Skip to content

Commit 05e3043

Browse files
committed
Fix mocking of signedInSessions
1 parent 7c0f9a2 commit 05e3043

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

packages/clerk-js/src/core/__tests__/clerk.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ describe('Clerk singleton', () => {
15031503
mockClientFetch.mockReturnValue(
15041504
Promise.resolve({
15051505
sessions: [mockSession],
1506-
signedInSessions: [],
1506+
signedInSessions: [mockSession],
15071507
signIn: new SignIn(null),
15081508
signUp: new SignUp({
15091509
status: 'missing_requirements',
@@ -1543,7 +1543,7 @@ describe('Clerk singleton', () => {
15431543
const mockSession = {
15441544
id: sessionId,
15451545
remove: jest.fn(),
1546-
status,
1546+
status: 'active',
15471547
user: {},
15481548
touch: jest.fn(() => Promise.resolve()),
15491549
getToken: jest.fn(),
@@ -1564,7 +1564,7 @@ describe('Clerk singleton', () => {
15641564
mockClientFetch.mockReturnValue(
15651565
Promise.resolve({
15661566
sessions: [mockSession],
1567-
signedInSessions: [],
1567+
signedInSessions: [mockSession],
15681568
signIn: new SignIn(null),
15691569
signUp: new SignUp({
15701570
status: 'missing_requirements',

packages/clerk-js/src/core/sessionTasks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export function warnMissingPendingTaskHandlers(options: Record<string, unknown>)
4949
keyof (Pick<SetActiveParams, 'navigate'> & Pick<ClerkOptions, 'taskUrls'>)
5050
>;
5151

52-
const hasAtLeastOneTaskOption = Object.keys(options).some(option => taskOptions.includes(option as any));
53-
if (hasAtLeastOneTaskOption) {
52+
const hasAtLeastOneOption = Object.keys(options).some(option => taskOptions.includes(option as any));
53+
if (hasAtLeastOneOption) {
5454
return;
5555
}
5656

5757
// TODO - Link to after-auth docs once it gets released
5858
logger.warnOnce(
59-
`Clerk: Session has pending tasks but no handling is configured. To handle pending tasks automatically, provide either "taskUrls" for navigation to custom URLs or "navigate" for programmatic navigation. Without these options, users may get stuck on incomplete flows.`,
59+
`Clerk: Session has pending tasks but no handling is configured. To handle pending tasks, provide either "taskUrls" for navigation to custom URLs or "navigate" for programmatic navigation. Without these options, users may get stuck on incomplete flows.`,
6060
);
6161
}

packages/clerk-js/src/ui/components/SessionTasks/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ export const SessionTasks = withCardStateProvider(() => {
107107
}
108108

109109
const navigateOnSetActive = async ({ session }: { session: SessionResource }) => {
110-
const currentTaskKey = session.currentTask?.key;
111-
if (!currentTaskKey) {
110+
const currentTask = session.currentTask;
111+
if (!currentTask) {
112112
return navigate(redirectUrlComplete);
113113
}
114114

115-
return navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTaskKey]}`);
115+
return navigate(`./${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
116116
};
117117

118118
return (

packages/clerk-js/src/ui/contexts/components/SignIn.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ export const useSignInContext = (): SignInContextType => {
121121
const signUpContinueUrl = buildURL({ base: signUpUrl, hashPath: '/continue' }, { stringify: true });
122122

123123
const navigateOnSetActive = async ({ session, redirectUrl }: { session: SessionResource; redirectUrl: string }) => {
124-
const currentTaskKey = session.currentTask?.key;
125-
if (!currentTaskKey) {
124+
const currentTask = session.currentTask;
125+
if (!currentTask) {
126126
return navigate(redirectUrl);
127127
}
128128

129-
return navigate(`../tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTaskKey]}`);
129+
return navigate(`../tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
130130
};
131131

132132
const taskUrl = clerk.session?.currentTask

packages/clerk-js/src/ui/contexts/components/SignUp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ export const useSignUpContext = (): SignUpContextType => {
116116
const secondFactorUrl = buildURL({ base: signInUrl, hashPath: '/factor-two' }, { stringify: true });
117117

118118
const navigateOnSetActive = async ({ session, redirectUrl }: { session: SessionResource; redirectUrl: string }) => {
119-
const currentTaskKey = session.currentTask?.key;
120-
if (!currentTaskKey) {
119+
const currentTask = session.currentTask;
120+
if (!currentTask) {
121121
return navigate(redirectUrl);
122122
}
123123

124-
return navigate(`../tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTaskKey]}`);
124+
return navigate(`../tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[currentTask.key]}`);
125125
};
126126

127127
const taskUrl = clerk.session?.currentTask

packages/types/src/clerk.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,6 @@ type ClerkOptionsNavigation =
950950
};
951951

952952
/**
953-
* A custom navigation function to be called just before the session and/or organization is set.
954953
* @inline
955954
*/
956955
export type SetActiveNavigate = ({ session }: { session: SessionResource }) => Promise<unknown>;

0 commit comments

Comments
 (0)