From e57a7e5bb8ece71c8ed1db48cb1bc5d6fd675fe9 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Wed, 27 Nov 2024 16:42:30 +0100 Subject: [PATCH] test: stability fixes for python e2e tests --- test/helpers.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/helpers.js b/test/helpers.js index 2473c15a1..fdea5d1ee 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -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); } @@ -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, [ @@ -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") @@ -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); }