Skip to content

Commit d4cd794

Browse files
authored
test(e2e): restructure account portal interoperability tests for core 3 (#7438)
1 parent 719afce commit d4cd794

File tree

8 files changed

+90
-32
lines changed

8 files changed

+90
-32
lines changed

integration/presets/envs.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,43 @@ const withEmailCodesQuickstart = withEmailCodes
8181
.setEnvVariable('public', 'CLERK_SIGN_IN_URL', '')
8282
.setEnvVariable('public', 'CLERK_SIGN_UP_URL', '');
8383

84-
const withAPCore1ClerkLatest = environmentConfig()
85-
.setId('withAPCore1ClerkLatest')
84+
const withAPCore1ClerkV4 = environmentConfig()
85+
.setId('withAPCore1ClerkV4')
8686
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
8787
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-email-codes').sk)
88-
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-email-codes').pk)
89-
.setEnvVariable('public', 'CLERK_JS_URL', constants.E2E_APP_CLERK_JS || 'http://localhost:18211/clerk.browser.js')
90-
.setEnvVariable('public', 'CLERK_UI_URL', constants.E2E_APP_CLERK_UI || 'http://localhost:18212/ui.browser.js');
88+
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-email-codes').pk);
9189

92-
const withAPCore1ClerkV4 = environmentConfig()
93-
.setId('withAPCore1ClerkV4')
90+
// Uses staging instance which runs Core 3
91+
const withAPCore3ClerkV4 = environmentConfig()
92+
.setId('withAPCore3ClerkV4')
93+
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
94+
.setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev')
95+
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-billing-staging').sk)
96+
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-billing-staging').pk);
97+
98+
const withAPCore1ClerkV6 = environmentConfig()
99+
.setId('withAPCore1ClerkV6')
94100
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
95101
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-email-codes').sk)
96102
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-email-codes').pk);
97103

98-
const withAPCore2ClerkLatest = environmentConfig()
99-
.setId('withAPCore2ClerkLatest')
104+
// Uses staging instance which runs Core 3
105+
const withAPCore3ClerkV6 = environmentConfig()
106+
.setId('withAPCore3ClerkV6')
100107
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
101-
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('core-2-all-enabled').sk)
102-
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('core-2-all-enabled').pk)
103-
.setEnvVariable('public', 'CLERK_JS_URL', constants.E2E_APP_CLERK_JS || 'http://localhost:18211/clerk.browser.js')
104-
.setEnvVariable('public', 'CLERK_UI_URL', constants.E2E_APP_CLERK_UI || 'http://localhost:18212/ui.browser.js');
108+
.setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev')
109+
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-billing-staging').sk)
110+
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-billing-staging').pk);
105111

106-
const withAPCore2ClerkV4 = environmentConfig()
107-
.setId('withAPCore2ClerkV4')
112+
// Uses staging instance which runs Core 3
113+
const withAPCore3ClerkLatest = environmentConfig()
114+
.setId('withAPCore3ClerkLatest')
108115
.setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true)
109-
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('core-2-all-enabled').sk)
110-
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('core-2-all-enabled').pk);
116+
.setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev')
117+
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-billing-staging').sk)
118+
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-billing-staging').pk)
119+
.setEnvVariable('public', 'CLERK_JS_URL', constants.E2E_APP_CLERK_JS || 'http://localhost:18211/clerk.browser.js')
120+
.setEnvVariable('public', 'CLERK_UI_URL', constants.E2E_APP_CLERK_UI || 'http://localhost:18212/ui.browser.js');
111121

