Skip to content

Commit 725918d

Browse files
authoredMar 12, 2025··
feat(clerk-js,clerk-react,types): Navigate to tasks on after sign-in/sign-up (#5280)
1 parent 150b5c8 commit 725918d

File tree

25 files changed

+733
-280
lines changed

25 files changed

+733
-280
lines changed
 

‎.changeset/brave-pears-add.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/types': minor
4+
'@clerk/clerk-react': minor
5+
---
6+
7+
Navigate to tasks on after sign-in/sign-up

‎integration/.keys.json.sample

+4
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@
4646
"with-waitlist-mode": {
4747
"pk": "",
4848
"sk": ""
49+
},
50+
"with-session-tasks": {
51+
"pk": "",
52+
"sk": ""
4953
}
5054
}

‎integration/presets/envs.ts

+8
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ const withSignInOrUpwithRestrictedModeFlow = withEmailCodes
137137
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-restricted-mode').pk)
138138
.setEnvVariable('public', 'CLERK_SIGN_UP_URL', undefined);
139139

140+
const withSessionTasks = base
141+
.clone()
142+
.setId('withSessionTasks')
143+
.setEnvVariable('private', 'CLERK_SECRET_KEY', instanceKeys.get('with-session-tasks').sk)
144+
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-session-tasks').pk)
145+
.setEnvVariable('private', 'CLERK_ENCRYPTION_KEY', constants.E2E_CLERK_ENCRYPTION_KEY || 'a-key');
146+
140147
export const envs = {
141148
base,
142149
withKeyless,
@@ -157,4 +164,5 @@ export const envs = {
157164
withSignInOrUpFlow,
158165
withSignInOrUpEmailLinksFlow,
159166
withSignInOrUpwithRestrictedModeFlow,
167+
withSessionTasks,
160168
} as const;

‎integration/presets/longRunningApps.ts

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export const createLongRunningApps = () => {
3737
config: next.appRouter,
3838
env: envs.withSignInOrUpEmailLinksFlow,
3939
},
40+
{
41+
id: 'next.appRouter.withSessionTasks',
42+
config: next.appRouter,
43+
env: envs.withSessionTasks,
44+
},
4045
{ id: 'quickstart.next.appRouter', config: next.appRouterQuickstart, env: envs.withEmailCodesQuickstart },
4146
{ id: 'elements.next.appRouter', config: elements.nextAppRouter, env: envs.withEmailCodes },
4247
{ id: 'astro.node.withCustomRoles', config: astro.node, env: envs.withCustomRoles },

‎integration/templates/next-app-router/src/app/layout.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
2424
persistClient: process.env.NEXT_PUBLIC_EXPERIMENTAL_PERSIST_CLIENT
2525
? process.env.NEXT_PUBLIC_EXPERIMENTAL_PERSIST_CLIENT === 'true'
2626
: undefined,
27+
// `experimental.withSessionTasks` will be removed soon in favor of checking via environment response
28+
withSessionTasks: true,
2729
}}
2830
>
2931
<html lang='en'>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { appConfigs } from '../presets';
4+
import type { FakeUser } from '../testUtils';
5+
import { createTestUtils, testAgainstRunningApps } from '../testUtils';
6+
7+
testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
8+
'session tasks after sign-in flow @nextjs',
9+
({ app }) => {
10+
test.describe.configure({ mode: 'serial' });
11+
12+
let fakeUser: FakeUser;
13+
14+
test.beforeAll(async () => {
15+
const u = createTestUtils({ app });
16+
fakeUser = u.services.users.createFakeUser();
17+
await u.services.users.createBapiUser(fakeUser);
18+
});
19+
20+
test.afterAll(async () => {
21+
await fakeUser.deleteIfExists();
22+
await app.teardown();
23+
});
24+
25+
test('navigate to task on after sign-in', async ({ page, context }) => {
26+
const u = createTestUtils({ app, page, context });
27+
await u.po.signIn.goTo();
28+
await u.po.signIn.setIdentifier(fakeUser.email);
29+
await u.po.signIn.continue();
30+
await u.po.signIn.setPassword(fakeUser.password);
31+
await u.po.signIn.continue();
32+
await u.po.expect.toBeSignedIn();
33+
34+
await expect(u.page.getByRole('button', { name: /create organization/i })).toBeVisible();
35+
expect(page.url()).toContain('add-organization');
36+
});
37+
},
38+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { appConfigs } from '../presets';
4+
import { createTestUtils, testAgainstRunningApps } from '../testUtils';
5+
6+
testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
7+
'session tasks after sign-up flow @nextjs',
8+
({ app }) => {
9+
test.describe.configure({ mode: 'serial' });
10+
11+
test.afterAll(async () => {
12+
await app.teardown();
13+
});
14+
15+
test('navigate to task on after sign-up', async ({ page, context }) => {
16+
const u = createTestUtils({ app, page, context });
17+
const fakeUser = u.services.users.createFakeUser({
18+
fictionalEmail: true,
19+
withPhoneNumber: true,
20+
withUsername: true,
21+
});
22+
await u.po.signUp.goTo();
23+
await u.po.signUp.signUpWithEmailAndPassword({
24+
email: fakeUser.email,
25+
password: fakeUser.password,
26+
});
27+
28+
await expect(u.page.getByRole('button', { name: /create organization/i })).toBeVisible();
29+
expect(page.url()).toContain('add-organization');
30+
31+
await fakeUser.deleteIfExists();
32+
});
33+
},
34+
);

‎packages/clerk-js/bundlewatch.config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": [
3-
{ "path": "./dist/clerk.js", "maxSize": "570kB" },
4-
{ "path": "./dist/clerk.browser.js", "maxSize": "76kB" },
3+
{ "path": "./dist/clerk.js", "maxSize": "572kB" },
4+
{ "path": "./dist/clerk.browser.js", "maxSize": "78kB" },
55
{ "path": "./dist/clerk.headless.js", "maxSize": "50KB" },
66
{ "path": "./dist/ui-common*.js", "maxSize": "92KB" },
77
{ "path": "./dist/vendors*.js", "maxSize": "26.5KB" },
@@ -12,7 +12,7 @@
1212
{ "path": "./dist/organizationswitcher*.js", "maxSize": "5KB" },
1313
{ "path": "./dist/organizationlist*.js", "maxSize": "5.5KB" },
1414
{ "path": "./dist/signin*.js", "maxSize": "12.4KB" },
15-
{ "path": "./dist/signup*.js", "maxSize": "6.4KB" },
15+
{ "path": "./dist/signup*.js", "maxSize": "6.5KB" },
1616
{ "path": "./dist/userbutton*.js", "maxSize": "5KB" },
1717
{ "path": "./dist/userprofile*.js", "maxSize": "15KB" },
1818
{ "path": "./dist/userverification*.js", "maxSize": "5KB" },

0 commit comments

Comments
 (0)
Please sign in to comment.