Skip to content

chore(e2e): Run keyless e2e tests in staging database #5078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion integration/models/applicationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export const applicationConfig = () => {
[...env.privateVariables]
.filter(([_, v]) => v)
.map(([k, v]) => `${envFormatters.private(k)}=${v}`)
.join('\n'),
.join('\n') +
'\n',
);
};
return defaultWriter;
Expand Down
7 changes: 6 additions & 1 deletion integration/presets/envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ export const instanceKeys = getInstanceKeys();

const base = environmentConfig()
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
.setEnvVariable('public', 'CLERK_KEYLESS_DISABLED', true)
.setEnvVariable('public', 'CLERK_SIGN_IN_URL', '/sign-in')
.setEnvVariable('public', 'CLERK_SIGN_UP_URL', '/sign-up')
.setEnvVariable('public', 'CLERK_JS_URL', constants.E2E_APP_CLERK_JS || 'http://localhost:18211/clerk.browser.js');

const withKeyless = base.clone().setEnvVariable('public', 'CLERK_ENABLE_KEYLESS', true);
const withKeyless = base
.clone()
// Creates keyless applications in our staging database.
.setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev')
.setEnvVariable('public', 'CLERK_KEYLESS_DISABLED', false);

const withEmailCodes = base
.clone()
Expand Down
14 changes: 8 additions & 6 deletions integration/tests/next-quickstart-keyless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ const mockClaimedInstanceEnvironmentCall = async (page: Page) => {
test.describe('Keyless mode @quickstart', () => {
test.describe.configure({ mode: 'serial' });
let app: Application;
let dashboardUrl = 'https://dashboard.clerk.com/';

test.beforeAll(async () => {
app = await commonSetup.commit();
await app.setup();
await app.withEnv(appConfigs.envs.withKeyless);
if (appConfigs.envs.withKeyless.privateVariables.get('CLERK_API_URL')?.includes('clerkstage')) {
dashboardUrl = 'https://dashboard.clerkstage.dev/';
}
await app.dev();
});

Expand Down Expand Up @@ -74,7 +78,7 @@ test.describe('Keyless mode @quickstart', () => {

await newPage.waitForLoadState();
await newPage.waitForURL(url => {
const urlToReturnTo = 'https://dashboard.clerk.com/apps/claim?token=';
const urlToReturnTo = `${dashboardUrl}apps/claim?token=`;
return (
url.pathname === '/apps/claim/sign-in' &&
url.searchParams.get('sign_in_force_redirect_url')?.startsWith(urlToReturnTo) &&
Expand Down Expand Up @@ -102,11 +106,9 @@ test.describe('Keyless mode @quickstart', () => {
]);

await newPage.waitForLoadState();
await newPage.waitForURL(url =>
url.href.startsWith(
'https://dashboard.clerk.com/sign-in?redirect_url=https%3A%2F%2Fdashboard.clerk.com%2Fapps%2Fapp_',
),
);
await newPage.waitForURL(url => {
return url.href.startsWith(`${dashboardUrl}sign-in?redirect_url=${encodeURIComponent(dashboardUrl)}apps%2Fapp_`);
});
});

test('Claimed application with keys inside .env, on dismiss, keyless prompt is removed.', async ({
Expand Down