diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/steamLaunchOptions.test.ts | 48 | ||||
| -rw-r--r-- | tests/test_steam_service.py | 19 |
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/steamLaunchOptions.test.ts b/tests/steamLaunchOptions.test.ts index 049f6be..1a6069f 100644 --- a/tests/steamLaunchOptions.test.ts +++ b/tests/steamLaunchOptions.test.ts @@ -8,6 +8,7 @@ import { installWrapperIntegration, installWrapperLaunchOption, isLegacyWrapperToken, + normalizeShortcutTarget, normalizeLaunchOptions, readSteamLaunchOptions, removeWrapperIntegration, @@ -16,6 +17,12 @@ import { const wrapper = "~/.lsfg"; +test("normalizes Steam's split direct Flatpak target representation", () => { + assert.equal(normalizeShortcutTarget("flatpak", "/usr/bin/"), "/usr/bin/flatpak"); + assert.equal(normalizeShortcutTarget("flatpak", "/usr/bin"), "/usr/bin/flatpak"); + assert.equal(normalizeShortcutTarget("flatpak", "/home/deck/"), "flatpak"); +}); + test("inserts one wrapper immediately before an existing command macro", () => { assert.deepEqual(installWrapperLaunchOption('gamemoderun %command% --profile "high quality"', wrapper), { options: 'gamemoderun ~/.lsfg %command% --profile "high quality"', @@ -144,6 +151,47 @@ test("reads the matching app-details field and installs/removes Steam integratio } }); +test("wraps a split direct Flatpak target while preserving its launch arguments", async () => { + const previousWindow = (globalThis as Record<string, unknown>).window; + const previousSteamClient = (globalThis as Record<string, unknown>).SteamClient; + let shortcutTarget = "flatpak"; + const shortcutOptions = '"run" "--branch=master" "io.github.banjorecomp.banjorecomp"'; + const targetWrites: string[] = []; + const apps = { + RegisterForAppDetails(_appId: number, callback: (details: SteamAppDetails) => void) { + callback({ + strShortcutExe: shortcutTarget, + strShortcutStartDir: "/usr/bin/", + strShortcutLaunchOptions: shortcutOptions, + }); + return { unregister() {} }; + }, + SetShortcutExe(_appId: number, executable: string) { + targetWrites.push(executable); + shortcutTarget = executable; + }, + SetShortcutLaunchOptions() {}, + }; + (globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout }; + (globalThis as Record<string, unknown>).SteamClient = { Apps: apps }; + try { + const installed = await installWrapperIntegration(46, true, wrapper, false, { kind: "flatpak" }); + assert.equal(installed.originalExecutable, "/usr/bin/flatpak"); + assert.equal(installed.snapshot.target, '"~/.lsfg" "/usr/bin/flatpak"'); + assert.equal(installed.snapshot.options, shortcutOptions); + assert.deepEqual(targetWrites, ['"~/.lsfg" "/usr/bin/flatpak"']); + + const restored = await removeWrapperIntegration(46, true, wrapper, installed.originalExecutable, false, { kind: "flatpak" }); + assert.equal(restored.target, "/usr/bin/flatpak"); + assert.deepEqual(targetWrites, ['"~/.lsfg" "/usr/bin/flatpak"', "/usr/bin/flatpak"]); + } finally { + if (previousWindow === undefined) delete (globalThis as Record<string, unknown>).window; + else (globalThis as Record<string, unknown>).window = previousWindow; + if (previousSteamClient === undefined) delete (globalThis as Record<string, unknown>).SteamClient; + else (globalThis as Record<string, unknown>).SteamClient = previousSteamClient; + } +}); + test("uses shortcut launch options for a host shortcut without changing its Target", async () => { const previousWindow = (globalThis as Record<string, unknown>).window; const previousSteamClient = (globalThis as Record<string, unknown>).SteamClient; diff --git a/tests/test_steam_service.py b/tests/test_steam_service.py index 95bd2a2..4f61f3c 100644 --- a/tests/test_steam_service.py +++ b/tests/test_steam_service.py @@ -21,6 +21,10 @@ class SteamTransportTests(unittest.TestCase): classify_shortcut_transport("/usr/bin/flatpak", "run com.example.Game --fullscreen"), {"kind": "flatpak"}, ) + self.assertEqual( + classify_shortcut_transport("flatpak", "run com.example.Game --fullscreen", "/usr/bin/"), + {"kind": "flatpak"}, + ) for executable, options in ( ("flatpak", "run com.example.Game"), ("/usr/bin/flatpak run com.example.Game", "--fullscreen"), @@ -40,6 +44,21 @@ class SteamTransportTests(unittest.TestCase): ) self.assertEqual(classify_shortcut_transport("~/.lsfg", "run com.example.Game"), {"kind": "host"}) + def test_split_flatpak_target_is_recognized_without_script_or_app_detection(self): + game = SteamService._shortcut_game( + { + "appid": 123456, + "AppName": "Split Flatpak shortcut", + "Exe": "flatpak", + "StartDir": "/usr/bin/", + "LaunchOptions": "run io.example.Game", + } + ) + + self.assertEqual(game["transport"], {"kind": "flatpak"}) + self.assertEqual(game["executable"], "flatpak") + self.assertEqual(game["startDir"], "/usr/bin/") + def test_direct_flatpak_shortcut_keeps_arguments_without_an_app_id(self): game = SteamService._shortcut_game( { |
