From e6b41f65a5a5846f9b82cc5e87d2f00812272114 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Fri, 1 May 2026 16:47:34 -0700 Subject: [PATCH] fix: improve link click handling to wait for networkidle This ensures proper navigation waits for links that trigger client-side routing --- e2e/cucumber/step-definitions/common-steps.ts | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/e2e/cucumber/step-definitions/common-steps.ts b/e2e/cucumber/step-definitions/common-steps.ts index ddc0911..b0b3f8e 100644 --- a/e2e/cucumber/step-definitions/common-steps.ts +++ b/e2e/cucumber/step-definitions/common-steps.ts @@ -180,28 +180,18 @@ When('I click the {string} link', async function (linkText: string) { const selector = `a:has-text("${linkText}")`; console.log(`🌍 Clicking link: ${linkText}`); - // Get current URL - const currentUrl = world.page.url(); - // Click the link await world.page.click(selector); - // Wait a bit for navigation to start - await world.page.waitForTimeout(500); - - // Check if URL changed - const newUrl = world.page.url(); - if (newUrl === currentUrl) { - console.log(`🌍 URL did not change immediately after link click`); - // Wait for any navigation to complete - try { - await world.page.waitForLoadState('domcontentloaded', { timeout: 5000 }); - } catch { - console.log(`🌍 DOMContentLoaded not reached, continuing`); - } - } else { - console.log(`🌍 Page navigated to: ${newUrl}`); + // Wait for navigation to complete + try { + await world.page.waitForLoadState('networkidle', { timeout: 10000 }); + } catch { + console.log(`🌍 Networkidle not reached, continuing`); } + + const newUrl = world.page.url(); + console.log(`🌍 Page navigated to: ${newUrl}`); }); When('I click the {string} wordmark', async function (wordmarkText: string) {