summaryrefslogtreecommitdiffhomepage
path: root/gui/test
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2024-10-10 10:35:47 +0200
committerDavid Lönnhager <david.l@mullvad.net>2024-10-18 12:04:46 +0200
commit95c0f9b0392802ee64a7c8a0f42ac0da3f94bed4 (patch)
treef74d2deaae399afe99c1054b878096963777d4bb /gui/test
parent1c209ec4d2c869c220f40f0aac04dfd363883678 (diff)
downloadmullvadvpn-95c0f9b0392802ee64a7c8a0f42ac0da3f94bed4.tar.xz
mullvadvpn-95c0f9b0392802ee64a7c8a0f42ac0da3f94bed4.zip
Fix linter errors
Diffstat (limited to 'gui/test')
-rw-r--r--gui/test/e2e/installed/state-dependent/settings.spec.ts31
-rw-r--r--gui/test/e2e/utils.ts5
2 files changed, 19 insertions, 17 deletions
diff --git a/gui/test/e2e/installed/state-dependent/settings.spec.ts b/gui/test/e2e/installed/state-dependent/settings.spec.ts
index 4575594803..343d0fc430 100644
--- a/gui/test/e2e/installed/state-dependent/settings.spec.ts
+++ b/gui/test/e2e/installed/state-dependent/settings.spec.ts
@@ -1,9 +1,10 @@
-import path from 'path';
-import os from 'os';
-import { execSync } from 'child_process';
import { expect, Page, test } from '@playwright/test';
-import { startInstalledApp } from '../installed-utils';
+import { execSync } from 'child_process';
+import os from 'os';
+import path from 'path';
+
import { fileExists, TestUtils } from '../../utils';
+import { startInstalledApp } from '../installed-utils';
function getAutoStartPath() {
return path.join(os.homedir(), '.config', 'autostart', 'mullvad-vpn.desktop');
@@ -27,8 +28,8 @@ test.afterAll(async () => {
test.describe('VPN Settings', () => {
test('Auto-connect setting', async () => {
// Navigate to the VPN settings view
- await util.waitForNavigation(async () => await page.click('button[aria-label="Settings"]'));
- await util.waitForNavigation(async () => await page.click('text=VPN settings'));
+ await util.waitForNavigation(() => page.click('button[aria-label="Settings"]'));
+ await util.waitForNavigation(() => page.click('text=VPN settings'));
// Find the auto-connect toggle
const autoConnectToggle = page.getByText('Auto-connect').locator('..').getByRole('checkbox');
@@ -36,26 +37,28 @@ test.describe('VPN Settings', () => {
// Check initial state
const initialCliState = execSync('mullvad auto-connect get').toString().trim();
expect(initialCliState).toMatch(/off$/);
- await expect(autoConnectToggle).toHaveAttribute('aria-checked', 'false')
+ await expect(autoConnectToggle).toHaveAttribute('aria-checked', 'false');
// Toggle auto-connect
await autoConnectToggle.click();
// Verify the setting was applied correctly
- await expect(autoConnectToggle).toHaveAttribute('aria-checked', 'true')
+ await expect(autoConnectToggle).toHaveAttribute('aria-checked', 'true');
const newCliState = execSync('mullvad auto-connect get').toString().trim();
expect(newCliState).toMatch(/off$/);
});
test('Launch on startup setting', async () => {
// Find the launch on start-up toggle
- const launchOnStartupToggle =
- page.getByText('Launch app on start-up').locator('..').getByRole('checkbox');
+ const launchOnStartupToggle = page
+ .getByText('Launch app on start-up')
+ .locator('..')
+ .getByRole('checkbox');
// Check initial state
const initialCliState = execSync('mullvad auto-connect get').toString().trim();
expect(initialCliState).toMatch(/off$/);
- await expect(launchOnStartupToggle).toHaveAttribute('aria-checked', 'false')
+ await expect(launchOnStartupToggle).toHaveAttribute('aria-checked', 'false');
if (process.platform === 'linux') {
expect(autoStartPathExists()).toBeFalsy();
}
@@ -64,7 +67,7 @@ test.describe('VPN Settings', () => {
await launchOnStartupToggle.click();
// Verify the setting was applied correctly
- await expect(launchOnStartupToggle).toHaveAttribute('aria-checked', 'true')
+ await expect(launchOnStartupToggle).toHaveAttribute('aria-checked', 'true');
if (process.platform === 'linux') {
expect(autoStartPathExists()).toBeTruthy();
}
@@ -87,13 +90,13 @@ test.describe('VPN Settings', () => {
// Check initial state
const initialCliState = execSync('mullvad lan get').toString().trim();
expect(initialCliState).toMatch(/block$/);
- await expect(lanToggle).toHaveAttribute('aria-checked', 'false')
+ await expect(lanToggle).toHaveAttribute('aria-checked', 'false');
// Toggle LAN setting
await lanToggle.click();
// Verify the setting was applied correctly
- await expect(lanToggle).toHaveAttribute('aria-checked', 'true')
+ await expect(lanToggle).toHaveAttribute('aria-checked', 'true');
const newState = execSync('mullvad lan get').toString().trim();
expect(newState).toMatch(/allow$/);
});
diff --git a/gui/test/e2e/utils.ts b/gui/test/e2e/utils.ts
index 3e5e40e75f..97524f69bc 100644
--- a/gui/test/e2e/utils.ts
+++ b/gui/test/e2e/utils.ts
@@ -1,5 +1,5 @@
import fs from 'fs';
-import { Locator, Page, _electron as electron, ElectronApplication } from 'playwright';
+import { _electron as electron, ElectronApplication, Locator, Page } from 'playwright';
export interface StartAppResponse {
app: ElectronApplication;
@@ -124,12 +124,11 @@ export function escapeRegExp(regexp: string): string {
return regexp.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
-
export function fileExists(filePath: string): boolean {
try {
fs.accessSync(filePath);
return true;
- } catch (e) {
+ } catch {
return false;
}
}