summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/helpers.ts6
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/vpn-settings.spec.ts118
2 files changed, 124 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/helpers.ts b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/helpers.ts
new file mode 100644
index 0000000000..ad9e021cc3
--- /dev/null
+++ b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/helpers.ts
@@ -0,0 +1,6 @@
+import { Page } from 'playwright';
+
+export const createSelectors = (page: Page) => ({
+ launchAppOnStartupSwitch: () => page.getByLabel('Launch app on start-up'),
+ autoConnectSwitch: () => page.getByLabel('Auto-connect'),
+});
diff --git a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/vpn-settings.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/vpn-settings.spec.ts
new file mode 100644
index 0000000000..994363ebea
--- /dev/null
+++ b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/vpn-settings.spec.ts
@@ -0,0 +1,118 @@
+import { execSync } from 'node:child_process';
+
+import { expect, test } from '@playwright/test';
+import os from 'os';
+import path from 'path';
+import { Page } from 'playwright';
+
+import { RoutePath } from '../../../../../src/renderer/lib/routes';
+import { fileExists, TestUtils } from '../../../utils';
+import { startInstalledApp } from '../../installed-utils';
+import { createSelectors } from './helpers';
+
+let page: Page;
+let util: TestUtils;
+let selectors: ReturnType<typeof createSelectors>;
+
+test.describe('VPN settings', () => {
+ const startup = async () => {
+ ({ page, util } = await startInstalledApp());
+ selectors = createSelectors(page);
+
+ await util.waitForRoute(RoutePath.main);
+
+ await page.click('button[aria-label="Settings"]');
+ await util.waitForRoute(RoutePath.settings);
+ await page.getByRole('button', { name: 'VPN settings' }).click();
+ await util.waitForRoute(RoutePath.vpnSettings);
+ };
+
+ test.beforeAll(async () => {
+ await startup();
+ });
+
+ test.afterAll(async () => {
+ await page.close();
+ });
+
+ test.describe('Launch on startup and auto-connect', () => {
+ test.afterEach(async () => {
+ const autoConnectSwitch = selectors.autoConnectSwitch();
+ if ((await autoConnectSwitch.getAttribute('aria-checked')) === 'true') {
+ await autoConnectSwitch.click();
+ }
+ await expect(autoConnectSwitch).toHaveAttribute('aria-checked', 'false');
+
+ if (process.platform === 'linux') {
+ expect(autoStartPathExists()).toBeFalsy();
+ }
+
+ const launchAppOnStartupSwitch = selectors.launchAppOnStartupSwitch();
+ if ((await launchAppOnStartupSwitch.getAttribute('aria-checked')) === 'true') {
+ await launchAppOnStartupSwitch.click();
+ }
+ await expect(launchAppOnStartupSwitch).toHaveAttribute('aria-checked', 'false');
+ });
+
+ const enableAutoConnect = async () => {
+ const autoConnectSwitch = selectors.autoConnectSwitch();
+ await expect(autoConnectSwitch).toHaveAttribute('aria-checked', 'false');
+
+ await autoConnectSwitch.click();
+ await expect(autoConnectSwitch).toHaveAttribute('aria-checked', 'true');
+ };
+
+ const enableLaunchAppOnStartup = async () => {
+ const launchAppOnStartupSwitch = selectors.launchAppOnStartupSwitch();
+ await expect(launchAppOnStartupSwitch).toHaveAttribute('aria-checked', 'false');
+
+ await launchAppOnStartupSwitch.click();
+ await expect(launchAppOnStartupSwitch).toHaveAttribute('aria-checked', 'true');
+
+ if (process.platform === 'linux') {
+ expect(autoStartPathExists()).toBeTruthy();
+ }
+ };
+
+ const getAutoStartPath = () => {
+ return path.join(os.homedir(), '.config', 'autostart', 'mullvad-vpn.desktop');
+ };
+
+ const autoStartPathExists = () => {
+ return fileExists(getAutoStartPath());
+ };
+
+ test.describe('Launch app on start-up', () => {
+ test('Should be enabled when switch is clicked', async () => {
+ await enableAutoConnect();
+
+ const cliAutoConnect = execSync('mullvad auto-connect get').toString();
+ expect(cliAutoConnect).toContain('off');
+ });
+
+ test('Should not enavble cli auto-connect when enabled alone', () => {
+ const cliAutoConnect = execSync('mullvad auto-connect get').toString();
+ expect(cliAutoConnect).toContain('off');
+ });
+ });
+
+ test.describe('Auto-connect', () => {
+ test('Should be enabled when switch is clicked', async () => {
+ await enableLaunchAppOnStartup();
+ });
+
+ test('Should not enable cli auto-connect when enabled alone', () => {
+ const cliAutoConnect = execSync('mullvad auto-connect get').toString();
+ expect(cliAutoConnect).toContain('off');
+ });
+ });
+
+ test('Should enable cli auto-connect when both launch app on start-up and auto-connect are enabled', async () => {
+ await enableLaunchAppOnStartup();
+ await enableAutoConnect();
+
+ const cliAutoConnect = execSync('mullvad auto-connect get').toString();
+ expect(cliAutoConnect).toContain('on');
+ });
+ });
+});