summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2025-10-06 16:50:51 +0200
committerOskar <oskar@mullvad.net>2025-10-06 16:50:51 +0200
commit4ff9c94d43ae35dfe54017eac9de9be749d7ad0d (patch)
treed2140246b748e4342e72595e8d5f6226e06647fd
parent7dab6e5e945c273c182591a7bfe4a1f48ec9c509 (diff)
parent7546b93617524bfe55fcc31cab7d137879f32870 (diff)
downloadmullvadvpn-4ff9c94d43ae35dfe54017eac9de9be749d7ad0d.tar.xz
mullvadvpn-4ff9c94d43ae35dfe54017eac9de9be749d7ad0d.zip
Merge branch 'speed-up-and-improve-mocked-tests'
-rw-r--r--.github/workflows/git-commit-message-style.yml2
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/account-expiry.spec.ts1
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/expired-account-error-view.spec.ts42
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts8
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/login.spec.ts10
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts11
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/too-many-devices.spec.ts13
7 files changed, 36 insertions, 51 deletions
diff --git a/.github/workflows/git-commit-message-style.yml b/.github/workflows/git-commit-message-style.yml
index 3b3142a4e0..9176fc70c5 100644
--- a/.github/workflows/git-commit-message-style.yml
+++ b/.github/workflows/git-commit-message-style.yml
@@ -35,4 +35,4 @@ jobs:
max-subject-line-length: '72'
# The action's wordlist is a bit short. Add more accepted verbs
additional-verbs: 'tidy, wrap, obfuscate, bias, prohibit, forbid, revert, slim, impl, disregard, reproduce,
- signal, guarantee, cap'
+ signal, guarantee, cap, parallelize'
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/account-expiry.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/account-expiry.spec.ts
index bd8f7b0317..a1907f4cf7 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/account-expiry.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/account-expiry.spec.ts
@@ -162,6 +162,7 @@ test.describe('Account expiry', () => {
},
},
});
+ await page.clock.fastForward(1000);
await routes.expired.waitForRoute();
});
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/expired-account-error-view.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/expired-account-error-view.spec.ts
deleted file mode 100644
index 2135a11de3..0000000000
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/expired-account-error-view.spec.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { Page } from 'playwright';
-
-import { colorTokens } from '../../../src/renderer/lib/foundations';
-import { RoutePath } from '../../../src/shared/routes';
-import { getBackgroundColor } from '../utils';
-import { MockedTestUtils, startMockedApp } from './mocked-utils';
-
-let page: Page;
-let util: MockedTestUtils;
-
-test.beforeEach(async () => {
- ({ page, util } = await startMockedApp());
- await util.expectRoute(RoutePath.main);
-});
-
-test.afterEach(async () => {
- await page.close();
-});
-
-test('App should show Expired Account Error View', async () => {
- await util.ipc.account[''].notify({
- expiry: new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString(),
- });
-
- await expect(page.locator('text=Out of time')).toBeVisible();
- const buyMoreButton = page.locator('button:has-text("Buy more credit")');
- await expect(buyMoreButton).toBeVisible();
- expect(await getBackgroundColor(buyMoreButton)).toBe(colorTokens.green);
-
- const redeemVoucherButton = page.locator('button:has-text("Redeem voucher")');
- await expect(redeemVoucherButton).toBeVisible();
- expect(await getBackgroundColor(redeemVoucherButton)).toBe(colorTokens.green);
-});
-
-test('App should show out of time view after running out of time', async () => {
- const expiryDate = new Date();
- expiryDate.setSeconds(expiryDate.getSeconds() + 2);
-
- await util.ipc.account[''].notify({ expiry: expiryDate.toISOString() });
- await util.expectRoute(RoutePath.expired);
-});
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
index b7786a983f..50da2e5c6a 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
@@ -17,6 +17,7 @@ type FeatureIndicatorTestOption = {
featureIndicator: FeatureIndicator;
featureIndicatorLabel: string;
route: RoutePath;
+ skip?: boolean;
};
type FeatureIndicatorWithOptionTestOption = FeatureIndicatorTestOption & {
@@ -38,6 +39,7 @@ const featureIndicatorWithoutOption: FeatureIndicatorTestOption[] = [
featureIndicator: FeatureIndicator.splitTunneling,
route: RoutePath.splitTunneling,
featureIndicatorLabel: 'Split tunneling',
+ skip: process.platform === 'linux',
},
{
testId: 'server ip override',
@@ -249,8 +251,12 @@ test.describe('Feature indicators', () => {
};
featureIndicatorWithoutOption.forEach(
- ({ testId, featureIndicator, route, featureIndicatorLabel }) => {
+ ({ testId, featureIndicator, route, featureIndicatorLabel, skip }) => {
test(`Should navigate to setting when clicking on ${testId} feature indicator`, async () => {
+ if (skip === true) {
+ test.skip();
+ }
+
await helpers.connectWithFeatures([featureIndicator]);
await clickFeatureIndicator(featureIndicatorLabel, route);
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/login.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/login.spec.ts
index 1cffac8759..99e7f37721 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/login.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/login.spec.ts
@@ -4,6 +4,12 @@ import { Page } from 'playwright';
import { RoutesObjectModel } from '../route-object-models';
import { MockedTestUtils, startMockedApp } from './mocked-utils';
+const START_DATE = new Date('2025-01-01T13:37:00');
+
+const NON_EXPIRED_EXPIRY = {
+ expiry: new Date(START_DATE.getTime() + 60 * 60 * 1000).toISOString(),
+};
+
let page: Page;
let util: MockedTestUtils;
let routes: RoutesObjectModel;
@@ -31,6 +37,7 @@ test.describe('Login view', () => {
});
test.beforeEach(async () => {
+ await page.clock.install({ time: START_DATE });
await logout();
});
@@ -54,9 +61,10 @@ test.describe('Login view', () => {
type: 'logged in',
deviceState: { type: 'logged in', accountAndDevice: { accountNumber: '1234123412341234' } },
});
- await util.ipc.account[''].notify({ expiry: new Date(Date.now() + 60 * 1000).toISOString() });
+ await util.ipc.account[''].notify(NON_EXPIRED_EXPIRY);
await expect(header).toHaveText('Logged in');
+ await page.clock.fastForward(1000);
await routes.main.waitForRoute();
});
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts
index 3826d9e27e..39e9eb7743 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts
@@ -17,12 +17,17 @@ let util: MockedTestUtils;
let routes: RoutesObjectModel;
let helpers: SelectLocationHelpers;
+test.describe.configure({ mode: 'parallel' });
+
test.describe('Select location', () => {
test.beforeAll(async () => {
({ page, util } = await startMockedApp());
routes = new RoutesObjectModel(page, util);
helpers = createHelpers(page, routes, util);
+ await util.ipc.tunnel.connect.ignore();
+ await util.ipc.settings.setRelaySettings.ignore();
+
await util.expectRoute(RoutePath.main);
});
@@ -130,9 +135,6 @@ test.describe('Select location', () => {
});
test('Should disable entry server in exit list', async () => {
- await util.ipc.tunnel.connect.ignore();
- await util.ipc.settings.setRelaySettings.ignore();
-
const settings = await helpers.updateMockSettings({
multihop: true,
daita: true,
@@ -303,8 +305,7 @@ test.describe('Select location', () => {
// Expect all filtered relays to have a button
await expect(buttons).toHaveCount(relays.length);
});
- });
- test.describe('Filter by LWO', () => {
+
test('Should apply filter when LWO obfuscation is selected', async () => {
const settings = getDefaultSettings();
if ('normal' in settings.relaySettings) {
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/too-many-devices.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/too-many-devices.spec.ts
index 76e3fddee3..9672f13bf3 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/too-many-devices.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/too-many-devices.spec.ts
@@ -8,6 +8,12 @@ let page: Page;
let util: MockedTestUtils;
let routes: RoutesObjectModel;
+const START_DATE = new Date('2025-01-01T13:37:00');
+
+const NON_EXPIRED_EXPIRY = {
+ expiry: new Date(START_DATE.getTime() + 60 * 60 * 1000).toISOString(),
+};
+
test.describe('Too many devices', () => {
test.beforeAll(async () => {
({ page, util } = await startMockedApp());
@@ -22,6 +28,10 @@ test.describe('Too many devices', () => {
await routes.login.waitForRoute();
});
+ test.beforeEach(async () => {
+ await page.clock.install({ time: START_DATE });
+ });
+
test.afterAll(async () => {
await page.close();
});
@@ -60,7 +70,8 @@ test.describe('Too many devices', () => {
type: 'logged in',
deviceState: { type: 'logged in', accountAndDevice: { accountNumber: '1234123412341234' } },
});
- await util.ipc.account[''].notify({ expiry: new Date(Date.now() + 60 * 1000).toISOString() });
+ await util.ipc.account[''].notify(NON_EXPIRED_EXPIRY);
+ await page.clock.fastForward(1000);
await routes.main.waitForRoute();
});