Skip to content

Commit

Permalink
test: call beforeeach on both app and test server backends in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 21, 2023
1 parent 704bb3f commit 1afddc5
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 88 deletions.
5 changes: 2 additions & 3 deletions test/end-to-end/accountlinking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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",
Expand Down
17 changes: 5 additions & 12 deletions test/end-to-end/emailverification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
isGeneralErrorSupported,
setGeneralErrorToLocalStorage,
isAccountLinkingSupported,
backendBeforeEach,
} from "../helpers";

describe("SuperTokens Email Verification", function () {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions test/end-to-end/embed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
13 changes: 4 additions & 9 deletions test/end-to-end/generalerror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
loginWithAuth0,
isGeneralErrorSupported,
setGeneralErrorToLocalStorage,
backendBeforeEach,
} from "../helpers";

import {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 6 additions & 18 deletions test/end-to-end/getRedirectionURL.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
clearBrowserCookiesWithoutAffectingConsole,
isPasswordlessSupported,
isThirdPartyPasswordlessSupported,
backendBeforeEach,
} from "../helpers";

import {
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/multitenancy.dynamic_login_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
isMultitenancySupported,
isMultitenancyManagementEndpointsSupported,
setupTenant,
backendBeforeEach,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/multitenancy.tenant_interactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
addUserToTenant,
removeUserFromTenant,
removeTenant,
backendBeforeEach,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
Expand All @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions test/end-to-end/passwordless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
setGeneralErrorToLocalStorage,
getInputField,
isAccountLinkingSupported,
backendBeforeEach,
} from "../helpers";

import {
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/resetpasswordusingtoken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
getResetPasswordFormBackButton,
waitForSTElement,
getResetPasswordSuccessBackToSignInButton,
backendBeforeEach,
} from "../helpers";

/*
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/signin-rrdv5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
screenshotOnFailure,
waitForText,
waitForSTElement,
backendBeforeEach,
} from "../helpers";
import fetch from "isomorphic-fetch";
import { SOMETHING_WENT_WRONG_ERROR } from "../constants";
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/signin-rrdv6.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
screenshotOnFailure,
waitForText,
waitForSTElement,
backendBeforeEach,
} from "../helpers";
import fetch from "isomorphic-fetch";
import { SOMETHING_WENT_WRONG_ERROR } from "../constants";
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/signin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/signup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
screenshotOnFailure,
getGeneralError,
waitForSTElement,
backendBeforeEach,
} from "../helpers";

import {
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions test/end-to-end/thirdparty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions test/end-to-end/thirdpartyemailpassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
clickOnProviderButtonWithoutWaiting,
getFeatureFlags,
setEnabledRecipes,
backendBeforeEach,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
Expand All @@ -52,6 +53,7 @@ import {
SOMETHING_WENT_WRONG_ERROR,
EMAIL_EXISTS_API,
GET_AUTH_URL_API,
TEST_APPLICATION_SERVER_BASE_URL,
} from "../constants";

/*
Expand All @@ -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",
Expand Down
Loading

0 comments on commit 1afddc5

Please sign in to comment.