From 8519af87206475043f996a925c545392533f289b Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 13 Jan 2026 10:03:41 -0700 Subject: [PATCH] fix(e2e): add race condition guards to checkpoint UI tests Four checkpoint tests were calling count() immediately after the API response without waiting for React to render. This caused intermittent failures where the locator found 0 checkpoint items despite the API returning 3 checkpoints. Fix: Wait for checkpoint items OR empty state to be visible before calling count() to ensure React has finished rendering. Tests fixed: - should show restore confirmation dialog - should display checkpoint diff preview - should display checkpoint metadata - should allow deleting checkpoint Result: 48/50 checkpoint tests pass (96%). Remaining 2 failures are WebKit login timeouts tracked in #230. --- tests/e2e/test_checkpoint_ui.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/e2e/test_checkpoint_ui.spec.ts b/tests/e2e/test_checkpoint_ui.spec.ts index a208f0b8..522f47d2 100644 --- a/tests/e2e/test_checkpoint_ui.spec.ts +++ b/tests/e2e/test_checkpoint_ui.spec.ts @@ -280,6 +280,9 @@ test.describe('Checkpoint UI Workflow', () => { const checkpointItems = page.locator('[data-testid^="checkpoint-item-"]'); const emptyState = page.locator('[data-testid="checkpoint-empty-state"]'); + // Wait for either checkpoint items OR empty state to be visible (prevents race condition) + await expect(checkpointItems.first().or(emptyState)).toBeVisible({ timeout: TIMEOUTS.DOM_UPDATE }); + const count = await checkpointItems.count(); if (count > 0) { @@ -310,6 +313,9 @@ test.describe('Checkpoint UI Workflow', () => { const checkpointItems = page.locator('[data-testid^="checkpoint-item-"]'); const emptyState = page.locator('[data-testid="checkpoint-empty-state"]'); + // Wait for either checkpoint items OR empty state to be visible (prevents race condition) + await expect(checkpointItems.first().or(emptyState)).toBeVisible({ timeout: TIMEOUTS.DOM_UPDATE }); + const count = await checkpointItems.count(); if (count > 0) { @@ -352,6 +358,9 @@ test.describe('Checkpoint UI Workflow', () => { const checkpointItems = page.locator('[data-testid^="checkpoint-item-"]'); const emptyState = page.locator('[data-testid="checkpoint-empty-state"]'); + // Wait for either checkpoint items OR empty state to be visible (prevents race condition) + await expect(checkpointItems.first().or(emptyState)).toBeVisible({ timeout: TIMEOUTS.DOM_UPDATE }); + const count = await checkpointItems.count(); if (count > 0) { @@ -379,6 +388,9 @@ test.describe('Checkpoint UI Workflow', () => { const checkpointItems = page.locator('[data-testid^="checkpoint-item-"]'); const emptyState = page.locator('[data-testid="checkpoint-empty-state"]'); + // Wait for either checkpoint items OR empty state to be visible (prevents race condition) + await expect(checkpointItems.first().or(emptyState)).toBeVisible({ timeout: TIMEOUTS.DOM_UPDATE }); + const count = await checkpointItems.count(); if (count > 0) {