Skip to content

Commit 0f7f223

Browse files
committed
test: improve test stability
1 parent 03ebc1b commit 0f7f223

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

test/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const SEND_VERIFY_EMAIL_API = `${TEST_APPLICATION_SERVER_BASE_URL}/auth/u
3333
export const VERIFY_EMAIL_API = `${TEST_APPLICATION_SERVER_BASE_URL}/auth/user/email/verify`;
3434
export const SIGN_IN_UP_API = `${TEST_APPLICATION_SERVER_BASE_URL}/auth/signinup`;
3535
export const GET_AUTH_URL_API = `${TEST_APPLICATION_SERVER_BASE_URL}/auth/authorisationurl`;
36+
export const LOGIN_METHODS_API = `${TEST_APPLICATION_SERVER_BASE_URL}/auth/loginmethods`;
3637
export const ST_ROOT_SELECTOR = `#${ST_ROOT_ID}`;
3738

3839
export const SOMETHING_WENT_WRONG_ERROR = "Something went wrong. Please try again.";

test/end-to-end/multitenancy.dynamic_login_methods.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
TEST_SERVER_BASE_URL,
4848
SIGN_IN_UP_API,
4949
SOMETHING_WENT_WRONG_ERROR,
50+
LOGIN_METHODS_API,
5051
} from "../constants";
5152

5253
// Run the tests in a DOM environment.
@@ -211,6 +212,20 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
211212
});
212213

213214
it("should postpone render with no react-router-dom", async function () {
215+
await page.setRequestInterception(true);
216+
let resolveLoginMethodsReq;
217+
const loginMethodsReqPromise = new Promise((res) => {
218+
resolveLoginMethodsReq = res;
219+
});
220+
const requestHandler = async (request) => {
221+
if (request.url().startsWith(LOGIN_METHODS_API)) {
222+
await loginMethodsReqPromise;
223+
request.continue();
224+
} else {
225+
request.continue();
226+
}
227+
};
228+
page.on("request", requestHandler);
214229
await enableDynamicLoginMethods(page, {
215230
emailPassword: { enabled: false },
216231
passwordless: { enabled: false },
@@ -223,7 +238,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
223238

224239
const spinner = await waitForSTElement(page, "[data-supertokens~=delayedRender]");
225240
assert.ok(spinner);
226-
await page.waitForTimeout(2000);
241+
resolveLoginMethodsReq();
227242
const providers = await getProvidersLabels(page);
228243
compareArrayContents(providers, ["Continue with Apple"]);
229244
});

test/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export async function getSubmitFormButtonLabel(page) {
119119
}
120120

121121
export async function getProvidersLabels(page) {
122-
await waitForSTElement(page);
122+
await waitForSTElement(page, "[data-supertokens~=headerTitle]");
123123
return await page.evaluate(
124124
({ ST_ROOT_SELECTOR }) =>
125125
Array.from(

0 commit comments

Comments
 (0)