Skip to content

Commit bca0f00

Browse files
committed
test(integration): verify account portal serves clerk-js v6
Why: The AP E2E tests exercise sign-in/sign-up flows against staging Core 3 but never actually assert which clerk-js version the AP serves. If Core 3 started serving the wrong major version, these tests would still pass. What changed: Added testAPClerkJsVersion helper in common.ts that navigates to the AP, waits for clerk-js to load, and checks window.Clerk.version starts with the expected major version. Called from the v6 test file with '6'.
1 parent a8c64cc commit bca0f00

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

integration/tests/next-account-portal/clerk-ap-core-3-v6.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Application } from '../../models/application';
44
import { appConfigs } from '../../presets';
55
import type { FakeUser } from '../../testUtils';
66
import { createTestUtils } from '../../testUtils';
7-
import { testHandshakeRecovery, testSignIn, testSignOut, testSignUp, testSSR } from './common';
7+
import { testAPClerkJsVersion, testHandshakeRecovery, testSignIn, testSignOut, testSignUp, testSSR } from './common';
88

99
test.describe('Next with ClerkJS V6 <-> Account Portal Core 3 @ap-flows', () => {
1010
test.describe.configure({ mode: 'serial' });
@@ -27,6 +27,10 @@ test.describe('Next with ClerkJS V6 <-> Account Portal Core 3 @ap-flows', () =>
2727
await app.teardown();
2828
});
2929

30+
test('AP serves clerk-js v6', async ({ page, context }) => {
31+
await testAPClerkJsVersion({ app, page, context, fakeUser }, '6');
32+
});
33+
3034
test('sign in', async ({ page, context }) => {
3135
await testSignIn({ app, page, context, fakeUser });
3236
});

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,26 @@ export const testSignOut = async ({ app, page, context, fakeUser }: TestParams)
226226
expect(apURL).toMatch(/\.accounts(stage\.dev|\.dev|\.stg)/);
227227
};
228228

229+
export const testAPClerkJsVersion = async ({ app, page, context }: TestParams, expectedMajorVersion: string) => {
230+
const u = createTestUtils({ app, page, context, useTestingToken: false });
231+
232+
await u.page.goToAppHome();
233+
await u.page.waitForClerkJsLoaded();
234+
await u.po.expect.toBeSignedOut();
235+
236+
// Navigate to the Account Portal
237+
await u.page.getByRole('button', { name: /Sign in/i }).click();
238+
await u.po.signIn.waitForMounted();
239+
240+
const accountPortalURL = page.url();
241+
expect(accountPortalURL).toMatch(/\.accounts(stage\.dev|\.dev|\.stg)/);
242+
243+
// Verify the clerk-js version served by the Account Portal
244+
const clerkVersion = await page.evaluate(() => window.Clerk?.version);
245+
expect(clerkVersion).toBeDefined();
246+
expect(clerkVersion).toMatch(new RegExp(`^${expectedMajorVersion}\\.`));
247+
};
248+
229249
export const testHandshakeRecovery = async ({ app, page, context, fakeUser }: TestParams) => {
230250
const u = createTestUtils({ app, page, context, useTestingToken: false });
231251

0 commit comments

Comments
 (0)