From 8f2e06bc32928d3e9e0ed8a0310a544eb077ecd5 Mon Sep 17 00:00:00 2001 From: Kacper Date: Wed, 17 Dec 2025 22:19:53 +0100 Subject: [PATCH] fix: improve waitForBoardView to handle zustand hydration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The zustand store may not have hydrated from localStorage by the time the board view first renders, causing board-view-no-project to appear briefly. Use waitForFunction to poll until board-view appears. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/ui/tests/utils/git/worktree.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/ui/tests/utils/git/worktree.ts b/apps/ui/tests/utils/git/worktree.ts index 52fc3900..f8e6da5d 100644 --- a/apps/ui/tests/utils/git/worktree.ts +++ b/apps/ui/tests/utils/git/worktree.ts @@ -459,6 +459,7 @@ export async function setupProjectWithStaleWorktree(page: Page, projectPath: str /** * Wait for the board view to load * Navigates to /board first since the index route shows WelcomeView + * Handles zustand store hydration timing (may show "no-project" briefly) */ export async function waitForBoardView(page: Page): Promise { // Navigate directly to /board route (index route shows welcome view) @@ -467,7 +468,19 @@ export async function waitForBoardView(page: Page): Promise { await page.goto('/board'); await page.waitForLoadState('networkidle'); } - await page.waitForSelector('[data-testid="board-view"]', { timeout: TIMEOUTS.long }); + + // Wait for either board-view (success) or board-view-no-project (store not hydrated yet) + // Then poll until board-view appears (zustand hydrates from localStorage) + await page.waitForFunction( + () => { + const boardView = document.querySelector('[data-testid="board-view"]'); + const noProject = document.querySelector('[data-testid="board-view-no-project"]'); + const loading = document.querySelector('[data-testid="board-view-loading"]'); + // Return true only when board-view is visible (store hydrated with project) + return boardView !== null; + }, + { timeout: TIMEOUTS.long } + ); } /**