Skip to content

Commit 8afed04

Browse files
committed
test: improve test stability
1 parent 10b31ee commit 8afed04

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
@@ -48,6 +48,7 @@ import {
4848
TEST_SERVER_BASE_URL,
4949
SIGN_IN_UP_API,
5050
SOMETHING_WENT_WRONG_ERROR,
51+
LOGIN_METHODS_API,
5152
} from "../constants";
5253

5354
let connectionURI;
@@ -218,6 +219,20 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
218219
});
219220

220221
it("should postpone render with no react-router-dom", async function () {
222+
await page.setRequestInterception(true);
223+
let resolveLoginMethodsReq;
224+
const loginMethodsReqPromise = new Promise((res) => {
225+
resolveLoginMethodsReq = res;
226+
});
227+
const requestHandler = async (request) => {
228+
if (request.url().startsWith(LOGIN_METHODS_API)) {
229+
await loginMethodsReqPromise;
230+
request.continue();
231+
} else {
232+
request.continue();
233+
}
234+
};
235+
page.on("request", requestHandler);
221236
await enableDynamicLoginMethods(page, {
222237
emailPassword: { enabled: false },
223238
passwordless: { enabled: false },
@@ -230,7 +245,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
230245

231246
const spinner = await waitForSTElement(page, "[data-supertokens~=delayedRender]");
232247
assert.ok(spinner);
233-
await page.waitForTimeout(2000);
248+
resolveLoginMethodsReq();
234249
const providers = await getProvidersLabels(page);
235250
compareArrayContents(providers, ["Continue with Apple"]);
236251
});

test/helpers.js

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

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

0 commit comments

Comments
 (0)