diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2023-04-18 15:24:20 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-04-19 11:02:59 +0200 |
| commit | e547ed425587daf26f745dc8d91bdde9643c8462 (patch) | |
| tree | c5805bd1b4932227154dcb6bdaf0c04c3cb137e9 /gui/test | |
| parent | 1c0fa05e4cf507084f79cf66e21aec913747c3d2 (diff) | |
| download | mullvadvpn-e547ed425587daf26f745dc8d91bdde9643c8462.tar.xz mullvadvpn-e547ed425587daf26f745dc8d91bdde9643c8462.zip | |
Add test for too many devices flow
Diffstat (limited to 'gui/test')
| -rw-r--r-- | gui/test/e2e/installed/state-dependent/too-many-devices.spec.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gui/test/e2e/installed/state-dependent/too-many-devices.spec.ts b/gui/test/e2e/installed/state-dependent/too-many-devices.spec.ts new file mode 100644 index 0000000000..6da1993777 --- /dev/null +++ b/gui/test/e2e/installed/state-dependent/too-many-devices.spec.ts @@ -0,0 +1,51 @@ +import { expect, test } from '@playwright/test'; +import { Locator, Page } from 'playwright'; +import { RoutePath } from '../../../../src/renderer/lib/routes'; +import { TestUtils } from '../../utils'; + +import { startInstalledApp } from '../installed-utils'; + +// This test expects the daemon to be logged out and the provided account to have five registered +// devices.. +// Env parameters: +// `ACCOUNT_NUMBER`: Account number to use when logging in + +let page: Page; +let util: TestUtils; + +test.beforeAll(async () => { + ({ page, util } = await startInstalledApp()); +}); + +test.afterAll(async () => { + await page.close(); +}); + +test('App should show too many devices', async () => { + expect(await util.currentRoute()).toEqual(RoutePath.login); + + const loginInput = getInput(page); + await loginInput.type(process.env.ACCOUNT_NUMBER!); + + expect(await util.waitForNavigation(() => { + loginInput.press('Enter'); + })).toEqual(RoutePath.tooManyDevices); + + const loginButton = page.getByText('Continue with login'); + + await expect(page.getByTestId('title')).toHaveText('Too many devices'); + await expect(loginButton).toBeDisabled(); + await page.getByLabel(/^Remove device named/).first().click(); + await page.getByText('Yes, log out device').click(); + + await expect(loginButton).toBeEnabled(); + + expect(await util.waitForNavigation(() => { + loginButton.click(); + })).toEqual(RoutePath.login); + expect(await util.waitForNavigation()).toEqual(RoutePath.main); +}); + +function getInput(page: Page): Locator { + return page.getByPlaceholder('0000 0000 0000 0000'); +} |
