diff --git a/tests/e2e/07-conversion-funnel.spec.ts b/tests/e2e/07-conversion-funnel.spec.ts index 3dc15b3..03bd950 100644 --- a/tests/e2e/07-conversion-funnel.spec.ts +++ b/tests/e2e/07-conversion-funnel.spec.ts @@ -134,10 +134,10 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { // ── Step 4: Navigate to stake page ── console.log('[FUNNEL] Navigating to stake page...'); await navigateSPA(page, '/app/stake'); - // eslint-disable-next-line no-restricted-syntax -- waitForTimeout: no event source exists for Ponder indexing lag and UI re-renders after on-chain transactions in E2E tests. See AGENTS.md #Engineering Principles. - await page.waitForTimeout(2_000); - // Stake page may redirect to /app/login if no wallet connected. + // Wait for either page's root element to confirm the route has mounted. + await page.waitForSelector('.stake-view, .login-wrapper', { timeout: 15_000 }); + // Either outcome confirms the route is functional. const currentUrl = page.url(); const isStakePage = currentUrl.includes('/app/stake'); @@ -215,8 +215,8 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { // ── Step 4: Navigate to stake ── await navigateSPA(page, '/app/stake'); - // eslint-disable-next-line no-restricted-syntax -- waitForTimeout: no event source exists for Ponder indexing lag and UI re-renders after on-chain transactions in E2E tests. See AGENTS.md #Engineering Principles. - await page.waitForTimeout(2_000); + // Wait for either page's root element — stake or login redirect. + await page.waitForSelector('.stake-view, .login-wrapper', { timeout: 15_000 }); const currentUrl = page.url(); expect(currentUrl.includes('/app/stake') || currentUrl.includes('/app/login')).toBeTruthy(); @@ -274,9 +274,14 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { expect(hasUmami).toBeTruthy(); console.log('[ANALYTICS] ✅ Analytics tracker available in web-app context'); - // Wait for wallet auto-connection (injected provider) - // eslint-disable-next-line no-restricted-syntax -- waitForTimeout: no event source exists for Ponder indexing lag and UI re-renders after on-chain transactions in E2E tests. See AGENTS.md #Engineering Principles. - await page.waitForTimeout(3_000); + // Wait for wallet_connect event to appear in analytics — the injected provider + // fires this when the wallet auto-connects. Poll the events array rather than + // sleeping: this resolves as soon as the event fires, or times out gracefully. + await page.waitForFunction( + () => ((window as unknown as { __analytics_events?: Array<{ name: string }> }).__analytics_events ?? []) + .some(e => e.name === 'wallet_connect'), + { timeout: 10_000 }, + ).catch(() => { /* wallet may not auto-connect on this page — see check below */ }); const webAppEvents = await getAnalyticsEvents(page); console.log(`[ANALYTICS] Web-app events: ${JSON.stringify(webAppEvents)}`); @@ -286,7 +291,7 @@ test.describe('Conversion Funnel: Landing → Swap → Stake', () => { if (walletEvent) { console.log('[ANALYTICS] ✅ wallet_connect event verified'); } else { - console.log('[ANALYTICS] wallet_connect not fired yet (wallet may not auto-connect on this page)'); + console.log('[ANALYTICS] wallet_connect not fired (wallet did not auto-connect on this page)'); } console.log('[ANALYTICS] ✅ Analytics funnel verification complete');