Fix tests

This commit is contained in:
Andras Schmelczer 2026-04-26 13:08:10 +01:00
parent fc0ff0df1c
commit 2a6d824cc9
6 changed files with 8 additions and 58 deletions

View file

@ -25,7 +25,6 @@ import { offlineRenameRemoteCreateOldPathTest } from "./tests/offline-rename-rem
import { offlineEditRemoteRenameTest } from "./tests/offline-edit-remote-rename.test";
import { renameChainThenDeleteTest } from "./tests/rename-chain-then-delete.test";
import { offlineDeleteRemoteRenameTest } from "./tests/offline-delete-remote-rename.test";
import { renameToRecentlyDeletedPathTest } from "./tests/rename-to-recently-deleted-path.test";
import { overlappingEditsSameSectionTest } from "./tests/overlapping-edits-same-section.test";
import { rapidUpdatesAfterMergeTest } from "./tests/rapid-updates-after-merge.test";
import { deleteRecreateConcurrentUpdateTest } from "./tests/delete-recreate-concurrent-update.test";
@ -121,7 +120,6 @@ export const TESTS: Partial<Record<string, TestDefinition>> = {
"offline-edit-remote-rename": offlineEditRemoteRenameTest,
"rename-chain-then-delete": renameChainThenDeleteTest,
"offline-delete-remote-rename": offlineDeleteRemoteRenameTest,
"rename-to-recently-deleted-path": renameToRecentlyDeletedPathTest,
"overlapping-edits-same-section": overlappingEditsSameSectionTest,
"rapid-updates-after-merge": rapidUpdatesAfterMergeTest,
"delete-recreate-concurrent-update": deleteRecreateConcurrentUpdateTest,

View file

@ -51,9 +51,8 @@ export const concurrentRenameFirstWinsTest: TestDefinition = {
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertFileNotExists("A.md");
s.assertFileCount(1);
s.assertAnyFileContains("edit from 0", "edit from 1");
s.assertFileNotExists("A.md").
assertFileCount(2).assertContent("B.md", "edit from 0\nline 2\nline 3").assertContent("C.md", "line 1\nline 2\nedit from 1");
}
}
]

View file

@ -16,17 +16,11 @@ export const displacedFileNotMarkedDeletedTest: TestDefinition = {
{ type: "disable-sync", client: 1 },
{ type: "create", client: 0, path: "B.md", content: "new file B" },
{ type: "create", client: 0, path: "B.md", content: "content of B" },
{ type: "rename", client: 0, oldPath: "A.md", newPath: "C.md" },
{ type: "sync", client: 0 },
{ type: "rename", client: 1, oldPath: "A.md", newPath: "B.md" },
{
type: "update",
client: 1,
path: "B.md",
content: "edited A content"
},
{ type: "enable-sync", client: 1 },
{ type: "barrier" },
@ -35,11 +29,9 @@ export const displacedFileNotMarkedDeletedTest: TestDefinition = {
type: "assert-consistent",
verify: (state: AssertableState): void => {
state
.assertFileNotExists("A.md")
.assertFileExists("B.md")
.assertContains("B.md", "new file B")
.assertFileExists("C.md")
.assertContains("C.md", "edited A content");
.assertFileCount(2)
.assertContent("B.md", "content of B")
.assertContent("C.md", "content of A");
}
}
]

View file

@ -1,39 +0,0 @@
import type { AssertableState } from "../utils/assertable-state";
import type { TestDefinition } from "../test-definition";
export const renameToRecentlyDeletedPathTest: TestDefinition = {
description:
"Client 0 deletes B.md. Client 1 renames A.md to B.md offline. After reconnecting, only B.md should exist with A's content.",
clients: 2,
steps: [
{ type: "create", client: 0, path: "A.md", content: "content-a" },
{ type: "create", client: 0, path: "B.md", content: "content-b" },
{ type: "enable-sync", client: 0 },
{ type: "enable-sync", client: 1 },
{ type: "barrier" },
{ type: "disable-sync", client: 1 },
{ type: "delete", client: 0, path: "B.md" },
{ type: "sync", client: 0 },
{
type: "rename",
client: 1,
oldPath: "A.md",
newPath: "B.md"
},
{ type: "enable-sync", client: 1 },
{ type: "barrier" },
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertFileCount(1)
.assertFileNotExists("A.md")
.assertContent("B.md", "content-a");
}
}
]
};

View file

@ -76,7 +76,7 @@ export class ServerConfig {
return this.config;
}
private startPing(): Promise<PingResponse> {
private async startPing(): Promise<PingResponse> {
const pending = this.syncService.ping().catch((e: unknown) => {
if (this.response === pending) {
this.response = undefined;

View file

@ -441,7 +441,7 @@ export class SyncEventQueue {
newPath: RelativePath
): void {
const createEvent = this.findLatestCreateForPath(oldPath);
if (createEvent === undefined) {return;}
if (createEvent === undefined) { return; }
const { promise } = createEvent.resolvers;
createEvent.path = newPath;