diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-11 13:47:52 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-11 13:47:52 -0400 |
| commit | f3074fbe1427411dc3b5597d2e87918383299e3f (patch) | |
| tree | bf96f3d6f3942327a8a6541b8a7d7a18906a748e /tests | |
| parent | d1990a2b630f7161342a9c854bce0fcf7a967a8d (diff) | |
| download | decky-lsfg-vk-f3074fbe1427411dc3b5597d2e87918383299e3f.tar.gz decky-lsfg-vk-f3074fbe1427411dc3b5597d2e87918383299e3f.zip | |
feat: non steam tab, faster bulk actions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gameTargets.test.ts | 41 | ||||
| -rw-r--r-- | tests/nowPlaying.test.ts | 7 | ||||
| -rw-r--r-- | tests/test_configuration_profiles.py | 17 |
3 files changed, 64 insertions, 1 deletions
diff --git a/tests/gameTargets.test.ts b/tests/gameTargets.test.ts new file mode 100644 index 0000000..9896d76 --- /dev/null +++ b/tests/gameTargets.test.ts @@ -0,0 +1,41 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { getTargetSource, mergeGameTargets, targetsForSource } from "../src/utils/gameTargets.ts"; + +const config = (appid: string, profile: string) => ({ appid, profile, config: {} }); + +test("workaround sidecar source wins over current discovery metadata", () => { + const installed = [{ appid: "123", name: "Shortcut", nonSteam: false }]; + const workarounds = [{ appid: "123", non_steam: true, command_token_added: true }]; + + assert.equal(getTargetSource("123", installed, workarounds), "nonSteam"); + assert.equal(mergeGameTargets([config("123", "Shortcut")], installed, workarounds)[0].source, "nonSteam"); +}); + +test("configured profiles without reliable source are unknown", () => { + const targets = mergeGameTargets([config("456", "Missing Game")], [], []); + + assert.deepEqual(targets[0], { + appid: "456", + name: "Missing Game", + nonSteam: false, + source: "unknown", + configured: true, + }); +}); + +test("unknown configured profiles are visible in both source tabs", () => { + const targets = mergeGameTargets([ + config("123", "Steam Game"), + config("456", "Missing Game"), + ], [ + { appid: "123", name: "Steam Game", nonSteam: false }, + { appid: "789", name: "Shortcut", nonSteam: true }, + ], []); + + const steamTargets = targetsForSource(targets, "steam"); + const nonSteamTargets = targetsForSource(targets, "nonSteam"); + + assert.deepEqual(steamTargets.map((target) => target.appid).sort(), ["123", "456"]); + assert.deepEqual(nonSteamTargets.map((target) => target.appid).sort(), ["456", "789"]); +}); diff --git a/tests/nowPlaying.test.ts b/tests/nowPlaying.test.ts index c99ffc4..a6b116a 100644 --- a/tests/nowPlaying.test.ts +++ b/tests/nowPlaying.test.ts @@ -24,6 +24,7 @@ const game = (nonSteam = true, configured = true) => ({ appid: "123456", name: nonSteam ? "1080 Snowboarding" : "Native Game", nonSteam, + source: nonSteam ? "nonSteam" : "steam", configured, }); @@ -102,6 +103,12 @@ test("configured Steam target remains the fallback", () => { assert.equal(target?.kind, "steam"); }); +test("configured non-Steam target remains the fallback", () => { + const target = resolveNowPlayingTarget(game(true), null); + + assert.equal(target?.kind, "nonSteam"); +}); + test("unconfigured Steam target has no Now Playing controls", () => { assert.equal(resolveNowPlayingTarget(game(false, false), null), null); }); diff --git a/tests/test_configuration_profiles.py b/tests/test_configuration_profiles.py index 64db0f1..898a9e7 100644 --- a/tests/test_configuration_profiles.py +++ b/tests/test_configuration_profiles.py @@ -3,7 +3,7 @@ import tempfile import types import unittest from pathlib import Path -from unittest.mock import Mock +from unittest.mock import Mock, patch sys.modules.setdefault( @@ -64,6 +64,21 @@ preserve_swapchain_image_count = false self.assertIn("flatpak:org.example.Game", data["profiles"]) self.assertEqual(data["profiles"]["flatpak:org.example.Game"]["multiplier"], 3) + def test_scoped_game_reset_is_one_write_and_preserves_other_profiles(self): + self.service.update_game_config("123", "Steam Game", {"multiplier": 2}) + self.service.update_game_config("456", "Non-Steam Game", {"multiplier": 3}) + self.service.update_flatpak_config("org.example.Game", {"multiplier": 4}) + + with patch.object(self.service, "_save_profile_data", wraps=self.service._save_profile_data) as save: + result = self.service.reset_game_configs(["123"]) + + data = self.service._get_profile_data() + self.assertTrue(result["success"]) + self.assertEqual(save.call_count, 1) + self.assertNotIn("Steam Game", data["profiles"]) + self.assertIn("Non-Steam Game", data["profiles"]) + self.assertIn("flatpak:org.example.Game", data["profiles"]) + def test_flatpak_reset_all_preserves_steam_profiles(self): self.service.update_game_config("123", "Steam Game", {"multiplier": 2}) self.service.update_flatpak_config("org.example.Game", {"multiplier": 3}) |
