From 42b4120f6726c03323f7030765fdba2c441b6bea Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Mon, 11 Dec 2023 13:07:27 +0530 Subject: [PATCH] Fix unit tests --- test/unit/componentOverrides.test.tsx | 2 -- .../unit/recipe/emailpassword/emailPassword.test.tsx | 8 +++++--- test/unit/recipe/emailpassword/signInUp.test.tsx | 7 ++++++- test/unit/recipe/passwordless/passwordless.test.ts | 2 +- test/unit/recipe/passwordless/signInUp.test.tsx | 7 ++++++- test/unit/recipe/session/sessionAuth.test.tsx | 12 ++++++++++-- test/unit/recipe/thirdparty/signInUp.test.tsx | 7 ++++++- test/unit/recipe/thirdparty/thirdParty.test.ts | 2 +- .../recipe/thirdpartyemailpassword/signInUp.test.tsx | 7 ++++++- .../recipe/thirdpartypasswordless/signInUp.test.tsx | 7 ++++++- 10 files changed, 47 insertions(+), 14 deletions(-) diff --git a/test/unit/componentOverrides.test.tsx b/test/unit/componentOverrides.test.tsx index bd1e3918e..11adfbfc0 100644 --- a/test/unit/componentOverrides.test.tsx +++ b/test/unit/componentOverrides.test.tsx @@ -42,7 +42,6 @@ import { SendVerifyEmail } from "../../lib/ts/recipe/emailverification/component import { VerifyEmailLinkClicked } from "../../lib/ts/recipe/emailverification/components/themes/emailVerification/verifyEmailLinkClicked"; import { Header as ThirdPartyEmailPasswordHeader } from "../../lib/ts/recipe/thirdpartyemailpassword/components/themes/signInAndUp/header"; import { Header as ThirdPartyPasswordlessHeader } from "../../lib/ts/recipe/thirdpartypasswordless/components/themes/signInUp/header"; -import { CloseTabScreen } from "../../lib/ts/recipe/passwordless/components/themes/signInUp/closeTabScreen"; import { ComponentOverride } from "../../lib/ts/components/componentOverride/componentOverride"; import { LinkClickedScreen } from "../../lib/ts/recipe/passwordless/components/themes/linkClickedScreen"; import { LinkSent } from "../../lib/ts/recipe/passwordless/components/themes/signInUp/linkSent"; @@ -101,7 +100,6 @@ describe("Theme component overrides", () => { PasswordlessUserInputCodeFormFooter_Override: UserInputCodeFormFooter, PasswordlessUserInputCodeFormHeader_Override: UserInputCodeFormHeader, PasswordlessLinkSent_Override: LinkSent, - PasswordlessCloseTabScreen_Override: CloseTabScreen, PasswordlessLinkClickedScreen_Override: LinkClickedScreen, ThirdPartyPasswordlessHeader_Override: ThirdPartyPasswordlessHeader, }; diff --git a/test/unit/recipe/emailpassword/emailPassword.test.tsx b/test/unit/recipe/emailpassword/emailPassword.test.tsx index 3382b7c7e..f8a72f721 100644 --- a/test/unit/recipe/emailpassword/emailPassword.test.tsx +++ b/test/unit/recipe/emailpassword/emailPassword.test.tsx @@ -635,9 +635,11 @@ describe("EmailPassword", function () { }).authReact(SuperTokens.getInstanceOrThrow().appInfo, false); assert( - (await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "SUCCESS", isNewRecipeUser: false })) === - null + (await EmailPassword.getInstanceOrThrow().getRedirectUrl( + { action: "SUCCESS", isNewRecipeUser: false, isNewPrimaryUser: false }, + {} + )) === null ); - assert((await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "RESET_PASSWORD" })) === null); + assert((await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "RESET_PASSWORD" }, {})) === null); }); }); diff --git a/test/unit/recipe/emailpassword/signInUp.test.tsx b/test/unit/recipe/emailpassword/signInUp.test.tsx index f2d5d5a29..f6bc5b8ae 100644 --- a/test/unit/recipe/emailpassword/signInUp.test.tsx +++ b/test/unit/recipe/emailpassword/signInUp.test.tsx @@ -73,7 +73,12 @@ describe("EmailPassword.SignInAndUp", () => { expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith( { rid: "emailpassword", - successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined }, + successRedirectContext: { + action: "SUCCESS", + isNewRecipeUser: false, + isNewPrimaryUser: false, + redirectToPath: undefined, + }, }, {}, undefined diff --git a/test/unit/recipe/passwordless/passwordless.test.ts b/test/unit/recipe/passwordless/passwordless.test.ts index 11499b1d6..2de8a9f11 100644 --- a/test/unit/recipe/passwordless/passwordless.test.ts +++ b/test/unit/recipe/passwordless/passwordless.test.ts @@ -140,7 +140,7 @@ describe("Passwordless", function () { assert.throws(() => Passwordless.getInstanceOrThrow().config.onHandleEvent({} as any), { message: "ON HANDLE EVENTS HOOK THROWS", }); - assert.throws(() => Passwordless.getInstanceOrThrow().config.getRedirectionURL({} as any), { + assert.throws(() => Passwordless.getInstanceOrThrow().config.getRedirectionURL({} as any, {}), { message: "GET REDIRECTION HOOK THROWS", }); }); diff --git a/test/unit/recipe/passwordless/signInUp.test.tsx b/test/unit/recipe/passwordless/signInUp.test.tsx index f5cb153b5..53be0c7c8 100644 --- a/test/unit/recipe/passwordless/signInUp.test.tsx +++ b/test/unit/recipe/passwordless/signInUp.test.tsx @@ -74,7 +74,12 @@ describe("Passwordless.SingInUp", () => { expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith( { rid: "passwordless", - successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined }, + successRedirectContext: { + action: "SUCCESS", + isNewRecipeUser: false, + isNewPrimaryUser: false, + redirectToPath: undefined, + }, }, {}, undefined diff --git a/test/unit/recipe/session/sessionAuth.test.tsx b/test/unit/recipe/session/sessionAuth.test.tsx index ba23082a5..f76daa20f 100644 --- a/test/unit/recipe/session/sessionAuth.test.tsx +++ b/test/unit/recipe/session/sessionAuth.test.tsx @@ -611,7 +611,11 @@ describe("SessionAuth", () => { ]); // then - expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ redirectBack: true, history: undefined }); + expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ + redirectBack: true, + navigate: undefined, + userContext: {}, + }); }); test("not redirect on UNAUTHORISED if doRedirection=false", async () => { @@ -673,7 +677,11 @@ describe("SessionAuth", () => { // then expect(child).not.toBeInTheDocument(); - expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ redirectBack: true, history: undefined }); + expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ + redirectBack: true, + navigate: undefined, + userContext: {}, + }); }); test("not redirect on session load if doRedirection=false", async () => { diff --git a/test/unit/recipe/thirdparty/signInUp.test.tsx b/test/unit/recipe/thirdparty/signInUp.test.tsx index d3a492c74..3814af60b 100644 --- a/test/unit/recipe/thirdparty/signInUp.test.tsx +++ b/test/unit/recipe/thirdparty/signInUp.test.tsx @@ -85,7 +85,12 @@ describe("ThirdParty.SignInAndUp", () => { expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith( { rid: "thirdparty", - successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined }, + successRedirectContext: { + action: "SUCCESS", + isNewRecipeUser: false, + isNewPrimaryUser: false, + redirectToPath: undefined, + }, }, {}, undefined diff --git a/test/unit/recipe/thirdparty/thirdParty.test.ts b/test/unit/recipe/thirdparty/thirdParty.test.ts index e77f8fa4e..bdf14937d 100644 --- a/test/unit/recipe/thirdparty/thirdParty.test.ts +++ b/test/unit/recipe/thirdparty/thirdParty.test.ts @@ -363,7 +363,7 @@ describe("ThirdParty", function () { assert.throws(() => ThirdParty.getInstanceOrThrow().config.onHandleEvent({} as any), { message: "ON HANDLE EVENTS HOOK THROWS", }); - assert.throws(() => ThirdParty.getInstanceOrThrow().config.getRedirectionURL({} as any), { + assert.throws(() => ThirdParty.getInstanceOrThrow().config.getRedirectionURL({} as any, {}), { message: "GET REDIRECTION HOOK THROWS", }); }); diff --git a/test/unit/recipe/thirdpartyemailpassword/signInUp.test.tsx b/test/unit/recipe/thirdpartyemailpassword/signInUp.test.tsx index f3783cb97..b249b8562 100644 --- a/test/unit/recipe/thirdpartyemailpassword/signInUp.test.tsx +++ b/test/unit/recipe/thirdpartyemailpassword/signInUp.test.tsx @@ -73,7 +73,12 @@ describe("ThirdPartyEmailPassword.SignInAndUp", () => { expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith( { rid: "thirdpartyemailpassword", - successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined }, + successRedirectContext: { + action: "SUCCESS", + isNewRecipeUser: false, + isNewPrimaryUser: false, + redirectToPath: undefined, + }, }, {}, undefined diff --git a/test/unit/recipe/thirdpartypasswordless/signInUp.test.tsx b/test/unit/recipe/thirdpartypasswordless/signInUp.test.tsx index 807150958..6fd489232 100644 --- a/test/unit/recipe/thirdpartypasswordless/signInUp.test.tsx +++ b/test/unit/recipe/thirdpartypasswordless/signInUp.test.tsx @@ -74,7 +74,12 @@ describe("ThirdPartyPasswordless.SignInAndUp", () => { expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith( { rid: "thirdpartypasswordless", - successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined }, + successRedirectContext: { + action: "SUCCESS", + isNewRecipeUser: false, + isNewPrimaryUser: false, + redirectToPath: undefined, + }, }, {}, undefined