summaryrefslogtreecommitdiffhomepage
path: root/desktop
diff options
context:
space:
mode:
authorOliver <oliver@mohlin.dev>2025-07-28 15:16:19 +0200
committerDavid Lönnhager <david.l@mullvad.net>2025-07-31 13:23:05 +0200
commit8b6d3ee91ef07c8334152e191dc78f49b526dbe9 (patch)
tree5506a89d57c79480f6dfd2642c8e495c8f132aa1 /desktop
parent466d3d3e386518d0945945d78dce63bfed7326ab (diff)
downloadmullvadvpn-8b6d3ee91ef07c8334152e191dc78f49b526dbe9.tar.xz
mullvadvpn-8b6d3ee91ef07c8334152e191dc78f49b526dbe9.zip
Add helper functions to update mock settings and relays in tests
Diffstat (limited to 'desktop')
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/helpers.ts70
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/select-location.spec.ts59
2 files changed, 84 insertions, 45 deletions
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/helpers.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/helpers.ts
index d04dac2f3b..283a35b48e 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/helpers.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/select-location/helpers.ts
@@ -6,6 +6,9 @@ import {
IRelayListCity,
IRelayListCountry,
IRelayListHostname,
+ IRelayListWithEndpointData,
+ ISettings,
+ IWireguardEndpointData,
Ownership,
} from '../../../../src/shared/daemon-rpc-types';
import { RoutePath } from '../../../../src/shared/routes';
@@ -106,6 +109,70 @@ export const createHelpers = (page: Page, routes: RoutesObjectModel, utils: Mock
});
};
+ const updateMockSettings = async (
+ {
+ daita,
+ directOnly,
+ multihop,
+ }: {
+ multihop?: boolean;
+ daita?: boolean;
+ directOnly?: boolean;
+ },
+ settings?: ISettings,
+ ) => {
+ if (!settings) {
+ settings = getDefaultSettings();
+ }
+ if ('normal' in settings.relaySettings && settings.tunnelOptions.wireguard.daita) {
+ if (multihop !== undefined)
+ settings.relaySettings.normal.wireguardConstraints.useMultihop = multihop;
+ if (daita !== undefined) settings.tunnelOptions.wireguard.daita.enabled = daita;
+ if (directOnly !== undefined) settings.tunnelOptions.wireguard.daita.directOnly = directOnly;
+ }
+
+ await utils.sendMockIpcResponse<ISettings>({
+ channel: 'settings-',
+ response: settings,
+ });
+
+ return settings;
+ };
+
+ const updateEntryLocation = async (relay: LocatedRelay, settings?: ISettings) => {
+ if (!settings) {
+ settings = getDefaultSettings();
+ }
+ if ('normal' in settings.relaySettings && settings.tunnelOptions.wireguard.daita) {
+ settings.relaySettings.normal.wireguardConstraints.entryLocation = {
+ only: {
+ hostname: relay.relay.hostname,
+ country: relay.country.code,
+ city: relay.city.code,
+ },
+ };
+ }
+
+ await utils.sendMockIpcResponse<ISettings>({
+ channel: 'settings-',
+ response: settings,
+ });
+
+ return settings;
+ };
+
+ const updateMockRelays = async (relayList: IRelayList) => {
+ const wireguardEndpointData: IWireguardEndpointData = {
+ portRanges: [],
+ udp2tcpPorts: [],
+ };
+
+ await utils.sendMockIpcResponse<IRelayListWithEndpointData>({
+ channel: 'relays-',
+ response: { relayList, wireguardEndpointData },
+ });
+ };
+
return {
areAllCheckboxesChecked,
expandLocatedRelays,
@@ -116,6 +183,9 @@ export const createHelpers = (page: Page, routes: RoutesObjectModel, utils: Mock
resetProviders,
resetView,
updateMockRelayFilter,
+ updateMockSettings,
+ updateMockRelays,
+ updateEntryLocation,
};
};
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 ab4cd3736d..bf91759aae 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
@@ -3,24 +3,13 @@ import { Page } from 'playwright';
import { getDefaultSettings } from '../../../../src/main/default-settings';
import { colorTokens } from '../../../../src/renderer/lib/foundations';
-import {
- IRelayListWithEndpointData,
- ISettings,
- IWireguardEndpointData,
- ObfuscationType,
- Ownership,
-} from '../../../../src/shared/daemon-rpc-types';
+import { ISettings, ObfuscationType, Ownership } from '../../../../src/shared/daemon-rpc-types';
import { RoutePath } from '../../../../src/shared/routes';
import { RoutesObjectModel } from '../../route-object-models';
import { MockedTestUtils, startMockedApp } from '../mocked-utils';
import { createHelpers, SelectLocationHelpers } from './helpers';
import { mockData } from './mock-data';
-const wireguardEndpointData: IWireguardEndpointData = {
- portRanges: [],
- udp2tcpPorts: [],
-};
-
let page: Page;
let util: MockedTestUtils;
let routes: RoutesObjectModel;
@@ -32,14 +21,12 @@ test.describe('Select location', () => {
({ page, util } = await startMockedApp());
routes = new RoutesObjectModel(page, util);
helpers = createHelpers(page, routes, util);
+
+ await helpers.updateMockRelays(relayList);
+
await util.waitForRoute(RoutePath.main);
await page.getByLabel('Select location').click();
await util.waitForRoute(RoutePath.selectLocation);
-
- await util.sendMockIpcResponse<IRelayListWithEndpointData>({
- channel: 'relays-',
- response: { relayList, wireguardEndpointData },
- });
});
test.afterAll(async () => {
@@ -48,14 +35,8 @@ test.describe('Select location', () => {
test.describe('Multihop enabled', () => {
test.beforeAll(async () => {
- const settings = getDefaultSettings();
- if ('normal' in settings.relaySettings) {
- settings.relaySettings.normal.wireguardConstraints.useMultihop = true;
- }
-
- await util.sendMockIpcResponse<ISettings>({
- channel: 'settings-',
- response: settings,
+ await helpers.updateMockSettings({
+ multihop: true,
});
});
@@ -81,16 +62,10 @@ test.describe('Select location', () => {
});
test("App shouldn't show entry selection when daita is enabled without direct only", async () => {
- const settings = getDefaultSettings();
- if ('normal' in settings.relaySettings && settings.tunnelOptions.wireguard.daita) {
- settings.relaySettings.normal.wireguardConstraints.useMultihop = true;
- settings.tunnelOptions.wireguard.daita.enabled = true;
- settings.tunnelOptions.wireguard.daita.directOnly = false;
- }
-
- await util.sendMockIpcResponse<ISettings>({
- channel: 'settings-',
- response: settings,
+ await helpers.updateMockSettings({
+ multihop: true,
+ daita: true,
+ directOnly: false,
});
const entryButton = routes.selectLocation.getEntryButton();
@@ -101,16 +76,10 @@ test.describe('Select location', () => {
});
test('App should show entry selection when daita is enabled with direct only', async () => {
- const settings = getDefaultSettings();
- if ('normal' in settings.relaySettings && settings.tunnelOptions.wireguard.daita) {
- settings.relaySettings.normal.wireguardConstraints.useMultihop = true;
- settings.tunnelOptions.wireguard.daita.enabled = true;
- settings.tunnelOptions.wireguard.daita.directOnly = true;
- }
-
- await util.sendMockIpcResponse<ISettings>({
- channel: 'settings-',
- response: settings,
+ await helpers.updateMockSettings({
+ multihop: true,
+ daita: true,
+ directOnly: true,
});
const entryButton = routes.selectLocation.getEntryButton();