summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2023-03-24 13:58:35 +0100
committerOskar Nyberg <oskar@mullvad.net>2023-03-27 10:18:28 +0200
commit50dc0f9025b5b97539841b3c2b58c5f4c0c41909 (patch)
treed6ae2c20818a1e6deabc504c5ebc8a356fd3faaf
parent745c617d708d21c96b7fa61a219a3ded2c219643 (diff)
downloadmullvadvpn-50dc0f9025b5b97539841b3c2b58c5f4c0c41909.tar.xz
mullvadvpn-50dc0f9025b5b97539841b3c2b58c5f4c0c41909.zip
Add test that logs in to provided account
-rw-r--r--gui/test/e2e/installed/state-dependent/login.spec.ts39
1 files changed, 35 insertions, 4 deletions
diff --git a/gui/test/e2e/installed/state-dependent/login.spec.ts b/gui/test/e2e/installed/state-dependent/login.spec.ts
index 4cb83f8f27..4a4edeadf8 100644
--- a/gui/test/e2e/installed/state-dependent/login.spec.ts
+++ b/gui/test/e2e/installed/state-dependent/login.spec.ts
@@ -1,12 +1,15 @@
-import { exec } from 'child_process';
+import { exec, execSync } from 'child_process';
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';
+import { assertDisconnected } from '../../shared/tunnel-state';
// This test expects the daemon to be logged out.
+// Env parameters:
+// `ACCOUNT_NUMBER`: Account number to use when logging in
let page: Page;
let util: TestUtils;
@@ -81,7 +84,7 @@ test('App should log in', async () => {
await expect(title).toHaveText('Login');
await expect(subtitle).toHaveText('Enter your account number');
- await loginInput.type(accountNumber);
+ await loginInput.type(process.env.ACCOUNT_NUMBER!);
await loginInput.press('Enter');
await expect(title).toHaveText('Logging in...');
@@ -91,8 +94,10 @@ test('App should log in', async () => {
expect(await util.waitForNavigation()).toEqual(RoutePath.main);
- const outOfTimeTitle = page.getByTestId('title');
- await expect(outOfTimeTitle).toHaveText('Out of time');
+ // Prevent the connect-button from being hovered, and therefore not have the correct color.
+ await page.hover('div');
+
+ await assertDisconnected(page);
});
test('App should log out', async () => {
@@ -114,6 +119,32 @@ test('App should log out', async () => {
await expect(subtitle).toHaveText('Enter your account number');
});
+test('App should log in to expired account', async () => {
+ expect(await util.currentRoute()).toEqual(RoutePath.login);
+
+ const title = page.locator('h1')
+ const subtitle = page.getByTestId('subtitle');
+ const loginInput = getInput(page);
+
+ await expect(title).toHaveText('Login');
+ await expect(subtitle).toHaveText('Enter your account number');
+
+ await loginInput.type(accountNumber);
+ await loginInput.press('Enter');
+
+ await expect(title).toHaveText('Logging in...');
+ await expect(subtitle).toHaveText('Checking account number');
+ await expect(title).toHaveText('Logged in');
+ await expect(subtitle).toHaveText('Valid account number');
+
+ expect(await util.waitForNavigation()).toEqual(RoutePath.main);
+
+ const outOfTimeTitle = page.getByTestId('title');
+ await expect(outOfTimeTitle).toHaveText('Out of time');
+
+ execSync('mullvad account logout');
+});
+
function getInput(page: Page): Locator {
return page.getByPlaceholder('0000 0000 0000 0000');
}