From ea700b224e4fe26b06d034e41938b773f1f7b16a Mon Sep 17 00:00:00 2001 From: johba Date: Mon, 23 Mar 2026 17:37:46 +0000 Subject: [PATCH] fix: use Promise.all for navigation-triggering clicks + cap test timeout Playwright click() can race with waitForURL when the click triggers window.location.href. Use Promise.all([waitForURL, click]) pattern to ensure the URL listener is active before the click fires. Also cap funnel test timeout to 3 minutes (these are navigation-only, no blockchain transactions) to fail fast rather than hang. Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/e2e/07-conversion-funnel.spec.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/e2e/07-conversion-funnel.spec.ts b/tests/e2e/07-conversion-funnel.spec.ts index 92f538b..8322fe8 100644 --- a/tests/e2e/07-conversion-funnel.spec.ts +++ b/tests/e2e/07-conversion-funnel.spec.ts @@ -33,6 +33,9 @@ async function getAnalyticsEvents(page: Page): Promise { + // Cap per-test timeout to 3 minutes — funnel tests are navigation-only, no transactions. + test.describe.configure({ timeout: 3 * 60 * 1000 }); + test.beforeAll(async () => { await validateStackHealthy(STACK_CONFIG); }); @@ -63,11 +66,12 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { // ── Step 2: Click CTA → navigates to /app/get-krk ── console.log('[FUNNEL] Clicking hero "Get $KRK" CTA...'); - await heroCta.click(); - - // The landing CTA sets window.location.href for /app/* paths, triggering - // a full-page navigation through Caddy to the webapp service. - await page.waitForURL('**/app/get-krk**', { timeout: 30_000 }); + // Use Promise.all to avoid race: the click triggers window.location.href + // which starts a full-page navigation through Caddy to the webapp. + await Promise.all([ + page.waitForURL('**/app/get-krk**', { timeout: 30_000 }), + heroCta.click(), + ]); console.log('[FUNNEL] Navigated to web-app get-krk page'); // Verify the Get KRK page rendered @@ -173,9 +177,10 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { const heroCta = page.locator('.header-cta button, .header-cta .k-button').first(); await expect(heroCta).toBeVisible({ timeout: 15_000 }); console.log('[FUNNEL-MOBILE] Clicking hero CTA...'); - await heroCta.click(); - - await page.waitForURL('**/app/get-krk**', { timeout: 30_000 }); + await Promise.all([ + page.waitForURL('**/app/get-krk**', { timeout: 30_000 }), + heroCta.click(), + ]); console.log('[FUNNEL-MOBILE] Navigated to get-krk page'); const getKrkHeading = page.getByRole('heading', { name: 'Get $KRK Tokens' });