vault-link/frontend/deterministic-tests/src/tests/double-offline-cycle.test.ts
Andras Schmelczer a33e4bbcb9 Add deterministic-tests workspace
Scripted multi-client harness against a real server (~110 scenario
tests, server-control, managed-websocket, test-runner). Wires the new
package into frontend/package.json workspaces and the lint script.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:11:16 +01:00

77 lines
2.1 KiB
TypeScript

import type { AssertableState } from "../utils/assertable-state";
import type { TestDefinition } from "../test-definition";
export const doubleOfflineCycleTest: TestDefinition = {
description:
"Client 0 goes through three offline-edit-reconnect cycles. " +
"Each offline edit must propagate to client 1 after reconnection.",
clients: 2,
steps: [
{
type: "create",
client: 0,
path: "doc.md",
content: "initial"
},
{ type: "enable-sync", client: 0 },
{ type: "enable-sync", client: 1 },
{ type: "barrier" },
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertContent("doc.md", "initial");
}
},
{ type: "disable-sync", client: 0 },
{
type: "update",
client: 0,
path: "doc.md",
content: "first edit"
},
{ type: "enable-sync", client: 0 },
{ type: "barrier" },
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertContent("doc.md", "first edit");
}
},
{ type: "disable-sync", client: 0 },
{
type: "update",
client: 0,
path: "doc.md",
content: "second edit"
},
{ type: "enable-sync", client: 0 },
{ type: "barrier" },
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertContent("doc.md", "second edit");
}
},
{ type: "disable-sync", client: 0 },
{
type: "update",
client: 0,
path: "doc.md",
content: "third edit"
},
{ type: "enable-sync", client: 0 },
{ type: "barrier" },
{
type: "assert-consistent",
verify: (s: AssertableState): void => {
s.assertFileCount(1).assertContent("doc.md", "third edit");
}
}
]
};