diff --git a/.changeset/purple-falcons-behave.md b/.changeset/purple-falcons-behave.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/purple-falcons-behave.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.changeset/silly-spies-cut.md b/.changeset/silly-spies-cut.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/silly-spies-cut.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/integration/models/longRunningApplication.ts b/integration/models/longRunningApplication.ts index 52c4ac4b6d..b7e17ced2d 100644 --- a/integration/models/longRunningApplication.ts +++ b/integration/models/longRunningApplication.ts @@ -62,6 +62,7 @@ export const longRunningApplication = (params: LongRunningApplicationParams) => try { const publishableKey = params.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'); const secretKey = params.env.privateVariables.get('CLERK_SECRET_KEY'); + const apiUrl = params.env.privateVariables.get('CLERK_API_URL'); const { instanceType, frontendApi: frontendApiUrl } = parsePublishableKey(publishableKey); if (instanceType !== 'development') { @@ -71,6 +72,8 @@ export const longRunningApplication = (params: LongRunningApplicationParams) => publishableKey, frontendApiUrl, secretKey, + // @ts-expect-error apiUrl is not a typed option for clerkSetup, but it is accepted at runtime. + apiUrl, dotenv: false, }); } diff --git a/integration/presets/envs.ts b/integration/presets/envs.ts index 8254244547..2ce9b117ee 100644 --- a/integration/presets/envs.ts +++ b/integration/presets/envs.ts @@ -144,6 +144,13 @@ const withSessionTasks = base .setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-session-tasks').pk) .setEnvVariable('private', 'CLERK_ENCRYPTION_KEY', constants.E2E_CLERK_ENCRYPTION_KEY || 'a-key'); +const withBillingStaging = base + .clone() + .setId('withBillingStaging') + .setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev') + .setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-billing-staging').sk) + .setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-billing-staging').pk); + export const envs = { base, withKeyless, @@ -165,4 +172,5 @@ export const envs = { withSignInOrUpEmailLinksFlow, withSignInOrUpwithRestrictedModeFlow, withSessionTasks, + withBillingStaging, } as const; diff --git a/integration/presets/longRunningApps.ts b/integration/presets/longRunningApps.ts index dabfbf7232..3f5a9cba35 100644 --- a/integration/presets/longRunningApps.ts +++ b/integration/presets/longRunningApps.ts @@ -42,6 +42,7 @@ export const createLongRunningApps = () => { config: next.appRouter, env: envs.withSessionTasks, }, + { id: 'next.appRouter.withBillingStaging', config: next.appRouter, env: envs.withBillingStaging }, { id: 'next.appRouter.withLegalConsent', config: next.appRouter, diff --git a/integration/tests/protect.test.ts b/integration/tests/protect.test.ts index 2d85ae3322..647ead518f 100644 --- a/integration/tests/protect.test.ts +++ b/integration/tests/protect.test.ts @@ -5,7 +5,9 @@ import { appConfigs } from '../presets'; import type { FakeOrganization, FakeUser } from '../testUtils'; import { createTestUtils, testAgainstRunningApps } from '../testUtils'; -testAgainstRunningApps({ withEnv: [appConfigs.envs.withCustomRoles] })('authorization @nextjs', ({ app }) => { +testAgainstRunningApps({ + withEnv: [appConfigs.envs.withCustomRoles, appConfigs.envs.withBillingStaging], +})('authorization @nextjs', ({ app }) => { test.describe.configure({ mode: 'serial' }); let fakeAdmin: FakeUser; @@ -40,6 +42,8 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withCustomRoles] })('authoriz await u.po.signIn.waitForMounted(); await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeAdmin.email, password: fakeAdmin.password }); await u.po.expect.toBeSignedIn(); + const jwtVersion = await page.evaluate(() => window.Clerk.session?.lastActiveToken?.jwt?.claims?.v); + expect(jwtVersion).toBe(app.env.id === 'withBillingStaging' ? 2 : undefined); await u.po.organizationSwitcher.goTo(); await u.po.organizationSwitcher.waitForMounted(); diff --git a/packages/testing/src/common/setup.ts b/packages/testing/src/common/setup.ts index 90397df525..480170e82f 100644 --- a/packages/testing/src/common/setup.ts +++ b/packages/testing/src/common/setup.ts @@ -48,7 +48,7 @@ export const fetchEnvVars = async (options?: ClerkSetupOptions): Promise