summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-03-12 13:55:40 +0100
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-04-28 12:53:03 +0200
commitc9d1bb4da96a977441eaf76b2113dd890db24585 (patch)
tree7f8026da9e9dbec9d2e3eeb1d81310f29c3903c4
parent00c8748779919088e3d4cf775b9c8b535ef74605 (diff)
downloadmullvadvpn-c9d1bb4da96a977441eaf76b2113dd890db24585.tar.xz
mullvadvpn-c9d1bb4da96a977441eaf76b2113dd890db24585.zip
Ensure currentRoute only executes js when window is found
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/utils.ts20
1 files changed, 13 insertions, 7 deletions
diff --git a/desktop/packages/mullvad-vpn/test/e2e/utils.ts b/desktop/packages/mullvad-vpn/test/e2e/utils.ts
index 97524f69bc..68970eca86 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/utils.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/utils.ts
@@ -8,7 +8,7 @@ export interface StartAppResponse {
}
export interface TestUtils {
- currentRoute: () => Promise<string>;
+ currentRoute: () => Promise<string | null>;
waitForNavigation: (initiateNavigation?: () => Promise<void> | void) => Promise<string>;
waitForNoTransition: () => Promise<void>;
}
@@ -45,14 +45,20 @@ export const launch = (options: LaunchOptions): Promise<ElectronApplication> =>
};
const currentRouteFactory = (app: ElectronApplication) => {
- return () =>
- app.evaluate<string>(({ webContents }) =>
- webContents
+ return () => {
+ return app.evaluate<string | null>(({ webContents }) => {
+ const electronWebContent = webContents
.getAllWebContents()
// Select window that isn't devtools
- .find((webContents) => webContents.getURL().startsWith('file://'))!
- .executeJavaScript('window.e2e.location'),
- );
+ .find((webContents) => webContents.getURL().startsWith('file://'));
+
+ if (electronWebContent) {
+ return electronWebContent.executeJavaScript('window.e2e.location');
+ }
+
+ return null;
+ });
+ };
};
const waitForNavigationFactory = (app: ElectronApplication, page: Page) => {