Skip to content

Commit c7274dd

Browse files
committed
test: update yjs versioning tests for no-op applyRestore
1 parent 2542e76 commit c7274dd

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

packages/core/src/y/extensions/Versioning.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,17 @@ describe("createYjsVersioningAdapter", () => {
236236
expect(getEditorText(ctx.editor)).toContain("Content");
237237
});
238238

239-
it("applyRestore throws not-yet-implemented error", () => {
239+
it("applyRestore is a no-op (server-side restore propagates via live sync)", () => {
240240
ctx = createCollabEditor();
241+
ctx.editor.replaceBlocks(ctx.editor.document, [
242+
{ type: "paragraph", content: "Content" },
243+
]);
244+
241245
const adapter = createYjsVersioningAdapter(ctx.editor, ctx.fragment);
242-
expect(() => adapter.preview.applyRestore(new Uint8Array())).toThrow(
243-
/not yet implemented/i,
244-
);
246+
247+
// Should not throw and should leave the live document untouched.
248+
expect(() => adapter.preview.applyRestore(new Uint8Array())).not.toThrow();
249+
expect(getEditorText(ctx.editor)).toContain("Content");
245250
});
246251
});
247252

@@ -333,7 +338,7 @@ describe("Yjs versioning integration (VersioningExtension + in-memory endpoints)
333338
expect(getEditorText(ctx.editor)).toContain("Current state");
334339
});
335340

336-
it("restoreSnapshot rejects because applyRestore is not yet implemented", async () => {
341+
it("restoreSnapshot resolves with the restored snapshot content", async () => {
337342
ctx = createCollabEditor();
338343
const versioning = ctx.editor.getExtension(VersioningExtension)!;
339344

@@ -342,9 +347,11 @@ describe("Yjs versioning integration (VersioningExtension + in-memory endpoints)
342347
]);
343348
const snap = await versioning.createSnapshot({ name: "v1" });
344349

345-
await expect(versioning.restoreSnapshot!(snap.id)).rejects.toThrow(
346-
/not yet implemented/i,
347-
);
350+
// applyRestore is a no-op for the Yjs adapter (the backend applies the
351+
// restore and the change propagates over live sync), so restoreSnapshot
352+
// resolves with the snapshot content returned by the endpoint.
353+
const content = await versioning.restoreSnapshot!(snap.id);
354+
expect(content).toBeInstanceOf(Uint8Array);
348355
});
349356

350357
it("previewing multiple snapshots and switching between them", async () => {

0 commit comments

Comments
 (0)