Skip to content

Commit

Permalink
test: more test stability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed May 28, 2024
1 parent a410d35 commit 96060d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
40 changes: 14 additions & 26 deletions test/end-to-end/passwordless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
getInputField,
isAccountLinkingSupported,
backendBeforeEach,
waitForUrl,
} from "../helpers";

import {
Expand Down Expand Up @@ -693,8 +694,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe

await page.waitForNavigation({ waitUntil: "networkidle0" });

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/redirect-here");
await waitForUrl(page, "/redirect-here");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand Down Expand Up @@ -1250,8 +1250,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await page.goto(device.codes[0].urlWithLinkCode);
await page.waitForNavigation({ waitUntil: "networkidle0" });

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/redirect-here");
await waitForUrl(page, "/redirect-here");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand Down Expand Up @@ -1294,8 +1293,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await page.goto(device.codes[0].urlWithLinkCode);
await page.waitForNavigation({ waitUntil: "networkidle0" });

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/redirect-here");
await waitForUrl(page, "/redirect-here");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand Down Expand Up @@ -1416,8 +1414,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe

// We have been redirected to linkSent
await waitForSTElement(page, "[data-supertokens~=sendCodeIcon]");
const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");

const error = await waitForSTElement(page, "[data-supertokens~='generalError']");
assert.strictEqual(await error.evaluate((e) => e.textContent), "general error from API consume code");
Expand Down Expand Up @@ -1452,8 +1449,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe

// We have been redirected to linkSent
await waitForSTElement(page, "[data-supertokens~=sendCodeIcon]");
const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");

const error = await waitForSTElement(page, "[data-supertokens~='generalError']");
assert.strictEqual(await error.evaluate((e) => e.textContent), SOMETHING_WENT_WRONG_ERROR);
Expand All @@ -1468,8 +1464,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand All @@ -1487,8 +1482,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
const btn = await waitForSTElement(page, "[data-supertokens='button']");
await btn.click();
await waitForSTElement(page, "[data-supertokens='generalError']");
const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand All @@ -1514,8 +1508,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await btn.click();
await waitForSTElement(page, "[data-supertokens='generalError']");

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand All @@ -1541,8 +1534,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await btn.click();
await waitForSTElement(page, "[data-supertokens='generalError']");

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand All @@ -1564,8 +1556,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand All @@ -1583,8 +1574,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");
assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
Expand Down Expand Up @@ -1756,8 +1746,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await submitForm(page);

await page.waitForNavigation({ waitUntil: "networkidle0" });
const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/redirect-here");
await waitForUrl(page, "/redirect-here");

assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
Expand Down Expand Up @@ -1856,8 +1845,7 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe
await btn.click();
await waitForSTElement(page, "[data-supertokens='generalError']");

const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/auth/");
await waitForUrl(page, "/auth/");

assert.deepStrictEqual(
[
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/thirdpartypasswordless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
clickOnProviderButtonWithoutWaiting,
getGeneralError,
backendBeforeEach,
waitForUrl,
} 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";
Expand Down Expand Up @@ -177,8 +178,7 @@ describe("SuperTokens Third Party Passwordless", function () {
await submitForm(page);

await Promise.all([page.waitForSelector(".sessionInfo-user-id"), page.waitForNetworkIdle()]);
const pathname = await page.evaluate(() => window.location.pathname);
assert.deepStrictEqual(pathname, "/dashboard");
await waitForUrl(page, "/dashboard");

assert.deepStrictEqual(consoleLogs, [
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
Expand Down

0 comments on commit 96060d3

Please sign in to comment.