diff --git a/src/App.test.tsx b/src/App.test.tsx index 4fb9b1c9..56152c8a 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -487,20 +487,22 @@ describe("Switchify PC shell", () => { stateHandler = handler; return () => undefined; }); + const markShown = vi.spyOn(api, "markSetupShown"); render(); await screen.findByRole("dialog", { name: "Pairing requests" }); expect(screen.queryByRole("dialog", { name: "Input access" })).not.toBeInTheDocument(); expect(screen.getByLabelText("Verification code for Galaxy")).toHaveTextContent("063781"); + // Let the auto-open state response settle first, so it cannot land after the cancellation and restore the pairing. + await waitFor(() => expect(markShown).toHaveBeenCalled()); + await act(() => markShown.mock.results[0].value); - act(() => stateHandler?.({ - ...structuredClone(browserState), - pendingPairings: [], - lastActivity: { kind: "info", message: "Pairing request cancelled." }, - })); + browserState.pendingPairings = []; + browserState.lastActivity = { kind: "info", message: "Pairing request cancelled." }; + act(() => stateHandler?.(structuredClone(browserState))); - await waitFor(() => expect(screen.queryByLabelText("Verification code for Galaxy")).not.toBeInTheDocument()); expect(await screen.findByRole("dialog", { name: "Input access" })).toBeInTheDocument(); + expect(screen.queryByLabelText("Verification code for Galaxy")).not.toBeInTheDocument(); }); it("creates a profile and records a desired key", async () => {