@@ -68,22 +68,44 @@ test.describe('Keyless mode @tanstack-react-start', () => {
6868
6969 await newPage . waitForLoadState ( ) ;
7070
71- await newPage . waitForURL ( url => {
72- const signInForceRedirectUrl = url . searchParams . get ( 'sign_in_force_redirect_url' ) ;
73- const signUpForceRedirectUrl = url . searchParams . get ( 'sign_up_force_redirect_url' ) ;
74-
75- // Parse the redirect URLs to check structure instead of using startsWith
76- const signInRedirectHasClaimToken =
77- signInForceRedirectUrl && new URL ( signInForceRedirectUrl ) . searchParams . has ( 'token' ) ;
78-
79- const signUpRedirectIsValid =
80- ( signUpForceRedirectUrl ?. startsWith ( `${ dashboardUrl } apps/claim` ) &&
81- new URL ( signUpForceRedirectUrl ) . searchParams . has ( 'token' ) ) ||
82- ( signUpForceRedirectUrl ?. startsWith ( `${ dashboardUrl } prepare-account` ) &&
83- signUpForceRedirectUrl ?. includes ( encodeURIComponent ( 'apps/claim?token=' ) ) ) ;
84-
85- return url . pathname === '/apps/claim/sign-in' && signInRedirectHasClaimToken && signUpRedirectIsValid ;
86- } ) ;
71+ await newPage . waitForURL (
72+ url => {
73+ // Log the URL to help debug
74+ console . log ( 'Current URL:' , url . href ) ;
75+ console . log ( 'Pathname:' , url . pathname ) ;
76+
77+ // Accept Vercel login redirect (which contains the dashboard claim URL with framework param)
78+ if ( url . hostname === 'vercel.com' && url . pathname === '/login' ) {
79+ // Decode the nested URL to check if it contains our claim URL with framework param
80+ const decodedUrl = decodeURIComponent ( url . href ) ;
81+ if (
82+ decodedUrl . includes ( 'dashboard.clerkstage.dev/apps/claim' ) &&
83+ decodedUrl . includes ( 'token=' ) &&
84+ decodedUrl . includes ( 'framework=tanstack-react-start' )
85+ ) {
86+ console . log ( 'Found Vercel SSO redirect with correct claim URL and framework parameter' ) ;
87+ return true ;
88+ }
89+ }
90+
91+ // Also accept if we're directly on the dashboard
92+ const isDashboard = url . href . includes ( dashboardUrl ) ;
93+ if ( isDashboard ) {
94+ const isClaimPage = url . pathname . includes ( '/apps/claim' ) || url . pathname . includes ( '/sign-in' ) ;
95+ if ( isClaimPage ) {
96+ const signInForceRedirectUrl = url . searchParams . get ( 'sign_in_force_redirect_url' ) ;
97+ if ( signInForceRedirectUrl && signInForceRedirectUrl . includes ( 'token=' ) ) {
98+ console . log ( 'Found dashboard claim page with token' ) ;
99+ return true ;
100+ }
101+ }
102+ }
103+
104+ console . log ( 'Still waiting...' ) ;
105+ return false ;
106+ } ,
107+ { timeout : 45000 } ,
108+ ) ;
87109 } ) ;
88110
89111 test ( 'Lands on claimed application with missing explicit keys, expanded by default, click to get keys from dashboard.' , async ( {
0 commit comments