From 6646c93889f39a7d12fe90da94cc14b8ee36ed23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Tue, 6 Oct 2026 17:38:08 +0200 Subject: [PATCH] Retrieve out IP from CLI in UI test This applies to the tunnel-state tests --- .../state-dependent/tunnel-state.spec.ts | 25 +++++++++++++------ test/test-manager/src/tests/ui.rs | 11 +++----- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts index 732e4a884d..b9e50301bc 100644 --- a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts +++ b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts @@ -12,10 +12,7 @@ import { startInstalledApp } from '../installed-utils'; const exec = promisify(execAsync); // This test expects the daemon to be logged into an account that has time left and to be -// disconnected. Env parameters: -// CONNECTION_CHECK_URL: Url to the connection check - -const { CONNECTION_CHECK_URL } = process.env; +// disconnected. interface ConnectedRelay { hostname: string; @@ -23,6 +20,7 @@ interface ConnectedRelay { inPort: number; inProtocol: string; obfuscationType?: string; + outIpv4?: string; } // Returns the relay that the daemon is connected to @@ -44,9 +42,23 @@ async function getConnectedRelay(): Promise { inPort: Number(inPort), inProtocol: inEndpoint.protocol, obfuscationType: obfuscation?.obfuscation_type.toLowerCase(), + outIpv4: location.ipv4 ?? undefined, }; } +// Returns the public IPv4 address of the tunnel. The daemon looks this up after connecting, so this +// waits for at most the `expect` timeout for it to become known. +async function getOutIpv4(): Promise { + let outIpv4: string | undefined; + await expect + .poll(async () => { + outIpv4 = (await getConnectedRelay()).outIpv4; + return outIpv4; + }) + .toBeDefined(); + return outIpv4!; +} + function formatInAddress(relay: ConnectedRelay) { // The app shows IPv6 addresses in brackets const inIp = relay.inIp.includes(':') ? `[${relay.inIp}]` : relay.inIp; @@ -118,10 +130,7 @@ test.describe('Tunnel state and settings', () => { await expect(outIp).toBeVisible(); - const ipResponse = await fetch(`${CONNECTION_CHECK_URL!}/ip`); - const ip = await ipResponse.text(); - - await expect(outIp).toHaveText(ip.trim()); + await expect(outIp).toHaveText(await getOutIpv4()); }); test('App should show correct WireGuard port', async () => { diff --git a/test/test-manager/src/tests/ui.rs b/test/test-manager/src/tests/ui.rs index a39d7b665e..7e90a5d0bc 100644 --- a/test/test-manager/src/tests/ui.rs +++ b/test/test-manager/src/tests/ui.rs @@ -86,14 +86,9 @@ pub async fn test_ui_tunnel_settings( rpc: ServiceClient, _: MullvadProxyClient, ) -> anyhow::Result<()> { - let connection_check_url = format!("https://am.i.{}", TEST_CONFIG.mullvad_host); - let ui_result = run_test_env( - &rpc, - &["state-dependent/tunnel-state.spec"], - [("CONNECTION_CHECK_URL", connection_check_url.as_str())], - ) - .await - .unwrap(); + let ui_result = run_test(&rpc, &["state-dependent/tunnel-state.spec"]) + .await + .unwrap(); assert!(ui_result.success()); Ok(())