Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test(editor): strengthen failed-save regressions

Arham Wanifd04954fc525
diff --git a/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts b/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts
index 72d46d34d..4b85a62d5 100644
--- a/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts
+++ b/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts
@@ -146,23 +146,22 @@ describe("useSequentialTimelineOps", () => {
};
let firstResult: AxcutDocument | null | undefined;
- let secondSettled = false;
+ let secondResult: AxcutDocument | null | undefined;
await act(async () => {
const p1 = result.current.apply(op1);
const p2 = result.current.apply(op2);
firstResult = await p1;
- await p2.then(() => {
- secondSettled = true;
- });
+ secondResult = await p2;
});
expect(firstResult).toBeNull();
- expect(secondSettled).toBe(true);
+ expect(secondResult).not.toBeNull();
expect(toastErrorMock).toHaveBeenCalledWith("Save failed", {
description: "save failed",
});
// The queue survived the first failure — both saves were attempted.
expect(saveDocument).toHaveBeenCalledTimes(2);
+ expect(saveDocument).toHaveBeenNthCalledWith(2, secondResult);
});
it("returns null when the store has no document and no fallback is supplied", async () => {
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index 31cc075cf..52f39d5e0 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -569,6 +569,10 @@ describe("useTimeline zoom modifiers (rotation + focus mode)", () => {
cy: 0.5,
});
expect(useProjectStore.getState().dirty).toBe(false);
+ // The live edit advanced revision once; restoring a different document
+ // advances it again so async work cannot mistake the rollback for the
+ // optimistic document it replaced.
+ expect(useProjectStore.getState().revision).toBe(3);
expect(toastErrorMock).toHaveBeenCalledWith("Save failed", {
description: "project file locked",
});