From 09251d84e3ea4be0ca5a10cfe7c404affc0ca249 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 18:19:49 +0200 Subject: [PATCH 1/8] ci: debugging tests on CI --- test/end-to-end/accountlinking.test.js | 4 ++-- ...multitenancy.dynamic_login_methods.test.js | 2 +- .../multitenancy.tenant_interactions.test.js | 2 +- .../end-to-end/thirdpartypasswordless.test.js | 24 +++++++++++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/test/end-to-end/accountlinking.test.js b/test/end-to-end/accountlinking.test.js index 9e53cf47f..0393ffdcb 100644 --- a/test/end-to-end/accountlinking.test.js +++ b/test/end-to-end/accountlinking.test.js @@ -50,7 +50,7 @@ import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, RESET_PASSW /* * Tests. */ -describe("SuperTokens Account linking", function () { +describe.only("SuperTokens Account linking", function () { let browser; let page; let consoleLogs; @@ -532,7 +532,7 @@ describe("SuperTokens Account linking", function () { assert.strictEqual(new URL(page.url()).pathname, "/auth/reset-password"); }); - it("should allow sign in w/ a verified emailpassword user in case of conflict", async function () { + it.only("should allow sign in w/ a verified emailpassword user in case of conflict", async function () { const email = `test-user+${Date.now()}@supertokens.com`; await page.evaluate(() => window.localStorage.setItem("mode", "REQUIRED")); diff --git a/test/end-to-end/multitenancy.dynamic_login_methods.test.js b/test/end-to-end/multitenancy.dynamic_login_methods.test.js index 4001ee357..9215f6ab3 100644 --- a/test/end-to-end/multitenancy.dynamic_login_methods.test.js +++ b/test/end-to-end/multitenancy.dynamic_login_methods.test.js @@ -52,7 +52,7 @@ let connectionURI; /* * Tests. */ -describe("SuperTokens Multitenancy dynamic login methods", function () { +describe.only("SuperTokens Multitenancy dynamic login methods", function () { let browser; let page; let pageCrashed; diff --git a/test/end-to-end/multitenancy.tenant_interactions.test.js b/test/end-to-end/multitenancy.tenant_interactions.test.js index 23b7351e7..4e63bf5ba 100644 --- a/test/end-to-end/multitenancy.tenant_interactions.test.js +++ b/test/end-to-end/multitenancy.tenant_interactions.test.js @@ -58,7 +58,7 @@ import { /* * Tests. */ -describe("SuperTokens Multitenancy tenant interactions", function () { +describe.only("SuperTokens Multitenancy tenant interactions", function () { let browser; let page; let pageCrashed; diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index 9474ba8ba..eabd3d88b 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -65,7 +65,7 @@ describe("SuperTokens Third Party Passwordless", function () { } }); - describe("Recipe combination tests", () => { + describe.only("Recipe combination tests", () => { before(async function () { await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { method: "POST", @@ -77,7 +77,7 @@ describe("SuperTokens Third Party Passwordless", function () { browser = await puppeteer.launch({ args: ["--no-sandbox", "--disable-setuid-sandbox"], - headless: true, + headless: false, }); page = await browser.newPage(); page.on("console", (consoleObj) => { @@ -117,42 +117,62 @@ describe("SuperTokens Third Party Passwordless", function () { it("No account consolidation", async function () { // 1. Sign up with credentials + console.log("a"); await setPasswordlessFlowType("EMAIL_OR_PHONE", "USER_INPUT_CODE"); + console.log("b"); await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo")); + console.log("c"); await Promise.all([ page.goto(`${TEST_CLIENT_BASE_URL}/auth`), page.waitForNavigation({ waitUntil: "networkidle0" }), ]); + console.log("d"); await setInputValues(page, [{ name: "emailOrPhone", value: email }]); + console.log("e"); await submitForm(page); + console.log("f"); await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]"); + console.log("g"); const loginAttemptInfo = JSON.parse( await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo")) ); + console.log("h"); const device = await getPasswordlessDevice(loginAttemptInfo); + console.log("i"); await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]); + console.log("j"); await submitForm(page); + console.log("k"); await Promise.all([page.waitForSelector(".sessionInfo-user-id"), page.waitForNetworkIdle()]); + console.log("l"); const passwordlessUserId = await getUserIdWithFetch(page); // 2. Log out + console.log("m"); const logoutButton = await getLogoutButton(page); + console.log("n"); await Promise.all([await logoutButton.click(), page.waitForNavigation({ waitUntil: "networkidle0" })]); + console.log("o"); await waitForSTElement(page, `input[name=emailOrPhone]`); // 3. Sign in with auth0 with same address. + console.log("p"); await clickOnProviderButton(page, "Auth0"); + console.log("q"); await Promise.all([ loginWithAuth0(page), page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200), ]); + console.log("r"); await Promise.all([page.waitForSelector(".sessionInfo-user-id"), page.waitForNetworkIdle()]); + console.log("s"); const thirdPartyUserId = await getUserIdWithFetch(page); + console.log(thirdPartyUserId, passwordlessUserId); // 4. Compare userIds assert.notDeepStrictEqual(thirdPartyUserId, passwordlessUserId); From 1155d7c4b257b98d2c15a4c52b29599d932df691 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 18:54:16 +0200 Subject: [PATCH 2/8] test: update message --- test/end-to-end/multitenancy.tenant_interactions.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end-to-end/multitenancy.tenant_interactions.test.js b/test/end-to-end/multitenancy.tenant_interactions.test.js index 4e63bf5ba..96c47717b 100644 --- a/test/end-to-end/multitenancy.tenant_interactions.test.js +++ b/test/end-to-end/multitenancy.tenant_interactions.test.js @@ -1094,7 +1094,7 @@ describe.only("SuperTokens Multitenancy tenant interactions", function () { { name: "confirm-password", value: newPassword }, ]); await submitForm(page); - assert.strictEqual(await getGeneralError(page), "Invalid password reset token"); + assert.strictEqual(await getGeneralError(page), "Something went wrong. Please try again."); }); }); From c149645187dfee04fbd6c52540d85b66fab13e69 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 19:13:10 +0200 Subject: [PATCH 3/8] test: remove headless false --- test/end-to-end/thirdpartypasswordless.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index eabd3d88b..f57c2a86d 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -77,7 +77,7 @@ describe("SuperTokens Third Party Passwordless", function () { browser = await puppeteer.launch({ args: ["--no-sandbox", "--disable-setuid-sandbox"], - headless: false, + headless: true, }); page = await browser.newPage(); page.on("console", (consoleObj) => { From 26346127b103a15c9d6c33550b3e2bc2437ddb36 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 19:30:18 +0200 Subject: [PATCH 4/8] test: remove only --- test/end-to-end/accountlinking.test.js | 4 ++-- test/end-to-end/multitenancy.dynamic_login_methods.test.js | 2 +- test/end-to-end/multitenancy.tenant_interactions.test.js | 2 +- test/end-to-end/thirdpartypasswordless.test.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/end-to-end/accountlinking.test.js b/test/end-to-end/accountlinking.test.js index 0393ffdcb..9e53cf47f 100644 --- a/test/end-to-end/accountlinking.test.js +++ b/test/end-to-end/accountlinking.test.js @@ -50,7 +50,7 @@ import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, RESET_PASSW /* * Tests. */ -describe.only("SuperTokens Account linking", function () { +describe("SuperTokens Account linking", function () { let browser; let page; let consoleLogs; @@ -532,7 +532,7 @@ describe.only("SuperTokens Account linking", function () { assert.strictEqual(new URL(page.url()).pathname, "/auth/reset-password"); }); - it.only("should allow sign in w/ a verified emailpassword user in case of conflict", async function () { + it("should allow sign in w/ a verified emailpassword user in case of conflict", async function () { const email = `test-user+${Date.now()}@supertokens.com`; await page.evaluate(() => window.localStorage.setItem("mode", "REQUIRED")); diff --git a/test/end-to-end/multitenancy.dynamic_login_methods.test.js b/test/end-to-end/multitenancy.dynamic_login_methods.test.js index 9215f6ab3..4001ee357 100644 --- a/test/end-to-end/multitenancy.dynamic_login_methods.test.js +++ b/test/end-to-end/multitenancy.dynamic_login_methods.test.js @@ -52,7 +52,7 @@ let connectionURI; /* * Tests. */ -describe.only("SuperTokens Multitenancy dynamic login methods", function () { +describe("SuperTokens Multitenancy dynamic login methods", function () { let browser; let page; let pageCrashed; diff --git a/test/end-to-end/multitenancy.tenant_interactions.test.js b/test/end-to-end/multitenancy.tenant_interactions.test.js index 96c47717b..3198d3be1 100644 --- a/test/end-to-end/multitenancy.tenant_interactions.test.js +++ b/test/end-to-end/multitenancy.tenant_interactions.test.js @@ -58,7 +58,7 @@ import { /* * Tests. */ -describe.only("SuperTokens Multitenancy tenant interactions", function () { +describe("SuperTokens Multitenancy tenant interactions", function () { let browser; let page; let pageCrashed; diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index f57c2a86d..ef997dc02 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -65,7 +65,7 @@ describe("SuperTokens Third Party Passwordless", function () { } }); - describe.only("Recipe combination tests", () => { + describe("Recipe combination tests", () => { before(async function () { await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { method: "POST", From 704bb3f3c93980fec19ccb332c302191422c877f Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 20:23:38 +0200 Subject: [PATCH 5/8] test: add logs --- test/end-to-end/thirdpartypasswordless.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index ef997dc02..311aab64a 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -82,6 +82,7 @@ describe("SuperTokens Third Party Passwordless", function () { page = await browser.newPage(); page.on("console", (consoleObj) => { const log = consoleObj.text(); + console.log(log); if (log.startsWith("ST_LOGS")) { consoleLogs.push(log); } From 1afddc59e9b31e20d6671f8c2119ba571c83ea71 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 21:24:11 +0200 Subject: [PATCH 6/8] test: call beforeeach on both app and test server backends in tests --- test/end-to-end/accountlinking.test.js | 5 ++-- test/end-to-end/emailverification.test.js | 17 ++++--------- test/end-to-end/embed.test.js | 6 ++--- test/end-to-end/generalerror.test.js | 13 ++++------ test/end-to-end/getRedirectionURL.test.js | 24 +++++-------------- ...multitenancy.dynamic_login_methods.test.js | 5 ++-- .../multitenancy.tenant_interactions.test.js | 5 ++-- test/end-to-end/passwordless.test.js | 8 ++----- .../resetpasswordusingtoken.test.js | 5 ++-- test/end-to-end/signin-rrdv5.test.js | 5 ++-- test/end-to-end/signin-rrdv6.test.js | 5 ++-- test/end-to-end/signin.test.js | 5 ++-- test/end-to-end/signup.test.js | 5 ++-- test/end-to-end/thirdparty.test.js | 5 ++-- .../thirdpartyemailpassword.test.js | 6 ++--- .../end-to-end/thirdpartypasswordless.test.js | 5 ++-- test/end-to-end/userContext.test.js | 5 ++-- test/end-to-end/userroles.test.js | 5 ++-- test/helpers.js | 12 ++++++++++ 19 files changed, 58 insertions(+), 88 deletions(-) diff --git a/test/end-to-end/accountlinking.test.js b/test/end-to-end/accountlinking.test.js index 9e53cf47f..f4e1140f7 100644 --- a/test/end-to-end/accountlinking.test.js +++ b/test/end-to-end/accountlinking.test.js @@ -44,6 +44,7 @@ import { getTextByDataSupertokens, sendEmailResetPasswordSuccessMessage, changeEmail, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, RESET_PASSWORD_API } from "../constants"; @@ -64,9 +65,7 @@ describe("SuperTokens Account linking", function () { describe("Recipe combination tests", () => { before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/emailverification.test.js b/test/end-to-end/emailverification.test.js index 66746fa05..94489dabd 100644 --- a/test/end-to-end/emailverification.test.js +++ b/test/end-to-end/emailverification.test.js @@ -51,6 +51,7 @@ import { isGeneralErrorSupported, setGeneralErrorToLocalStorage, isAccountLinkingSupported, + backendBeforeEach, } from "../helpers"; describe("SuperTokens Email Verification", function () { @@ -60,9 +61,7 @@ describe("SuperTokens Email Verification", function () { let accountLinkingSupported; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", }).catch(console.error); @@ -675,9 +674,7 @@ describe("SuperTokens Email Verification general errors", function () { const generalErrorMessageString = "General Error"; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", }).catch(console.error); @@ -797,9 +794,7 @@ describe("SuperTokens Email Verification isEmailVerified server error", function before(async function () { // Start server. - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -880,9 +875,7 @@ describe("Email verification signOut errors", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/embed.test.js b/test/end-to-end/embed.test.js index 5a1247146..e5a335334 100644 --- a/test/end-to-end/embed.test.js +++ b/test/end-to-end/embed.test.js @@ -5,7 +5,7 @@ import { TEST_SERVER_BASE_URL } from "../constants"; import { AuthPage } from "./pages/AuthPage"; import { EmailVerificationPage } from "./pages/EmailVerificationPage"; import { ResetPasswordPage } from "./pages/ResetPasswordPage"; -import { clearBrowserCookiesWithoutAffectingConsole, screenshotOnFailure } from "../helpers"; +import { backendBeforeEach, clearBrowserCookiesWithoutAffectingConsole, screenshotOnFailure } from "../helpers"; describe("Embed components", async () => { let browser; @@ -17,9 +17,7 @@ describe("Embed components", async () => { headless: true, }); - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", }).catch(console.error); diff --git a/test/end-to-end/generalerror.test.js b/test/end-to-end/generalerror.test.js index 31ae80548..9e0d95a6e 100644 --- a/test/end-to-end/generalerror.test.js +++ b/test/end-to-end/generalerror.test.js @@ -40,6 +40,7 @@ import { loginWithAuth0, isGeneralErrorSupported, setGeneralErrorToLocalStorage, + backendBeforeEach, } from "../helpers"; import { @@ -70,9 +71,7 @@ describe("General error rendering", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -236,9 +235,7 @@ function getEmailPasswordTests(rid, ridForStorage) { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -376,9 +373,7 @@ function getThirdPartyTests(rid, ridForStorage) { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/getRedirectionURL.test.js b/test/end-to-end/getRedirectionURL.test.js index 735fa3556..b279fd525 100644 --- a/test/end-to-end/getRedirectionURL.test.js +++ b/test/end-to-end/getRedirectionURL.test.js @@ -16,6 +16,7 @@ import { clearBrowserCookiesWithoutAffectingConsole, isPasswordlessSupported, isThirdPartyPasswordlessSupported, + backendBeforeEach, } from "../helpers"; import { @@ -31,9 +32,7 @@ describe("getRedirectionURL Tests", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -81,9 +80,7 @@ describe("getRedirectionURL Tests", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -136,9 +133,7 @@ describe("getRedirectionURL Tests", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -208,12 +203,7 @@ describe("getRedirectionURL Tests", function () { return; } - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); - await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", @@ -300,9 +290,7 @@ describe("getRedirectionURL Tests", function () { return; } - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/multitenancy.dynamic_login_methods.test.js b/test/end-to-end/multitenancy.dynamic_login_methods.test.js index 4001ee357..fc019b57c 100644 --- a/test/end-to-end/multitenancy.dynamic_login_methods.test.js +++ b/test/end-to-end/multitenancy.dynamic_login_methods.test.js @@ -38,6 +38,7 @@ import { isMultitenancySupported, isMultitenancyManagementEndpointsSupported, setupTenant, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, @@ -65,9 +66,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () { }); beforeEach(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); const startSTResp = await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/multitenancy.tenant_interactions.test.js b/test/end-to-end/multitenancy.tenant_interactions.test.js index 3198d3be1..0a30eddd2 100644 --- a/test/end-to-end/multitenancy.tenant_interactions.test.js +++ b/test/end-to-end/multitenancy.tenant_interactions.test.js @@ -45,6 +45,7 @@ import { addUserToTenant, removeUserFromTenant, removeTenant, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, @@ -71,9 +72,7 @@ describe("SuperTokens Multitenancy tenant interactions", function () { }); beforeEach(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/passwordless.test.js b/test/end-to-end/passwordless.test.js index 401542fb3..4da1e5884 100644 --- a/test/end-to-end/passwordless.test.js +++ b/test/end-to-end/passwordless.test.js @@ -36,6 +36,7 @@ import { setGeneralErrorToLocalStorage, getInputField, isAccountLinkingSupported, + backendBeforeEach, } from "../helpers"; import { @@ -2121,12 +2122,7 @@ async function setupDevice(page, inputName, contactInfo, forLinkOnly = true, cle } async function initBrowser(contactMethod, consoleLogs, authRecipe, { defaultCountry, disablePhoneGuess } = {}) { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); - await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/resetpasswordusingtoken.test.js b/test/end-to-end/resetpasswordusingtoken.test.js index 0d5b14dc1..2fa553178 100644 --- a/test/end-to-end/resetpasswordusingtoken.test.js +++ b/test/end-to-end/resetpasswordusingtoken.test.js @@ -52,6 +52,7 @@ import { getResetPasswordFormBackButton, waitForSTElement, getResetPasswordSuccessBackToSignInButton, + backendBeforeEach, } from "../helpers"; /* @@ -63,9 +64,7 @@ describe("SuperTokens Reset password", function () { let consoleLogs; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/signin-rrdv5.test.js b/test/end-to-end/signin-rrdv5.test.js index 5a5b441df..a69fb8ffb 100644 --- a/test/end-to-end/signin-rrdv5.test.js +++ b/test/end-to-end/signin-rrdv5.test.js @@ -49,6 +49,7 @@ import { screenshotOnFailure, waitForText, waitForSTElement, + backendBeforeEach, } from "../helpers"; import fetch from "isomorphic-fetch"; import { SOMETHING_WENT_WRONG_ERROR } from "../constants"; @@ -68,9 +69,7 @@ describe("SuperTokens SignIn with react router dom v5", function () { this.skip(); } - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/signin-rrdv6.test.js b/test/end-to-end/signin-rrdv6.test.js index 51c22c61f..b97df6d7e 100644 --- a/test/end-to-end/signin-rrdv6.test.js +++ b/test/end-to-end/signin-rrdv6.test.js @@ -49,6 +49,7 @@ import { screenshotOnFailure, waitForText, waitForSTElement, + backendBeforeEach, } from "../helpers"; import fetch from "isomorphic-fetch"; import { SOMETHING_WENT_WRONG_ERROR } from "../constants"; @@ -64,9 +65,7 @@ describe("SuperTokens SignIn with react router dom v6", function () { let consoleLogs = []; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/signin.test.js b/test/end-to-end/signin.test.js index e5b00ecab..86a204645 100644 --- a/test/end-to-end/signin.test.js +++ b/test/end-to-end/signin.test.js @@ -52,6 +52,7 @@ import { setGeneralErrorToLocalStorage, getInvalidClaimsJSON as getInvalidClaims, waitForText, + backendBeforeEach, } from "../helpers"; import fetch from "isomorphic-fetch"; import { SOMETHING_WENT_WRONG_ERROR } from "../constants"; @@ -67,9 +68,7 @@ describe("SuperTokens SignIn", function () { let consoleLogs = []; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/signup.test.js b/test/end-to-end/signup.test.js index 3804da90c..857bfbc42 100644 --- a/test/end-to-end/signup.test.js +++ b/test/end-to-end/signup.test.js @@ -38,6 +38,7 @@ import { screenshotOnFailure, getGeneralError, waitForSTElement, + backendBeforeEach, } from "../helpers"; import { @@ -57,9 +58,7 @@ describe("SuperTokens SignUp", function () { let consoleLogs; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/thirdparty.test.js b/test/end-to-end/thirdparty.test.js index c1d176566..226d83f94 100644 --- a/test/end-to-end/thirdparty.test.js +++ b/test/end-to-end/thirdparty.test.js @@ -31,6 +31,7 @@ import { waitFor, screenshotOnFailure, clickOnProviderButtonWithoutWaiting, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, GET_AUTH_URL_API } from "../constants"; @@ -51,9 +52,7 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa let consoleLogs = []; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/thirdpartyemailpassword.test.js b/test/end-to-end/thirdpartyemailpassword.test.js index 798908687..ed257a2b6 100644 --- a/test/end-to-end/thirdpartyemailpassword.test.js +++ b/test/end-to-end/thirdpartyemailpassword.test.js @@ -43,6 +43,7 @@ import { clickOnProviderButtonWithoutWaiting, getFeatureFlags, setEnabledRecipes, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, @@ -52,6 +53,7 @@ import { SOMETHING_WENT_WRONG_ERROR, EMAIL_EXISTS_API, GET_AUTH_URL_API, + TEST_APPLICATION_SERVER_BASE_URL, } from "../constants"; /* @@ -63,9 +65,7 @@ describe("SuperTokens Third Party Email Password", function () { let consoleLogs; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index 311aab64a..639d8eb27 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -36,6 +36,7 @@ import { setEnabledRecipes, clickOnProviderButtonWithoutWaiting, getGeneralError, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, GET_AUTH_URL_API } from "../constants"; import { getThirdPartyTestCases } from "./thirdparty.test"; @@ -67,9 +68,7 @@ describe("SuperTokens Third Party Passwordless", function () { describe("Recipe combination tests", () => { before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/userContext.test.js b/test/end-to-end/userContext.test.js index 9bd66287d..66e122a3f 100644 --- a/test/end-to-end/userContext.test.js +++ b/test/end-to-end/userContext.test.js @@ -24,6 +24,7 @@ import { assertProviders, clickOnProviderButton, loginWithAuth0, + backendBeforeEach, } from "../helpers"; import { TEST_CLIENT_BASE_URL, @@ -40,9 +41,7 @@ describe("SuperTokens userContext with UI components test", function () { let consoleLogs = []; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/end-to-end/userroles.test.js b/test/end-to-end/userroles.test.js index f4ac7b811..c75827136 100644 --- a/test/end-to-end/userroles.test.js +++ b/test/end-to-end/userroles.test.js @@ -30,6 +30,7 @@ import { getInvalidClaimsJSON as getInvalidClaims, waitFor, waitForText, + backendBeforeEach, } from "../helpers"; import { TEST_APPLICATION_SERVER_BASE_URL, TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL } from "../constants"; @@ -46,9 +47,7 @@ describe("User Roles in the frontend", function () { let browser; let page; before(async function () { - await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { - method: "POST", - }).catch(console.error); + await backendBeforeEach(); await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", diff --git a/test/helpers.js b/test/helpers.js index 8274127f6..bc7138534 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -22,6 +22,7 @@ import { SIGN_UP_API, EMAIL_EXISTS_API, TEST_CLIENT_BASE_URL, + TEST_SERVER_BASE_URL, } from "./constants"; import path from "path"; @@ -994,3 +995,14 @@ const testProviderConfigs = { ], }, }; + +export async function backendBeforeEach() { + await fetch(`${TEST_SERVER_BASE_URL}/beforeeach`, { + method: "POST", + }).catch(console.error); + if (TEST_SERVER_BASE_URL !== TEST_APPLICATION_SERVER_BASE_URL) { + await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/beforeeach`, { + method: "POST", + }).catch(console.error); + } +} From c333685f4fe7de61e01661f670f92060f2f5f41a Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 22:15:34 +0200 Subject: [PATCH 7/8] test: revert debugging changes --- .../end-to-end/thirdpartypasswordless.test.js | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/test/end-to-end/thirdpartypasswordless.test.js b/test/end-to-end/thirdpartypasswordless.test.js index 639d8eb27..cb7ac0bd2 100644 --- a/test/end-to-end/thirdpartypasswordless.test.js +++ b/test/end-to-end/thirdpartypasswordless.test.js @@ -81,7 +81,6 @@ describe("SuperTokens Third Party Passwordless", function () { page = await browser.newPage(); page.on("console", (consoleObj) => { const log = consoleObj.text(); - console.log(log); if (log.startsWith("ST_LOGS")) { consoleLogs.push(log); } @@ -117,62 +116,42 @@ describe("SuperTokens Third Party Passwordless", function () { it("No account consolidation", async function () { // 1. Sign up with credentials - console.log("a"); await setPasswordlessFlowType("EMAIL_OR_PHONE", "USER_INPUT_CODE"); - console.log("b"); await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo")); - console.log("c"); await Promise.all([ page.goto(`${TEST_CLIENT_BASE_URL}/auth`), page.waitForNavigation({ waitUntil: "networkidle0" }), ]); - console.log("d"); await setInputValues(page, [{ name: "emailOrPhone", value: email }]); - console.log("e"); await submitForm(page); - console.log("f"); await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]"); - console.log("g"); const loginAttemptInfo = JSON.parse( await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo")) ); - console.log("h"); const device = await getPasswordlessDevice(loginAttemptInfo); - console.log("i"); await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]); - console.log("j"); await submitForm(page); - console.log("k"); await Promise.all([page.waitForSelector(".sessionInfo-user-id"), page.waitForNetworkIdle()]); - console.log("l"); const passwordlessUserId = await getUserIdWithFetch(page); // 2. Log out - console.log("m"); const logoutButton = await getLogoutButton(page); - console.log("n"); await Promise.all([await logoutButton.click(), page.waitForNavigation({ waitUntil: "networkidle0" })]); - console.log("o"); await waitForSTElement(page, `input[name=emailOrPhone]`); // 3. Sign in with auth0 with same address. - console.log("p"); await clickOnProviderButton(page, "Auth0"); - console.log("q"); await Promise.all([ loginWithAuth0(page), page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200), ]); - console.log("r"); await Promise.all([page.waitForSelector(".sessionInfo-user-id"), page.waitForNetworkIdle()]); - console.log("s"); const thirdPartyUserId = await getUserIdWithFetch(page); - console.log(thirdPartyUserId, passwordlessUserId); // 4. Compare userIds assert.notDeepStrictEqual(thirdPartyUserId, passwordlessUserId); From 742bad66a87182cf9f6781c635f3ecc1eda5c9ab Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 21 Sep 2023 22:16:07 +0200 Subject: [PATCH 8/8] chore: update changelog and bump patch version --- CHANGELOG.md | 8 +++++++- lib/build/version.d.ts | 2 +- lib/ts/version.ts | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 487d4922c..7d9fc7119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] -## [0.35.0] - 2023-09-XX +## [0.35.1] - 2023-09-21 + +### Test changes + +- Test fixes for backend SDK CI + +## [0.35.0] - 2023-09-21 ### Overview diff --git a/lib/build/version.d.ts b/lib/build/version.d.ts index 1e2536ff4..7fb9cebdf 100644 --- a/lib/build/version.d.ts +++ b/lib/build/version.d.ts @@ -1 +1 @@ -export declare const package_version = "0.35.0"; +export declare const package_version = "0.35.1"; diff --git a/lib/ts/version.ts b/lib/ts/version.ts index 6da45ed4c..7c9a1c8e6 100644 --- a/lib/ts/version.ts +++ b/lib/ts/version.ts @@ -12,4 +12,4 @@ * License for the specific language governing permissions and limitations * under the License. */ -export const package_version = "0.35.0"; +export const package_version = "0.35.1"; diff --git a/package-lock.json b/package-lock.json index f09075daa..1c804b07b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "supertokens-auth-react", - "version": "0.35.0", + "version": "0.35.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "supertokens-auth-react", - "version": "0.35.0", + "version": "0.35.1", "license": "Apache-2.0", "dependencies": { "intl-tel-input": "^17.0.19", diff --git a/package.json b/package.json index c1eb63a6b..8243dd50c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "supertokens-auth-react", - "version": "0.35.0", + "version": "0.35.1", "description": "ReactJS SDK that provides login functionality with SuperTokens.", "main": "./index.js", "engines": {