summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2025-09-15 15:46:26 +0200
committerOskar <oskar@mullvad.net>2025-10-01 13:19:43 +0200
commit73f89bce2f4120bbbd52218722f78583a6cb3925 (patch)
tree7d7e4f2892dda1a788393d4e0b6c45c3720e80af
parentd43fba6eb625ab8ad39bc29cb9d5cbd24d5721a7 (diff)
downloadmullvadvpn-73f89bce2f4120bbbd52218722f78583a6cb3925.tar.xz
mullvadvpn-73f89bce2f4120bbbd52218722f78583a6cb3925.zip
Allow shift+escape in development only
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/components/KeyboardNavigation.tsx9
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/lib/routeHelpers.ts12
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts12
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts3
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/route-object-models/navigation/navigation-object-model.ts14
5 files changed, 21 insertions, 29 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/KeyboardNavigation.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/KeyboardNavigation.tsx
index 79fde5e536..762ef46fc7 100644
--- a/desktop/packages/mullvad-vpn/src/renderer/components/KeyboardNavigation.tsx
+++ b/desktop/packages/mullvad-vpn/src/renderer/components/KeyboardNavigation.tsx
@@ -1,9 +1,6 @@
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
-import { useLocation } from 'react-router';
-import { RoutePath } from '../../shared/routes';
import { useHistory } from '../lib/history';
-import { disableDismissForRoutes } from '../lib/routeHelpers';
import { useEffectEvent } from '../lib/utility-hooks';
interface IKeyboardNavigationProps {
@@ -14,7 +11,6 @@ interface IKeyboardNavigationProps {
export default function KeyboardNavigation(props: IKeyboardNavigationProps) {
const { pop } = useHistory();
const [backAction, setBackActionImpl] = useState<BackActionFn>();
- const location = useLocation();
// Since the backaction is now a function we need to make sure it's not called when setting the
// state.
@@ -25,15 +21,14 @@ export default function KeyboardNavigation(props: IKeyboardNavigationProps) {
const handleKeyDown = useCallback(
(event: KeyboardEvent) => {
if (event.key === 'Escape') {
- const path = location.pathname as RoutePath;
- if (event.shiftKey && !disableDismissForRoutes.includes(path)) {
+ if (event.shiftKey && window.env.development) {
pop(true);
} else {
backAction?.();
}
}
},
- [pop, backAction, location.pathname],
+ [pop, backAction],
);
useEffect(() => {
diff --git a/desktop/packages/mullvad-vpn/src/renderer/lib/routeHelpers.ts b/desktop/packages/mullvad-vpn/src/renderer/lib/routeHelpers.ts
index e610a2ac77..3f9c95f7a4 100644
--- a/desktop/packages/mullvad-vpn/src/renderer/lib/routeHelpers.ts
+++ b/desktop/packages/mullvad-vpn/src/renderer/lib/routeHelpers.ts
@@ -4,18 +4,6 @@ import { RoutePath } from '../../shared/routes';
export type GeneratedRoutePath = { routePath: string };
-export const disableDismissForRoutes = [
- RoutePath.launch,
- RoutePath.login,
- RoutePath.tooManyDevices,
- RoutePath.deviceRevoked,
- RoutePath.main,
- RoutePath.redeemVoucher,
- RoutePath.voucherSuccess,
- RoutePath.timeAdded,
- RoutePath.setupFinished,
-];
-
export function generateRoutePath(
routePath: RoutePath,
parameters: Parameters<typeof generatePath>[1],
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 d6b25b0d99..99eb0bf517 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
@@ -3,6 +3,7 @@ import { exec as execAsync } from 'child_process';
import { Page } from 'playwright';
import { promisify } from 'util';
+import { RoutePath } from '../../../../src/shared/routes';
import { RoutesObjectModel } from '../../route-object-models';
import { expectConnected, expectDisconnected, expectError } from '../../shared/tunnel-state';
import { escapeRegExp, TestUtils } from '../../utils';
@@ -106,10 +107,6 @@ test.describe('Tunnel state and settings', () => {
await exec('mullvad connect --wait');
});
- test.afterAll(async () => {
- await routes.wireguardSettings.gotoRoot();
- });
-
test('App should show UDP', async () => {
await expectConnected(page);
await routes.main.expandConnectionPanel();
@@ -126,7 +123,7 @@ test.describe('Tunnel state and settings', () => {
await routes.wireguardSettings.selectUdpOverTcp();
await expect(udpOverTcpOption).toHaveAttribute('aria-selected', 'true');
- await routes.wireguardSettings.gotoRoot();
+ await routes.wireguardSettings.goBackToRoute(RoutePath.main);
await expectConnected(page);
@@ -140,7 +137,9 @@ test.describe('Tunnel state and settings', () => {
test(`App should show port ${port}`, async () => {
await gotoUdpOverTcpSettings();
await routes.udpOverTcpSettings.selectPort(port);
- await routes.udpOverTcpSettings.gotoRoot();
+
+ await routes.udpOverTcpSettings.goBackToRoute(RoutePath.main);
+
await routes.main.expandConnectionPanel();
const inValue = await routes.main.getInIpText();
@@ -154,6 +153,7 @@ test.describe('Tunnel state and settings', () => {
const automaticOption = routes.wireguardSettings.getAutomaticObfuscationOption();
await expect(automaticOption).toHaveAttribute('aria-selected', 'true');
+ await routes.udpOverTcpSettings.goBackToRoute(RoutePath.main);
});
});
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
index 72fb1e7d61..b7786a983f 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/feature-indicators/feature-indicators.spec.ts
@@ -165,8 +165,7 @@ test.describe('Feature indicators', () => {
test.afterEach(async () => {
await helpers.disconnect();
- await routes.wireguardSettings.gotoRoot();
- await util.expectRoute(RoutePath.main);
+ await routes.wireguardSettings.goBackToRoute(RoutePath.main);
});
async function expectFeatureIndicators(expectedIndicators: Array<string>, only = true) {
diff --git a/desktop/packages/mullvad-vpn/test/e2e/route-object-models/navigation/navigation-object-model.ts b/desktop/packages/mullvad-vpn/test/e2e/route-object-models/navigation/navigation-object-model.ts
index 912142c737..36d3aba6cc 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/route-object-models/navigation/navigation-object-model.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/route-object-models/navigation/navigation-object-model.ts
@@ -1,5 +1,7 @@
import { Page } from 'playwright';
+import { RoutePath } from '../../../../src/shared/routes';
+import { matchPaths } from '../../lib/path-helpers';
import { TestUtils } from '../../utils';
import { createSelectors } from './selectors';
@@ -17,7 +19,15 @@ export class NavigationObjectModel {
await this.utils.expectRouteChange(() => this.navigationSelectors.backButton().click());
}
- async gotoRoot() {
- await this.page.press('body', 'Shift+Escape');
+ async goBackToRoute(route: RoutePath) {
+ const currentRoute = await this.utils.getCurrentRoute();
+ if (!matchPaths(route, currentRoute)) {
+ if (await this.navigationSelectors.backButton().isVisible()) {
+ await this.goBack();
+ await this.goBackToRoute(route);
+ } else {
+ await this.utils.expectRoute(route);
+ }
+ }
}
}