From eedd242f26817e9a81ebcab19f5c813e43da02e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Titsworth-Morin?= Date: Fri, 1 May 2026 20:25:18 +0000 Subject: [PATCH] Stabilize worktree switcher test with explicit waitFor timeouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "clears stale files and git params when switching worktrees" test was flaky in CI — the default 1s waitFor timeout is insufficient when running full coverage on slower CI runners. Increased to 5s for all waitFor calls in both worktree tests. Co-Authored-By: Claude Opus 4.6 --- apps/web/tests/unit/pages/workspace.test.tsx | 59 ++++++++++++-------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/apps/web/tests/unit/pages/workspace.test.tsx b/apps/web/tests/unit/pages/workspace.test.tsx index 3d5d96de0..4d4b03787 100644 --- a/apps/web/tests/unit/pages/workspace.test.tsx +++ b/apps/web/tests/unit/pages/workspace.test.tsx @@ -698,17 +698,23 @@ describe('Workspace page', () => { it('restores active worktree from URL search params', async () => { renderWorkspace('/workspaces/ws-123?worktree=%2Fworkspaces%2Frepo-wt-feature-auth', true); - await waitFor(() => { - expect(mocks.getWorktrees).toHaveBeenCalledWith( - 'https://ws-ws-123.example.com', - 'ws-123', - 'tok_123' - ); - }); + await waitFor( + () => { + expect(mocks.getWorktrees).toHaveBeenCalledWith( + 'https://ws-ws-123.example.com', + 'ws-123', + 'tok_123' + ); + }, + { timeout: 5_000 } + ); - await waitFor(() => { - expect(screen.getByRole('button', { name: /Switch worktree \(feature\/auth\)/i })).toBeInTheDocument(); - }); + await waitFor( + () => { + expect(screen.getByRole('button', { name: /Switch worktree \(feature\/auth\)/i })).toBeInTheDocument(); + }, + { timeout: 5_000 } + ); expect(screen.getByTestId('location-probe').textContent).toContain( 'worktree=%2Fworkspaces%2Frepo-wt-feature-auth' ); @@ -720,25 +726,34 @@ describe('Workspace page', () => { true ); - await waitFor(() => { - expect(screen.getByRole('button', { name: /Switch worktree \(feature\/auth\)/i })).toBeInTheDocument(); - }); + await waitFor( + () => { + expect(screen.getByRole('button', { name: /Switch worktree \(feature\/auth\)/i })).toBeInTheDocument(); + }, + { timeout: 5_000 } + ); fireEvent.click(screen.getByRole('button', { name: /Switch worktree \(feature\/auth\)/i })); // Wait for the dropdown to render before clicking the worktree option - await waitFor(() => { - expect(screen.getByRole('button', { name: /^main \(primary\)/i })).toBeInTheDocument(); - }); + await waitFor( + () => { + expect(screen.getByRole('button', { name: /^main \(primary\)/i })).toBeInTheDocument(); + }, + { timeout: 5_000 } + ); fireEvent.click(screen.getByRole('button', { name: /^main \(primary\)/i })); - await waitFor(() => { - const probe = screen.getByTestId('location-probe').textContent ?? ''; - expect(probe).not.toContain('files='); - expect(probe).not.toContain('git='); - expect(probe).not.toContain('worktree='); - }); + await waitFor( + () => { + const probe = screen.getByTestId('location-probe').textContent ?? ''; + expect(probe).not.toContain('files='); + expect(probe).not.toContain('git='); + expect(probe).not.toContain('worktree='); + }, + { timeout: 5_000 } + ); }); describe('orphaned session recovery', () => {