From 7112e4b6bff935dcdcfc475e20b3719d7585251d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 28 Oct 2026 10:19:07 +0000 Subject: [PATCH] test(studio): wait for the first undo press before the edit that should block the second (#6652) --- .../studio/src/hooks/usePersistentEditHistory.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/studio/src/hooks/usePersistentEditHistory.test.ts b/packages/studio/src/hooks/usePersistentEditHistory.test.ts index 5b44f4eed6..da36d4eaba 100644 --- a/packages/studio/src/hooks/usePersistentEditHistory.test.ts +++ b/packages/studio/src/hooks/usePersistentEditHistory.test.ts @@ -317,8 +317,12 @@ it("refuses a second press whose edit is undone once an edit was made after the return run; }; const press = () => hook().undo({ readFile, claimedAfter: atKey, serialize }); - const presses = Promise.all([press(), press()]); - await vi.waitFor(() => expect(file()).toBe("B")); + const firstPress = press(); + const secondPress = press(); + // The first press must be over, not only its file written: the undo's closing sweep would take card.html + // into the undo, and the claim below would then hold nothing. + const first = await act(() => firstPress); + expect(file()).toBe("B"); writeFileSync(join(dir, "card.html"), "Y"); await act(() => hook().recordEdit({ @@ -328,7 +332,7 @@ it("refuses a second press whose edit is undone once an edit was made after the ); open(); - const [first, second] = await act(() => presses); + const second = await act(() => secondPress); expect(first).toMatchObject({ ok: true, label: "Undid: Moved Card" }); expect(second).toMatchObject({ ok: false, reason: "content-mismatch" });