diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-12-15 14:16:20 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-12-15 16:05:38 +0100 |
| commit | bf02a24474f14f5d931f91c4e6816e188a236174 (patch) | |
| tree | f556e97dc6b5d09885ab27b237c135050d07b23e /gui/test | |
| parent | d96f6c1d69e25a09a561744a18dd895653e67a11 (diff) | |
| download | mullvadvpn-bf02a24474f14f5d931f91c4e6816e188a236174.tar.xz mullvadvpn-bf02a24474f14f5d931f91c4e6816e188a236174.zip | |
Add util function for asserting location switch
Diffstat (limited to 'gui/test')
| -rw-r--r-- | gui/test/e2e/utils.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gui/test/e2e/utils.ts b/gui/test/e2e/utils.ts index 118b1d0c11..083edcc676 100644 --- a/gui/test/e2e/utils.ts +++ b/gui/test/e2e/utils.ts @@ -8,6 +8,12 @@ export interface StartAppResponse { export interface TestUtils { getByTestId: (id: string) => Locator; + nextRoute: () => Promise<string>; +} + +interface History { + entries: Array<{ pathname: string }>; + index: number; } export const startApp = async ( @@ -34,11 +40,27 @@ export const startApp = async ( const util = { getByTestId: (id: string) => page.locator(`data-test-id=${id}`), + nextRoute: nextRouteFactory(app), }; return { app, page, util }; }; +export const nextRouteFactory = (app: ElectronApplication) => { + return async () => { + const nextRoute: string = await app.evaluate(({ ipcMain }) => { + return new Promise((resolve) => { + ipcMain.once('navigation-setHistory', (_event, history: History) => { + resolve(history.entries[history.index].pathname); + }); + }); + }); + + // TODO: Disable view transitions and shorten timeout or remove completely. + await new Promise((resolve) => setTimeout(resolve, 1000)); + return nextRoute; + } +}; const getStyleProperty = (locator: Locator, property: string) => { return locator.evaluate( |
