From f319e14d9514dea9ab3b2ac46f811b3b9c3ddde6 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Wed, 7 Aug 2024 14:04:40 +0100 Subject: [PATCH] replicate when platform.name is absent in windows --- packages/special-pages/pages/duckplayer/app/index.js | 1 + .../duckplayer/app/providers/SettingsProvider.jsx | 12 +----------- .../special-pages/tests/page-objects/duck-player.js | 7 ++----- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/special-pages/pages/duckplayer/app/index.js b/packages/special-pages/pages/duckplayer/app/index.js index 5fea1be668..8b14018c66 100644 --- a/packages/special-pages/pages/duckplayer/app/index.js +++ b/packages/special-pages/pages/duckplayer/app/index.js @@ -56,6 +56,7 @@ export async function init (messaging, baseEnvironment) { }) const settings = new Settings({}) + .withPlatformName(baseEnvironment.platform) .withPlatformName(init.platform?.name) .withPlatformName(baseEnvironment.urlParams.get('platform')) .withFeatureState('pip', init.settings.pip) diff --git a/packages/special-pages/pages/duckplayer/app/providers/SettingsProvider.jsx b/packages/special-pages/pages/duckplayer/app/providers/SettingsProvider.jsx index d72f32a430..ffab68312a 100644 --- a/packages/special-pages/pages/duckplayer/app/providers/SettingsProvider.jsx +++ b/packages/special-pages/pages/duckplayer/app/providers/SettingsProvider.jsx @@ -49,17 +49,7 @@ export function useOpenSettingsHandler() { } export function useSettingsUrl() { - const settings = useContext(SettingsContext).settings; - switch (settings.platform.name) { - case "windows": - return "duck://settings/duckplayer" - case "macos": - return "about:preferences/duckplayer" - default: { - console.warn("unreachable!") - } - } - return '' + return 'duck://settings/duckplayer' } export function useSettings() { diff --git a/packages/special-pages/tests/page-objects/duck-player.js b/packages/special-pages/tests/page-objects/duck-player.js index 240fcc2af5..868fd40221 100644 --- a/packages/special-pages/tests/page-objects/duck-player.js +++ b/packages/special-pages/tests/page-objects/duck-player.js @@ -59,7 +59,7 @@ export class DuckPlayerPage { }, locale: 'en', env: 'development', - platform: { name: this.platform.name } + platform: this.platform.name === 'windows' ? undefined : { name: this.platform.name } }, /** @type {import('../../types/duckplayer.js').UserValues} */ getUserValues: { @@ -325,10 +325,7 @@ export class DuckPlayerPage { this.page.context().on('requestfailed', resolve) }) - const expected = this.build.switch({ - windows: () => 'duck://settings/duckplayer', - apple: () => 'about:preferences/duckplayer' - }) + const expected = 'duck://settings/duckplayer' const openSettings = this.page.getByRole('link', { name: 'Open Settings' }) expect(await openSettings.getAttribute('href')).toEqual(expected)