summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2023-01-02 17:34:29 +0100
committerOskar Nyberg <oskar@mullvad.net>2023-01-03 14:38:25 +0100
commitfe72f750bcf1829348d83c1e513de28bac829cd1 (patch)
treeb8da3d65ce97323ce0947cc3cc431b607574b6e8 /gui
parentbdc93d1ee708ced697eacf7f4fed2d10874c6029 (diff)
downloadmullvadvpn-fe72f750bcf1829348d83c1e513de28bac829cd1.tar.xz
mullvadvpn-fe72f750bcf1829348d83c1e513de28bac829cd1.zip
Wait for initial navigation to finish when creating test window
Diffstat (limited to 'gui')
-rw-r--r--gui/test/e2e/utils.ts27
1 files changed, 16 insertions, 11 deletions
diff --git a/gui/test/e2e/utils.ts b/gui/test/e2e/utils.ts
index b812cdd84e..9d3ff14384 100644
--- a/gui/test/e2e/utils.ts
+++ b/gui/test/e2e/utils.ts
@@ -22,6 +22,9 @@ export const startApp = async (options: LaunchOptions): Promise<StartAppResponse
const app = await launch(options);
const page = await app.firstWindow();
+ // Wait for initial navigation to finish
+ await waitForNoTransition(page);
+
page.on('pageerror', (error) => console.log(error));
page.on('console', (msg) => console.log(msg.text()));
@@ -69,22 +72,24 @@ const waitForNavigationFactory = (
// Wait for view corresponding to new route to appear
await page.getByTestId(route).isVisible();
-
- // Wait until there's only one transitionContents
- const transitionContents = page.getByTestId('transition-content');
- let transitionContentsCount;
- do {
- if (transitionContentsCount !== undefined) {
- await new Promise((resolve) => setTimeout(resolve, 5));
- }
-
- transitionContentsCount = await transitionContents.count();
- } while (transitionContentsCount !== 1);
+ await waitForNoTransition(page);
return route;
};
};
+const waitForNoTransition = async (page: Page) => {
+ // Wait until there's only one transitionContents
+ let transitionContentsCount;
+ do {
+ if (transitionContentsCount !== undefined) {
+ await new Promise((resolve) => setTimeout(resolve, 5));
+ }
+
+ transitionContentsCount = await page.getByTestId('transition-content').count();
+ } while (transitionContentsCount !== 1);
+};
+
// Returns the route when it changes
const waitForNextRoute = async (app: ElectronApplication): Promise<string> => {
return await app.evaluate(({ ipcMain }) => {