Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/wicked-meals-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/types': patch
---

Rename `org` session task key to `select-organization`
19 changes: 11 additions & 8 deletions packages/clerk-js/src/core/__tests__/clerk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,18 @@ describe('Clerk singleton', () => {
touch: jest.fn(() => Promise.resolve()),
getToken: jest.fn(),
lastActiveToken: { getRawString: () => 'mocked-token' },
tasks: [{ key: 'org' }],
currentTask: { key: 'org', __internal_getUrl: () => 'https://sut/tasks/add-organization' },
tasks: [{ key: 'select-organization' }],
currentTask: { key: 'select-organization', __internal_getUrl: () => 'https://sut/tasks/select-organization' },
reload: jest.fn(() =>
Promise.resolve({
id: '1',
status: 'pending',
user: {},
tasks: [{ key: 'org' }],
currentTask: { key: 'org', __internal_getUrl: () => 'https://sut/tasks/add-organization' },
tasks: [{ key: 'select-organization' }],
currentTask: {
key: 'select-organization',
__internal_getUrl: () => 'https://sut/tasks/select-organization',
},
}),
),
};
Expand Down Expand Up @@ -2337,8 +2340,8 @@ describe('Clerk singleton', () => {
id: '1',
status: 'pending',
user: {},
tasks: [{ key: 'org' }],
currentTask: { key: 'org', __internal_getUrl: () => 'https://sut/tasks/add-organization' },
tasks: [{ key: 'select-organization' }],
currentTask: { key: 'select-organization', __internal_getUrl: () => 'https://sut/tasks/select-organization' },
lastActiveToken: { getRawString: () => 'mocked-token' },
};

Expand Down Expand Up @@ -2367,15 +2370,15 @@ describe('Clerk singleton', () => {
await sut.setActive({ session: mockResource as any as PendingSessionResource });
await sut.__internal_navigateToTaskIfAvailable();

expect(mockNavigate.mock.calls[0][0]).toBe('/sign-in#/tasks/add-organization');
expect(mockNavigate.mock.calls[0][0]).toBe('/sign-in#/tasks/select-organization');
});

it('navigates to next task with custom routing from clerk options', async () => {
const sut = new Clerk(productionPublishableKey);
await sut.load({
...mockedLoadOptions,
taskUrls: {
org: '/onboarding/select-organization',
'select-organization': '/onboarding/select-organization',
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/sessionTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
import { buildURL } from '../utils';

export const INTERNAL_SESSION_TASK_ROUTE_BY_KEY: Record<SessionTask['key'], string> = {
org: 'add-organization',
'select-organization': 'select-organization',
} as const;

interface NavigateToTaskOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/components/SessionTasks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const SessionTasksStart = () => {
function SessionTaskRoutes(): JSX.Element {
return (
<Switch>
<Route path={INTERNAL_SESSION_TASK_ROUTE_BY_KEY['org']}>
<Route path={INTERNAL_SESSION_TASK_ROUTE_BY_KEY['select-organization']}>
<ForceOrganizationSelectionTask />
</Route>
<Route index>
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export interface SessionTask {
/**
* The unique identifier for the type of task that needs to be completed
*/
key: 'org';
key: 'select-organization';
}

export type GetTokenOptions = {
Expand Down