This commit is contained in:
Andras Schmelczer 2026-09-27 08:29:17 +01:00
commit 3dab48f58b

View file

@ -7,7 +7,7 @@ import {
type StoredDatabase
} from "../sync-client/src/persistence/database";
import { FileOperations } from "../sync-client/src/file-operations/file-operations";
import { toStoredSnapshot } from "../sync-client/src/snapshot";
import { hashSnapshot } from "../sync-client/src/snapshot";
import type { ServerConfig } from "../sync-client/src/services/server-config";
import { mergeFileManifests } from "../sync-client/src/sync-operations/file-manifest";
import { assertManifest, pathDecision } from "./oracles";
@ -37,7 +37,7 @@ async function fixture(
initial.documents[id] = {
observedHash: (
await toStoredSnapshot((await disk.read(path))!)
await hashSnapshot((await disk.read(path))!)
).hash
};
const persistence = new MemoryPersistence({ database: initial });
@ -75,7 +75,7 @@ async function swapFixture() {
next.local = { a: "b.md", b: "a.md", c: "nested/c.md" };
next.documents.c = {};
const writes = {
c: { replacement: await toStoredSnapshot({ content: bytes("C") }) }
c: { replacement: await hashSnapshot({ content: bytes("C") }) }
};
const expected = new Map([
["a.md", bytes("B")],
@ -129,8 +129,8 @@ async function mergeFixture() {
next: structuredClone(current.initial),
writes: {
a: {
expected: await toStoredSnapshot({ content: bytes(base) }),
replacement: await toStoredSnapshot({ content: bytes(remote) })
expected: await hashSnapshot({ content: bytes(base) }),
replacement: await hashSnapshot({ content: bytes(remote) })
}
},
expected: new Map([
@ -154,7 +154,7 @@ async function deletionFixture() {
next,
writes: {
a: {
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote binary\0")
})
}
@ -178,8 +178,8 @@ async function permanentDestinationFixture() {
},
writes: {
a: {
expected: await toStoredSnapshot({ content: bytes("A") }),
replacement: await toStoredSnapshot({
expected: await hashSnapshot({ content: bytes("A") }),
replacement: await hashSnapshot({
content: bytes("REMOTE")
})
}
@ -418,8 +418,8 @@ for (const phase of ["before", "durable"]) {
await current.disk.userDelete("a.md");
await current.disk.userWrite("a.md", bytes("new incarnation"));
const changes: LocalChange[] = [
{ type: "delete", path: "a.md" },
{ type: "create", path: "a.md" }
{ type: "delete", path: "a.md", changeId: "delete" },
{ type: "create", path: "a.md", changeId: "recreate" }
];
const scan = async () => {
const runtime = current.restart();
@ -475,7 +475,12 @@ for (const editedContent of ["new bytes", "B"]) {
await current.disk.userRename("a.md", "moved.md");
await current.disk.userWrite("moved.md", bytes(editedContent));
const changes: LocalChange[] = [
{ type: "move", oldPath: "a.md", relativePath: "moved.md" }
{
type: "move",
oldPath: "a.md",
relativePath: "moved.md",
changeId: "move"
}
];
await scanChanges(runtime, changes);
assert.deepEqual(
@ -509,7 +514,12 @@ for (const equalContent of [false, true]) {
["temporary.md", "b.md"]
]) {
await current.disk.userRename(oldPath, relativePath);
changes.push({ type: "move", oldPath, relativePath });
changes.push({
type: "move",
oldPath,
relativePath,
changeId: oldPath
});
}
const expected = { a: "b.md", b: "a.md" };
const expectedFiles = new Map([