From 908ddcd99c8f12ac73f91e66937bb170cbe9c67d Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 9 Feb 2026 15:57:50 -0600 Subject: [PATCH] fix(integration): replace external dashboard navigation with href assertions in keyless tests --- .../tests/next-quickstart-keyless.test.ts | 39 +++++-------------- .../tests/tanstack-start/keyless.test.ts | 39 +++++-------------- 2 files changed, 20 insertions(+), 58 deletions(-) diff --git a/integration/tests/next-quickstart-keyless.test.ts b/integration/tests/next-quickstart-keyless.test.ts index d143b60385e..bc142137788 100644 --- a/integration/tests/next-quickstart-keyless.test.ts +++ b/integration/tests/next-quickstart-keyless.test.ts @@ -84,26 +84,11 @@ test.describe('Keyless mode @quickstart', () => { const claim = await u.po.keylessPopover.promptsToClaim(); - const [newPage] = await Promise.all([context.waitForEvent('page'), claim.click()]); - - await newPage.waitForLoadState(); - - await newPage.waitForURL(url => { - const urlToReturnTo = `${dashboardUrl}apps/claim?token=`; - - const signUpForceRedirectUrl = url.searchParams.get('sign_up_force_redirect_url'); - - const signUpForceRedirectUrlCheck = - signUpForceRedirectUrl?.startsWith(urlToReturnTo) || - (signUpForceRedirectUrl?.startsWith(`${dashboardUrl}prepare-account`) && - signUpForceRedirectUrl?.includes(encodeURIComponent('apps/claim?token='))); - - return ( - url.pathname === '/apps/claim/sign-in' && - url.searchParams.get('sign_in_force_redirect_url')?.startsWith(urlToReturnTo) && - signUpForceRedirectUrlCheck - ); - }); + // Verify the claim link points to the correct dashboard URL + // without navigating to the external dashboard, which is flaky in CI. + const href = await claim.getAttribute('href'); + expect(href).toContain(`${dashboardUrl}apps/claim?token=`); + expect(href).toContain('return_url='); }); test('Lands on claimed application with missing explicit keys, expanded by default, click to get keys from dashboard.', async ({ @@ -119,15 +104,11 @@ test.describe('Keyless mode @quickstart', () => { expect(await u.po.keylessPopover.isExpanded()).toBe(true); await expect(u.po.keylessPopover.promptToUseClaimedKeys()).toBeVisible(); - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - u.po.keylessPopover.promptToUseClaimedKeys().click(), - ]); - - await newPage.waitForLoadState(); - await newPage.waitForURL(url => { - return url.href.startsWith(`${dashboardUrl}sign-in?redirect_url=${encodeURIComponent(dashboardUrl)}apps%2Fapp_`); - }); + // Verify the link points to the correct dashboard URL + // without navigating to the external dashboard, which is flaky in CI. + const href = await u.po.keylessPopover.promptToUseClaimedKeys().getAttribute('href'); + expect(href).toContain(dashboardUrl); + expect(href).toContain('apps/app_'); }); test('Claimed application with keys inside .env, on dismiss, keyless prompt is removed.', async ({ diff --git a/integration/tests/tanstack-start/keyless.test.ts b/integration/tests/tanstack-start/keyless.test.ts index 759409b4929..fad2e28fa50 100644 --- a/integration/tests/tanstack-start/keyless.test.ts +++ b/integration/tests/tanstack-start/keyless.test.ts @@ -64,26 +64,11 @@ test.describe('Keyless mode @tanstack-react-start', () => { const claim = await u.po.keylessPopover.promptsToClaim(); - const [newPage] = await Promise.all([context.waitForEvent('page'), claim.click()]); - - await newPage.waitForLoadState(); - - await newPage.waitForURL(url => { - const urlToReturnTo = `${dashboardUrl}apps/claim?token=`; - - const signUpForceRedirectUrl = url.searchParams.get('sign_up_force_redirect_url'); - - const signUpForceRedirectUrlCheck = - signUpForceRedirectUrl?.startsWith(urlToReturnTo) || - (signUpForceRedirectUrl?.startsWith(`${dashboardUrl}prepare-account`) && - signUpForceRedirectUrl?.includes(encodeURIComponent('apps/claim?token='))); - - return ( - url.pathname === '/apps/claim/sign-in' && - url.searchParams.get('sign_in_force_redirect_url')?.startsWith(urlToReturnTo) && - signUpForceRedirectUrlCheck - ); - }); + // Verify the claim link points to the correct dashboard URL + // without navigating to the external dashboard, which is flaky in CI. + const href = await claim.getAttribute('href'); + expect(href).toContain(`${dashboardUrl}apps/claim?token=`); + expect(href).toContain('return_url='); }); test('Lands on claimed application with missing explicit keys, expanded by default, click to get keys from dashboard.', async ({ @@ -99,15 +84,11 @@ test.describe('Keyless mode @tanstack-react-start', () => { expect(await u.po.keylessPopover.isExpanded()).toBe(true); await expect(u.po.keylessPopover.promptToUseClaimedKeys()).toBeVisible(); - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - u.po.keylessPopover.promptToUseClaimedKeys().click(), - ]); - - await newPage.waitForLoadState(); - await newPage.waitForURL(url => { - return url.href.startsWith(`${dashboardUrl}sign-in?redirect_url=${encodeURIComponent(dashboardUrl)}apps%2Fapp_`); - }); + // Verify the link points to the correct dashboard URL + // without navigating to the external dashboard, which is flaky in CI. + const href = await u.po.keylessPopover.promptToUseClaimedKeys().getAttribute('href'); + expect(href).toContain(dashboardUrl); + expect(href).toContain('apps/app_'); }); test('Keyless popover is removed after adding keys to .env and restarting.', async ({ page, context }) => {