This commit is contained in:
@@ -43,6 +43,23 @@ test("merge replaces matching ids and keeps unrelated records", () => {
|
||||
assert.ok(merged.vaults[0].resources.some((item) => item.id === "resource-2"));
|
||||
});
|
||||
|
||||
test("server sync keeps newer fields and sessions from both devices", () => {
|
||||
const remote = library([resource({
|
||||
title: "Remote title",
|
||||
updatedAt: "2026-01-02T00:00:00.000Z",
|
||||
sessions: [{ id: "remote-session", end: 20, createdAt: "2026-01-02T00:00:00.000Z" }],
|
||||
})]);
|
||||
const local = library([resource({
|
||||
title: "Newer local title",
|
||||
updatedAt: "2026-01-03T00:00:00.000Z",
|
||||
sessions: [{ id: "local-session", end: 30, createdAt: "2026-01-03T00:00:00.000Z" }],
|
||||
})]);
|
||||
const merged = Model.mergeForSync(remote, local);
|
||||
const synced = merged.vaults[0].resources[0];
|
||||
assert.equal(synced.title, "Newer local title");
|
||||
assert.deepEqual(synced.sessions.map((session) => session.id).sort(), ["local-session", "remote-session"]);
|
||||
});
|
||||
|
||||
test("vault and folder operations preserve records safely", () => {
|
||||
let data = Model.addVault(library(), "Second", "#abcdef");
|
||||
assert.equal(data.vaults.length, 2);
|
||||
|
||||
Reference in New Issue
Block a user