From ab68ddecfab7508b41d23272b9bc623456c92f1a Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 11 Jul 2024 17:46:14 +0200 Subject: [PATCH] test: improve test stability on slower backends --- test/cross.auto_refresh.test.js | 1 + test/cross.basic_jwt.test.js | 1 + test/cross.cross_domain.test.js | 1 + test/cross.disable_interception.test.js | 1 + test/cross.resp_error.test.js | 1 + test/cross.token_migration.test.js | 1 + test/cross.unauthorised_event.test.js | 1 + test/interception.basic1.test.js | 4 +++- 8 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/cross.auto_refresh.test.js b/test/cross.auto_refresh.test.js index 65001c8d..95433d0b 100644 --- a/test/cross.auto_refresh.test.js +++ b/test/cross.auto_refresh.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.basic_jwt.test.js b/test/cross.basic_jwt.test.js index 49224513..9b984cb2 100644 --- a/test/cross.basic_jwt.test.js +++ b/test/cross.basic_jwt.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.cross_domain.test.js b/test/cross.cross_domain.test.js index 59b26787..558e1b39 100644 --- a/test/cross.cross_domain.test.js +++ b/test/cross.cross_domain.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.disable_interception.test.js b/test/cross.disable_interception.test.js index 9cbb8b33..85ff9220 100644 --- a/test/cross.disable_interception.test.js +++ b/test/cross.disable_interception.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.resp_error.test.js b/test/cross.resp_error.test.js index a32355c5..afb0d662 100644 --- a/test/cross.resp_error.test.js +++ b/test/cross.resp_error.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.token_migration.test.js b/test/cross.token_migration.test.js index 14f24772..cb5f0af8 100644 --- a/test/cross.token_migration.test.js +++ b/test/cross.token_migration.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/cross.unauthorised_event.test.js b/test/cross.unauthorised_event.test.js index f04a6ce4..b52e6ec2 100644 --- a/test/cross.unauthorised_event.test.js +++ b/test/cross.unauthorised_event.test.js @@ -107,6 +107,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } diff --git a/test/interception.basic1.test.js b/test/interception.basic1.test.js index 587d122a..4ec4a1ce 100644 --- a/test/interception.basic1.test.js +++ b/test/interception.basic1.test.js @@ -123,6 +123,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); + await page.waitForFunction(() => window.supertokens !== undefined); await new Promise(r => setTimeout(r, 100)); } catch {} } @@ -218,7 +219,8 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => { await page.goto(BASE_URL + "/index.html", { waitUntil: "load" }); await page.addScriptTag({ path: `./bundle/bundle.js`, type: "text/javascript" }); await page.evaluate(BASE_URL => (window.BASE_URL = BASE_URL), BASE_URL); - await new Promise(r => setTimeout(r, 100)); + await page.waitForFunction(() => window.supertokens !== undefined); + await new Promise(r => setTimeout(r, 250)); await setup({ isInIframe: true