Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update tests that check when the ev claim is updated #723

Merged
merged 1 commit into from
Oct 16, 2023
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
18 changes: 6 additions & 12 deletions test/accountlinking/emailverificationapis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
});

describe("isEmailVerifiedGET tests", function () {
it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and does not update session", async function () {
it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and updates session", async function () {
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
supertokens: {
Expand Down Expand Up @@ -555,12 +555,10 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.isVerified === false);

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);
});

it("calling isEmailVerifiedGET gives true for currently logged in user if email is verified, and does not update session", async function () {
it("calling isEmailVerifiedGET gives true for currently logged in user if email is verified, and updates session", async function () {
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
supertokens: {
Expand Down Expand Up @@ -643,9 +641,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.isVerified === true);

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);
});

it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and updates session if needed", async function () {
Expand Down Expand Up @@ -928,7 +924,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(userInCallback.recipeUserId.getAsString() === epUser.loginMethods[0].recipeUserId.getAsString());
});

it("calling generateEmailVerifyTokenPOST gives already verified for currently logged in user if email is verified, and does not update session", async function () {
it("calling generateEmailVerifyTokenPOST gives already verified for currently logged in user if email is verified, and updates session", async function () {
let userInCallback = undefined;
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
Expand Down Expand Up @@ -1021,9 +1017,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.status === "EMAIL_ALREADY_VERIFIED_ERROR");

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);

assert(userInCallback === undefined);
});
Expand Down
2 changes: 1 addition & 1 deletion test/emailpassword/emailverify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ describe(`emailverify: ${printPath("[test/emailpassword/emailverify.test.js]")}`
let infoFromResponse2 = extractInfoFromResponse(response);
assert.strictEqual(response.statusCode, 200);
assert.deepStrictEqual(response.body.status, "EMAIL_ALREADY_VERIFIED_ERROR");
assert.strictEqual(infoFromResponse2.frontToken, undefined);
assert.notStrictEqual(infoFromResponse2.frontToken, undefined);

// now we mark the email as unverified and try again
await EmailVerification.unverifyEmail(userId, emailId);
Expand Down