diff options
Diffstat (limited to 'desktop')
2 files changed, 42 insertions, 13 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 index ad9e021cc3..ebae817f2f 100644 --- 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 @@ -3,4 +3,5 @@ import { Page } from 'playwright'; export const createSelectors = (page: Page) => ({ launchAppOnStartupSwitch: () => page.getByLabel('Launch app on start-up'), autoConnectSwitch: () => page.getByLabel('Auto-connect'), + lanSwitch: () => page.getByLabel('Local network sharing'), }); 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 index 9dbab30770..dbb67e6a30 100644 --- 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 @@ -116,21 +116,49 @@ test.describe('VPN settings', () => { }); }); - test('LAN settings', async () => { - // Find the LAN toggle - const lanToggle = page.getByText('Local network sharing').locator('..').getByRole('checkbox'); + test.describe('LAN settings', () => { + const expectLocalNetworkSharing = async ( + ariaChecked: 'true' | 'false', + cliState: 'allow' | 'block', + ) => { + const lanSwitch = selectors.lanSwitch(); + await expect(lanSwitch).toHaveAttribute('aria-checked', ariaChecked); + const cliStateOutput = execSync('mullvad lan get').toString(); + expect(cliStateOutput).toContain(cliState); + }; + + const expectLocalNetworkSharingEnabled = async () => { + await expectLocalNetworkSharing('true', 'allow'); + }; + + const expectLocalNetworkSharingDisabled = async () => { + await expectLocalNetworkSharing('false', 'block'); + }; + + const disableLocalNetworkSharing = async () => { + const lanSwitch = selectors.lanSwitch(); + if ((await lanSwitch.getAttribute('aria-checked')) === 'true') { + await lanSwitch.click(); + } + await expectLocalNetworkSharingDisabled(); + }; - // Check initial state - const initialCliState = execSync('mullvad lan get').toString().trim(); - expect(initialCliState).toMatch(/block$/); - await expect(lanToggle).toHaveAttribute('aria-checked', 'false'); + test.beforeAll(async () => { + // Ensure local network sharing is disabled before starting the tests + await disableLocalNetworkSharing(); + }); - // Toggle LAN setting - await lanToggle.click(); + test.afterEach(async () => { + await disableLocalNetworkSharing(); + }); - // Verify the setting was applied correctly - await expect(lanToggle).toHaveAttribute('aria-checked', 'true'); - const newState = execSync('mullvad lan get').toString().trim(); - expect(newState).toMatch(/allow$/); + test('Should be enabled when switch is clicked', async () => { + await expectLocalNetworkSharingDisabled(); + + const lanSwitch = selectors.lanSwitch(); + await lanSwitch.click(); + + await expectLocalNetworkSharingEnabled(); + }); }); }); |
