diff --git a/apps/web/src/components/ChatView.agents.browser.tsx b/apps/web/src/components/ChatView.agents.browser.tsx index d00656693..d3ec5c61c 100644 --- a/apps/web/src/components/ChatView.agents.browser.tsx +++ b/apps/web/src/components/ChatView.agents.browser.tsx @@ -584,6 +584,11 @@ describe("ChatView (full app): agent browser tabs and rooms", () => { // One tab stop for the group; the arrow keys move along it and pick. expect(pill(astraId)?.tabIndex).toBe(0); expect(pill("primary")?.tabIndex).toBe(-1); + // The picker focuses its search box once more a frame and a tick after it + // (re)renders; on a busy machine that lands late. Let those pass first, + // or they pull focus off the pill before the arrow key. + await nextFrames(2); + await new Promise((resolve) => setTimeout(resolve, 0)); pill(astraId)!.focus(); await userEvent.keyboard("{ArrowLeft}"); await vi.waitFor(() => { diff --git a/apps/web/src/components/ChatView.panels.browser.tsx b/apps/web/src/components/ChatView.panels.browser.tsx index e259162c8..88e196c32 100644 --- a/apps/web/src/components/ChatView.panels.browser.tsx +++ b/apps/web/src/components/ChatView.panels.browser.tsx @@ -688,14 +688,34 @@ describe("ChatView (full app): right panel and header actions", () => { expect(railToggle.hasAttribute("data-pressed")).toBe(true); // A finger pushing the panel toward its edge closes it, as the toggle would. - const agentsPanel = await waitForElement( - () => document.querySelector("[data-agents-panel='tree']") as HTMLElement | null, - "The agents tab never opened.", + // The swipe goes to the panel as it is now: the tab reorder above can + // re-render it late on a busy machine, and a swipe on the element it + // replaced, or on a point something else still covers, reaches no drawer. + const swipeTarget = await vi.waitFor( + () => { + const panel = document.querySelector("[data-agents-panel='tree']"); + expect(panel, "The agents tab never opened.").not.toBeNull(); + const rect = panel!.getBoundingClientRect(); + const underFinger = document.elementFromPoint( + rect.left + rect.width * 0.75, + rect.top + rect.height / 2, + ); + expect( + underFinger !== null && panel!.contains(underFinger), + "Something other than the agents panel is under the finger.", + ).toBe(true); + // The finger lands on what is really there, not on the panel by reference. + return underFinger as HTMLElement; + }, + { timeout: 8_000, interval: 16 }, ); - touchSwipe(agentsPanel, 260); + touchSwipe(swipeTarget, 260); await vi.waitFor( () => { - expect(railToggle.hasAttribute("data-pressed")).toBe(false); + expect( + railToggle.hasAttribute("data-pressed"), + `The swipe did not close the panel (swiped element still on the page: ${swipeTarget.isConnected}).`, + ).toBe(false); }, { timeout: 8_000, interval: 16 }, );