Skip to content

Commit ba223aa

Browse files
committed
chore: additional checks
1 parent 6608a4b commit ba223aa

2 files changed

Lines changed: 76 additions & 32 deletions

File tree

integration/tests/next-quickstart-keyless.test.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,44 @@ test.describe('Keyless mode @quickstart', () => {
8888

8989
await newPage.waitForLoadState();
9090

91-
await newPage.waitForURL(url => {
92-
const signInForceRedirectUrl = url.searchParams.get('sign_in_force_redirect_url');
93-
const signUpForceRedirectUrl = url.searchParams.get('sign_up_force_redirect_url');
94-
95-
// Parse the redirect URLs to check structure instead of using startsWith
96-
const signInRedirectHasClaimToken =
97-
signInForceRedirectUrl && new URL(signInForceRedirectUrl).searchParams.has('token');
98-
99-
const signUpRedirectIsValid =
100-
(signUpForceRedirectUrl?.startsWith(`${dashboardUrl}apps/claim`) &&
101-
new URL(signUpForceRedirectUrl).searchParams.has('token')) ||
102-
(signUpForceRedirectUrl?.startsWith(`${dashboardUrl}prepare-account`) &&
103-
signUpForceRedirectUrl?.includes(encodeURIComponent('apps/claim?token=')));
104-
105-
return url.pathname === '/apps/claim/sign-in' && signInRedirectHasClaimToken && signUpRedirectIsValid;
106-
});
91+
await newPage.waitForURL(
92+
url => {
93+
// Log the URL to help debug
94+
console.log('Current URL:', url.href);
95+
console.log('Pathname:', url.pathname);
96+
97+
// Accept Vercel login redirect (which contains the dashboard claim URL with framework param)
98+
if (url.hostname === 'vercel.com' && url.pathname === '/login') {
99+
// Decode the nested URL to check if it contains our claim URL with framework param
100+
const decodedUrl = decodeURIComponent(url.href);
101+
if (
102+
decodedUrl.includes('dashboard.clerkstage.dev/apps/claim') &&
103+
decodedUrl.includes('token=') &&
104+
decodedUrl.includes('framework=nextjs')
105+
) {
106+
console.log('Found Vercel SSO redirect with correct claim URL and framework parameter');
107+
return true;
108+
}
109+
}
110+
111+
// Also accept if we're directly on the dashboard
112+
const isDashboard = url.href.includes(dashboardUrl);
113+
if (isDashboard) {
114+
const isClaimPage = url.pathname.includes('/apps/claim') || url.pathname.includes('/sign-in');
115+
if (isClaimPage) {
116+
const signInForceRedirectUrl = url.searchParams.get('sign_in_force_redirect_url');
117+
if (signInForceRedirectUrl && signInForceRedirectUrl.includes('token=')) {
118+
console.log('Found dashboard claim page with token');
119+
return true;
120+
}
121+
}
122+
}
123+
124+
console.log('Still waiting...');
125+
return false;
126+
},
127+
{ timeout: 45000 },
128+
);
107129
});
108130

109131
test('Lands on claimed application with missing explicit keys, expanded by default, click to get keys from dashboard.', async ({

integration/tests/tanstack-start/keyless.test.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)