|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | +import { exec as execAsync } from 'child_process'; |
| 3 | +import { Page } from 'playwright'; |
| 4 | +import { promisify } from 'util'; |
| 5 | + |
| 6 | +import { expectConnected } from '../../shared/tunnel-state'; |
| 7 | +import { startInstalledApp } from '../installed-utils'; |
| 8 | + |
| 9 | +const exec = promisify(execAsync); |
| 10 | + |
| 11 | +// This test expects the daemon to be logged into an account that has time left, have OpenVPN |
| 12 | +// selected and to be disconnected. |
| 13 | + |
| 14 | +let page: Page; |
| 15 | + |
| 16 | +test.beforeAll(async () => { |
| 17 | + ({ page } = await startInstalledApp()); |
| 18 | +}); |
| 19 | + |
| 20 | +test.afterAll(async () => { |
| 21 | + await page.close(); |
| 22 | +}); |
| 23 | + |
| 24 | +test('App should show correct tunnel protocol', async () => { |
| 25 | + await page.getByText('Connect', { exact: true }).click(); |
| 26 | + await expectConnected(page); |
| 27 | + await page.getByTestId('connection-panel-chevron').click(); |
| 28 | + |
| 29 | + const tunnelProtocol = page.getByTestId('tunnel-protocol'); |
| 30 | + await expect(tunnelProtocol).toHaveText('OpenVPN'); |
| 31 | +}); |
| 32 | + |
| 33 | +test('App should show correct OpenVPN transport protocol and port', async () => { |
| 34 | + const inData = page.getByTestId('in-ip'); |
| 35 | + |
| 36 | + await expect(inData).toContainText(new RegExp(':[0-9]+')); |
| 37 | + await expect(inData).toContainText(new RegExp('(TCP|UDP)$')); |
| 38 | + await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1195'); |
| 39 | + await expectConnected(page); |
| 40 | + await page.getByTestId('connection-panel-chevron').click(); |
| 41 | + await expect(inData).toContainText(new RegExp(':1195')); |
| 42 | + |
| 43 | + await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1300'); |
| 44 | + await expectConnected(page); |
| 45 | + await page.getByTestId('connection-panel-chevron').click(); |
| 46 | + await expect(inData).toContainText(new RegExp(':1300')); |
| 47 | + |
| 48 | + await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port any'); |
| 49 | + await expectConnected(page); |
| 50 | + await page.getByTestId('connection-panel-chevron').click(); |
| 51 | + await expect(inData).toContainText(new RegExp(':[0-9]+')); |
| 52 | + await expect(inData).toContainText(new RegExp('TCP$')); |
| 53 | + |
| 54 | + await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 80'); |
| 55 | + await expectConnected(page); |
| 56 | + await page.getByTestId('connection-panel-chevron').click(); |
| 57 | + await expect(inData).toContainText(new RegExp(':80')); |
| 58 | + |
| 59 | + await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 443'); |
| 60 | + await expectConnected(page); |
| 61 | + await page.getByTestId('connection-panel-chevron').click(); |
| 62 | + await expect(inData).toContainText(new RegExp(':443')); |
| 63 | + |
| 64 | + await exec('mullvad relay set tunnel openvpn --transport-protocol any'); |
| 65 | +}); |
| 66 | + |
| 67 | +test('App should show bridge mode', async () => { |
| 68 | + await exec('mullvad bridge set state on'); |
| 69 | + await expectConnected(page); |
| 70 | + const relay = page.getByTestId('hostname-line'); |
| 71 | + await expect(relay).toHaveText(new RegExp(' via ', 'i')); |
| 72 | +}); |
0 commit comments