From 60d551256ce7423a4ecc079d940c58dfdf31712a Mon Sep 17 00:00:00 2001 From: Owen McGirr Date: Tue, 8 Sep 2026 14:42:19 +0100 Subject: [PATCH] fix: await the pairing queue focus assertion "handles simultaneous pairing requests without discarding the queue" failed intermittently on CI while passing locally. Its final focus assertion was not wrapped in waitFor, unlike the earlier one in the same test. PairingDialog moves focus from a passive effect keyed on `requests` (src/App.tsx). The preceding waitFor only observes that the approved device's heading is gone; it does not guarantee that effect has run for the re-rendered dialog, so under CI load the assertion can catch the intermediate state. Scanned the rest of the suite for the same pattern. The three other unwrapped positive toHaveFocus assertions follow a synchronous fireEvent or an already-awaited findBy, so their focus is set before the assertion is reachable; they are left strict deliberately, since wrapping a deterministic assertion in waitFor would mask a real regression where focus arrives late. The two not.toHaveFocus assertions must stay unwrapped, as waitFor would pass on a state that could still change. Closes #694 Co-Authored-By: Claude Opus 5 (1M context) --- src/App.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.test.tsx b/src/App.test.tsx index d60c9219..4cb73a6c 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -291,7 +291,7 @@ describe("Switchify PC shell", () => { await waitFor(() => expect(screen.queryByRole("heading", { name: "Galaxy" })).not.toBeInTheDocument()); expect(approve).toHaveBeenCalledWith("pair-2"); expect(screen.getByRole("heading", { name: "Pixel" })).toBeInTheDocument(); - expect(screen.getByRole("button", { name: "Reject pairing request from Pixel, code 111111" })).toHaveFocus(); + await waitFor(() => expect(screen.getByRole("button", { name: "Reject pairing request from Pixel, code 111111" })).toHaveFocus()); }); it("clears a cancelled pairing request from the setup guide runtime event", async () => {