From 721bdfaf53f1bc54a0254909ddcd33d13bdbd203 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 14 Jan 2026 21:59:23 +0000 Subject: [PATCH] test(e2e): avoid networkidle in hydration checks The app performs background polling/analytics, so networkidle can hang. Use domcontentloaded + short waits to reliably catch hydration errors. Co-authored-by: dennis --- e2e/hydration.spec.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/e2e/hydration.spec.ts b/e2e/hydration.spec.ts index 3522bfb..cba05f0 100644 --- a/e2e/hydration.spec.ts +++ b/e2e/hydration.spec.ts @@ -19,9 +19,11 @@ test.describe('Hydration Tests', () => { } }); - // Navigate to home page - await page.goto('/en', { waitUntil: 'networkidle' }); - await page.waitForLoadState('domcontentloaded'); + // Navigate to home page. + // Avoid `networkidle` because the app has background polling/analytics requests. + await page.goto('/en', { waitUntil: 'domcontentloaded' }); + // Give hydration a moment to run + await page.waitForTimeout(1000); // Check for hydration errors const hydrationErrors = consoleErrors.filter(error => @@ -51,8 +53,8 @@ test.describe('Hydration Tests', () => { } }); - await page.goto('/en'); - await page.waitForLoadState('networkidle'); + await page.goto('/en', { waitUntil: 'domcontentloaded' }); + await page.waitForTimeout(500); // Check for duplicate key warnings const keyWarnings = consoleWarnings.filter(warning => @@ -71,14 +73,15 @@ test.describe('Hydration Tests', () => { } }); - await page.goto('/en', { waitUntil: 'networkidle' }); - await page.waitForLoadState('domcontentloaded'); + await page.goto('/en', { waitUntil: 'domcontentloaded' }); + await page.waitForTimeout(500); // Navigate to projects page via link const projectsLink = page.locator('a[href*="/projects"]').first(); if (await projectsLink.count() > 0) { await projectsLink.click(); await page.waitForLoadState('domcontentloaded'); + await page.waitForTimeout(500); // Check for errors after navigation const hydrationErrors = consoleErrors.filter(error => @@ -95,8 +98,8 @@ test.describe('Hydration Tests', () => { // Get initial HTML const initialHTML = await page.content(); - // Wait for React to hydrate - await page.waitForLoadState('networkidle'); + // Wait for React to hydrate (avoid networkidle due to background requests) + await page.waitForTimeout(1000); // Get HTML after hydration const hydratedHTML = await page.content(); @@ -109,7 +112,7 @@ test.describe('Hydration Tests', () => { test('Interactive elements work after hydration', async ({ page }) => { await page.goto('/en'); - await page.waitForLoadState('networkidle'); + await page.waitForTimeout(1000); // Try to find and click interactive elements const buttons = page.locator('button, a[role="button"]');