Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/wild-clocks-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
54 changes: 38 additions & 16 deletions integration/tests/next-quickstart-keyless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,44 @@

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
);
});
await newPage.waitForURL(
url => {
// Log the URL to help debug
console.log('Current URL:', url.href);
console.log('Pathname:', url.pathname);

// Accept Vercel login redirect (which contains the dashboard claim URL with framework param)
if (url.hostname === 'vercel.com' && url.pathname === '/login') {
// Decode the nested URL to check if it contains our claim URL with framework param
const decodedUrl = decodeURIComponent(url.href);
if (
decodedUrl.includes('dashboard.clerkstage.dev/apps/claim') &&
decodedUrl.includes('token=') &&
decodedUrl.includes('framework=nextjs')
) {
console.log('Found Vercel SSO redirect with correct claim URL and framework parameter');
return true;
}
}

// Also accept if we're directly on the dashboard
const isDashboard = url.href.includes(dashboardUrl);
if (isDashboard) {
const isClaimPage = url.pathname.includes('/apps/claim') || url.pathname.includes('/sign-in');
if (isClaimPage) {
const signInForceRedirectUrl = url.searchParams.get('sign_in_force_redirect_url');
if (signInForceRedirectUrl && signInForceRedirectUrl.includes('token=')) {
console.log('Found dashboard claim page with token');
return true;
}
}
}

console.log('Still waiting...');
return false;
},
{ timeout: 45000 },
);
});

test('Lands on claimed application with missing explicit keys, expanded by default, click to get keys from dashboard.', async ({
Expand Down
54 changes: 38 additions & 16 deletions integration/tests/tanstack-start/keyless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,44 @@

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
);
});
await newPage.waitForURL(
url => {
// Log the URL to help debug
console.log('Current URL:', url.href);
console.log('Pathname:', url.pathname);

// Accept Vercel login redirect (which contains the dashboard claim URL with framework param)
if (url.hostname === 'vercel.com' && url.pathname === '/login') {
// Decode the nested URL to check if it contains our claim URL with framework param
const decodedUrl = decodeURIComponent(url.href);
if (
decodedUrl.includes('dashboard.clerkstage.dev/apps/claim') &&
decodedUrl.includes('token=') &&
decodedUrl.includes('framework=tanstack-react-start')
) {
console.log('Found Vercel SSO redirect with correct claim URL and framework parameter');
return true;
}
}

// Also accept if we're directly on the dashboard
const isDashboard = url.href.includes(dashboardUrl);
if (isDashboard) {
const isClaimPage = url.pathname.includes('/apps/claim') || url.pathname.includes('/sign-in');
if (isClaimPage) {
const signInForceRedirectUrl = url.searchParams.get('sign_in_force_redirect_url');
if (signInForceRedirectUrl && signInForceRedirectUrl.includes('token=')) {
console.log('Found dashboard claim page with token');
return true;
}
}
}

console.log('Still waiting...');
return false;
},
{ timeout: 45000 },
);
});

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