Skip to content

Commit

Permalink
test: stability fixes for python e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Nov 27, 2024
1 parent f5b53b5 commit e57a7e5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export async function getProviderLogoCount(page) {
}

export async function getSubmitFormButtonLabelWithoutShadowDom(page) {
await page.waitForSelector("form > div > button");
return await page.evaluate(() => document.querySelector("form > div > button").innerText);
}

Expand Down Expand Up @@ -557,10 +558,22 @@ async function assertValidator(actualValidate, expectedValidate, values) {
}

export async function getLatestURLWithToken() {
const response = await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/token`);
const { latestURLWithToken } = await response.json();
let latestURLWithToken;
const start = Date.now();
while (latestURLWithToken === undefined) {
const response = await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/token`);
const respBody = await response.json();
latestURLWithToken = respBody.latestURLWithToken;
if (latestURLWithToken === undefined) {
if (Date.now() - start > 10000) {
throw new Error("Timeout waiting for latestURLWithToken");
}
await new Promise((res) => setTimeout(res, 250));
}
}
return latestURLWithToken;
}

export async function assertProviders(page) {
const providers = await getProvidersLabels(page);
assert.deepStrictEqual(providers, [
Expand Down Expand Up @@ -726,12 +739,14 @@ export async function generateState(state, page) {
}

export async function getUserIdWithAxios(page) {
await page.waitForSelector("#root > div > div.fill > div > div.axios > ul > li.sessionInfo-user-id");
return await page.evaluate(
() => document.querySelector("#root > div > div.fill > div > div.axios > ul > li.sessionInfo-user-id").innerText
);
}

export async function getSessionHandleWithAxios(page) {
await page.waitForSelector("#root > div > div.fill > div > div.axios > ul > li.sessionInfo-session-handle");
return await page.evaluate(
() =>
document.querySelector("#root > div > div.fill > div > div.axios > ul > li.sessionInfo-session-handle")
Expand Down Expand Up @@ -762,12 +777,14 @@ export async function getInvalidClaimsJSON(page) {
}

export async function getUserIdFromSessionContext(page) {
await page.waitForSelector("#root > div > div.fill > div > div.session-context-userId");
return await page.evaluate(
() => document.querySelector("#root > div > div.fill > div > div.session-context-userId").innerText
);
}

export async function getTextInDashboardNoAuth(page) {
await page.waitForSelector("#root > div > div.fill > div.not-logged-in");
return await page.evaluate(() => document.querySelector("#root > div > div.fill > div.not-logged-in").innerText);
}

Expand Down

0 comments on commit e57a7e5

Please sign in to comment.