112122
const withDynamicKeys = withEmailCodes
113123
.clone()
@@ -198,10 +208,11 @@ export const envs = {
198208
base,
199209
sessionsProd1,
200210
withAPIKeys,
201-
withAPCore1ClerkLatest,
202211
withAPCore1ClerkV4,
203-
withAPCore2ClerkLatest,
204-
withAPCore2ClerkV4,
212+
withAPCore1ClerkV6,
213+
withAPCore3ClerkV4,
214+
withAPCore3ClerkLatest,
215+
withAPCore3ClerkV6,
205216
withBilling,
206217
withBillingJwtV2,
207218
withCustomRoles,

integration/presets/next.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ const appRouterAPWithClerkNextV4 = appRouterQuickstart
4444
`,
4545
);
4646

47+
const appRouterAPWithClerkNextV6 = appRouterQuickstart
48+
.clone()
49+
.setName('next-app-router-ap-clerk-next-v6')
50+
.addDependency('@clerk/nextjs', '6');
51+
4752
export const next = {
4853
appRouter,
4954
appRouterTurbo,
5055
appRouterQuickstart,
5156
appRouterAPWithClerkNextLatest,
5257
appRouterAPWithClerkNextV4,
58+
appRouterAPWithClerkNextV6,
5359
} as const;

integration/tests/next-account-portal/clerk-v4-ap-core-2.test.ts renamed to integration/tests/next-account-portal/clerk-v4-ap-core-3.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { FakeUser } from '../../testUtils';
66
import { createTestUtils } from '../../testUtils';
77
import { testSignIn, testSignUp, testSSR } from './common';
88

9-
test.describe('Next with ClerkJS V4 <-> Account Portal Core 2 @ap-flows', () => {
9+
test.describe('Next with ClerkJS V4 <-> Account Portal Core 3 @ap-flows', () => {
1010
test.describe.configure({ mode: 'serial' });
1111
let app: Application;
1212
let fakeUser: FakeUser;
@@ -15,7 +15,7 @@ test.describe('Next with ClerkJS V4 <-> Account Portal Core 2 @ap-flows', () =>
1515
test.setTimeout(90_000); // Wait for app to be ready
1616
app = await appConfigs.next.appRouterAPWithClerkNextV4.clone().commit();
1717
await app.setup();
18-
await app.withEnv(appConfigs.envs.withAPCore2ClerkV4);
18+
await app.withEnv(appConfigs.envs.withAPCore3ClerkV4);
1919
await app.dev();
2020
const u = createTestUtils({ app });
2121
fakeUser = u.services.users.createFakeUser();

integration/tests/next-account-portal/clerk-v5-ap-core-2.test.ts renamed to integration/tests/next-account-portal/clerk-v6-ap-core-1.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import type { FakeUser } from '../../testUtils';
66
import { createTestUtils } from '../../testUtils';
77
import { testSignIn, testSignUp, testSSR } from './common';
88

9-
test.describe('Next with ClerkJS V5 <-> Account Portal Core 2 @ap-flows', () => {
9+
test.describe('Next with ClerkJS V6 <-> Account Portal Core 1 @ap-flows', () => {
1010
test.describe.configure({ mode: 'serial' });
1111
let app: Application;
1212
let fakeUser: FakeUser;
1313

1414
test.beforeAll(async () => {
1515
test.setTimeout(90_000); // Wait for app to be ready
16-
app = await appConfigs.next.appRouterAPWithClerkNextLatest.clone().commit();
16+
app = await appConfigs.next.appRouterAPWithClerkNextV6.clone().commit();
1717
await app.setup();
18-
await app.withEnv(appConfigs.envs.withAPCore2ClerkLatest);
18+
await app.withEnv(appConfigs.envs.withAPCore1ClerkV6);
1919
await app.dev();
2020
const u = createTestUtils({ app });
2121
fakeUser = u.services.users.createFakeUser();
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { test } from '@playwright/test';
2+
3+
import type { Application } from '../../models/application';
4+
import { appConfigs } from '../../presets';
5+
import type { FakeUser } from '../../testUtils';
6+
import { createTestUtils } from '../../testUtils';
7+
import { testSignIn, testSignUp, testSSR } from './common';
8+
9+
test.describe('Next with ClerkJS V6 <-> Account Portal Core 3 @ap-flows', () => {
10+
test.describe.configure({ mode: 'serial' });
11+
let app: Application;
12+
let fakeUser: FakeUser;
13+
14+
test.beforeAll(async () => {
15+
test.setTimeout(90_000); // Wait for app to be ready
16+
app = await appConfigs.next.appRouterAPWithClerkNextV6.clone().commit();
17+
await app.setup();
18+
await app.withEnv(appConfigs.envs.withAPCore3ClerkV6);
19+
await app.dev();
20+
const u = createTestUtils({ app });
21+
fakeUser = u.services.users.createFakeUser();
22+
await u.services.users.createBapiUser(fakeUser);
23+
});
24+
25+
test.afterAll(async () => {
26+
await fakeUser.deleteIfExists();
27+
await app.teardown();
28+
});
29+
30+
test('sign in', async ({ page, context }) => {
31+
await testSignIn({ app, page, context, fakeUser });
32+
});
33+
34+
test('sign up', async ({ page, context }) => {
35+
await testSignUp({ app, page, context, fakeUser });
36+
});
37+
38+
test('ssr', async ({ page, context }) => {
39+
await testSSR({ app, page, context, fakeUser });
40+
});
41+
});

integration/tests/next-account-portal/clerk-v5-ap-core-1.test.ts renamed to integration/tests/next-account-portal/clerk-v7-ap-core-3.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { FakeUser } from '../../testUtils';
66
import { createTestUtils } from '../../testUtils';
77
import { testSignIn, testSignUp, testSSR } from './common';
88

9-
test.describe('Next with ClerkJS V5 <-> Account Portal Core 1 @ap-flows', () => {
9+
test.describe('Next with ClerkJS V7 <-> Account Portal Core 3 @ap-flows', () => {
1010
test.describe.configure({ mode: 'serial' });
1111
let app: Application;
1212
let fakeUser: FakeUser;
@@ -15,7 +15,7 @@ test.describe('Next with ClerkJS V5 <-> Account Portal Core 1 @ap-flows', () =>
1515
test.setTimeout(90_000); // Wait for app to be ready
1616
app = await appConfigs.next.appRouterAPWithClerkNextLatest.clone().commit();
1717
await app.setup();
18-
await app.withEnv(appConfigs.envs.withAPCore1ClerkLatest);
18+
await app.withEnv(appConfigs.envs.withAPCore3ClerkLatest);
1919
await app.dev();
2020
const u = createTestUtils({ app });
2121
fakeUser = u.services.users.createFakeUser();

integration/tests/next-account-portal/common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export const testSignIn = async ({ app, page, context, fakeUser }: TestParams) =
3232
await u.po.signIn.waitForMounted();
3333

3434
const accountPortalURL = page.url();
35-
// Check that we are in Account Portal
36-
expect(accountPortalURL).toContain('.accounts.dev');
35+
// Check that we are in Account Portal (dev or staging)
36+
expect(accountPortalURL).toMatch(/\.accounts(stage\.dev|\.dev|\.stg)/);
3737
// Check that the DevBrowser JWT between localhost and AP is the same
3838
const accountPortalDbJwt = await context
3939
.cookies(accountPortalURL)
@@ -98,8 +98,8 @@ export const testSignUp = async ({ app, page, context }: TestParams) => {
9898

9999
// Check that the DevBrowser JWT between localhost and AP is the same
100100
const accountPortalURL = page.url();
101-
// Check that we are in Account Portal
102-
expect(accountPortalURL).toContain('.accounts.dev');
101+
// Check that we are in Account Portal (dev or staging)
102+
expect(accountPortalURL).toMatch(/\.accounts(stage\.dev|\.dev|\.stg)/);
103103
const accountPortalDbJwt = await context
104104
.cookies(accountPortalURL)
105105
.then(cookies => cookies.find(c => c.name === CLERK_DB_JWT_COOKIE_NAME)?.value);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"release:verdaccio": "if [ \"$(npm config get registry)\" = \"https://registry.npmjs.org/\" ]; then echo 'Error: Using default registry' && exit 1; else TURBO_CONCURRENCY=1 pnpm build && changeset publish --no-git-tag; fi",
3333
"test": "FORCE_COLOR=1 turbo test --concurrency=${TURBO_CONCURRENCY:-80%}",
3434
"test:cache:clear": "FORCE_COLOR=1 turbo test:cache:clear --continue --concurrency=${TURBO_CONCURRENCY:-80%}",
35-
"test:integration:ap-flows": "pnpm test:integration:base --grep @ap-flows",
35+
"test:integration:ap-flows": "E2E_DEBUG=1 pnpm test:integration:base --grep @ap-flows",
3636
"test:integration:astro": "E2E_APP_ID=astro.* pnpm test:integration:base --grep @astro",
3737
"test:integration:base": "pnpm playwright test --config integration/playwright.config.ts",
3838
"test:integration:billing": "E2E_APP_ID=withBillingJwtV2.* pnpm test:integration:base --grep @billing",

0 commit comments

Comments
 (0)