summaryrefslogtreecommitdiff
path: root/tests/steamLaunchOptions.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/steamLaunchOptions.test.ts')
-rw-r--r--tests/steamLaunchOptions.test.ts133
1 files changed, 64 insertions, 69 deletions
diff --git a/tests/steamLaunchOptions.test.ts b/tests/steamLaunchOptions.test.ts
index 3170fe8..40aeb3c 100644
--- a/tests/steamLaunchOptions.test.ts
+++ b/tests/steamLaunchOptions.test.ts
@@ -28,7 +28,7 @@ test("inserts one wrapper immediately before an existing command macro", () => {
});
});
-test("normalizes blank and argument-only fields while refusing ambiguous launchers", () => {
+test("normalizes blank and argument-only shortcut fields", () => {
assert.deepEqual(installWrapperLaunchOption("", wrapper), {
options: `${wrapper} %command%`,
commandTokenAdded: true,
@@ -41,7 +41,7 @@ test("normalizes blank and argument-only fields while refusing ambiguous launche
assert.throws(() => installWrapperLaunchOption('"%command%"', wrapper), /refusing to guess/);
});
-test("preserves assignments, quoting, suffixes, and unrelated values", () => {
+test("preserves assignments quoting suffixes and released wrapper cleanup", () => {
const options = 'FOO="hello world" VK_INSTANCE_LAYERS="one:two" gamemoderun %command% --flag "two words"';
assert.equal(
installWrapperLaunchOption(options, wrapper).options,
@@ -49,50 +49,40 @@ test("preserves assignments, quoting, suffixes, and unrelated values", () => {
);
assert.equal(removeWrapperLaunchOption(`${wrapper} %command% --arg "${wrapper}"`, wrapper, true), `--arg "${wrapper}"`);
assert.equal(normalizeLaunchOptions(" FOO=bar %COMMAND% --flag "), "FOO=bar %COMMAND% --flag");
-});
-
-test("cleans current, legacy, and bare Mako wrappers without touching suffix arguments", () => {
for (const token of ["~/lsfg", "/home/deck/lsfg", "mako-run", "mako-launch"]) {
assert.equal(cleanupLegacyWrapper(`FOO=bar ${token} %command% --arg "${token}"`), `FOO=bar %command% --arg "${token}"`);
}
- assert.equal(cleanupLegacyWrapper(`FOO=bar ${wrapper} %command%`), "FOO=bar %command%");
assert.equal(isLegacyWrapperToken("/home/kurt/lsfg"), true);
assert.equal(isLegacyWrapperToken("/opt/tools/lsfg"), false);
- assert.equal(removeWrapperLaunchOption(`FOO=bar ${wrapper} %command% --arg`, wrapper), "FOO=bar %command% --arg");
});
-test("removes only old plugin assignments and preserves DXVK settings", () => {
+test("removes only managed assignments and preserves unrelated values", () => {
assert.equal(
cleanupPluginAssignments(
'FOO="keep this" ENABLE_GAMESCOPE_WSI=0 DXVK_HDR=0 SteamDeck=0 DISABLE_VKBASALT=1 MESA_LOADER_DRIVER_OVERRIDE=zink DXVK_CONFIG="dxgi.syncInterval = 0; dxvk.maxFrameRate = 30" %command%',
),
'FOO="keep this" DXVK_CONFIG="dxgi.syncInterval = 0" %command%',
);
- assert.equal(
- cleanupPluginLaunchOptions(`DXVK_FRAME_RATE=30 ${wrapper} %command%`, wrapper),
- "%command%",
- );
+ assert.equal(cleanupPluginLaunchOptions(`DXVK_FRAME_RATE=30 ${wrapper} %command%`, wrapper), "%command%");
assert.equal(
cleanupPluginAssignments("PROTON_USE_WOW64=1 MANGOHUD=1 MANGOHUD_CONFIG=alpha %command%"),
"PROTON_USE_WOW64=1 MANGOHUD=1 MANGOHUD_CONFIG=alpha %command%",
);
});
-test("reads the matching app-details field and installs/removes Steam integration", async () => {
+test("uses launch options for Steam and non-Steam shortcuts without a Target API", async () => {
const previousWindow = (globalThis as Record<string, unknown>).window;
const previousSteamClient = (globalThis as Record<string, unknown>).SteamClient;
let appOptions = "FOO=bar %command%";
let shortcutOptions = "--windowed";
- let shortcutTarget = "/usr/bin/example-game";
const appWrites: string[] = [];
const shortcutWrites: string[] = [];
- const targetWrites: string[] = [];
const unregisters: number[] = [];
const apps = {
RegisterForAppDetails(appId: number, callback: (details: SteamAppDetails) => void) {
callback(appId === 42
? { strLaunchOptions: appOptions, strShortcutLaunchOptions: "wrong-field" }
- : { strShortcutExe: shortcutTarget, strShortcutLaunchOptions: shortcutOptions, strLaunchOptions: "wrong-field" });
+ : { strShortcutLaunchOptions: shortcutOptions, strLaunchOptions: "wrong-field" });
return { unregister: () => unregisters.push(appId) };
},
SetAppLaunchOptions(appId: number, options: string) {
@@ -105,11 +95,6 @@ test("reads the matching app-details field and installs/removes Steam integratio
shortcutWrites.push(options);
shortcutOptions = options;
},
- SetShortcutExe(appId: number, executable: string) {
- assert.equal(appId, 43);
- targetWrites.push(executable);
- shortcutTarget = executable;
- },
};
(globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout };
(globalThis as Record<string, unknown>).SteamClient = { Apps: apps };
@@ -120,18 +105,15 @@ test("reads the matching app-details field and installs/removes Steam integratio
assert.equal(installed.snapshot.options, `FOO=bar ${wrapper} %command%`.replaceAll(" ", " "));
assert.equal(installed.commandTokenAdded, false);
assert.equal(appWrites.length, 1);
- assert.equal(shortcutWrites.length, 0);
const shortcut = await installWrapperIntegration(43, true, wrapper);
- assert.equal(shortcut.originalExecutable, "/usr/bin/example-game");
- assert.equal(shortcut.snapshot.target, wrapper);
- assert.deepEqual(targetWrites, [wrapper]);
- const restored = await removeWrapperIntegration(43, true, wrapper, shortcut.originalExecutable);
- assert.equal(restored.target, "/usr/bin/example-game");
- assert.deepEqual(targetWrites, [wrapper, "/usr/bin/example-game"]);
- assert.equal(shortcutWrites.length, 0);
+ assert.equal(shortcut.snapshot.options, `~/.lsfg %command% --windowed`);
+ assert.deepEqual(shortcutWrites, [`~/.lsfg %command% --windowed`]);
+
+ const restored = await removeWrapperIntegration(43, true, wrapper, shortcut.commandTokenAdded);
+ assert.equal(restored.options, "--windowed");
- const cleaned = await removeWrapperIntegration(42, false, wrapper, undefined, installed.commandTokenAdded);
+ const cleaned = await removeWrapperIntegration(42, false, wrapper, installed.commandTokenAdded);
assert.equal(cleaned.options, "FOO=bar %command%".replaceAll(" ", " "));
assert.ok(unregisters.includes(42));
assert.ok(unregisters.includes(43));
@@ -143,21 +125,46 @@ test("reads the matching app-details field and installs/removes Steam integratio
}
});
-test("fails closed when shortcut Target ownership or setters are unavailable", async () => {
+test("AppImage EmuDeck and direct Flatpak shortcuts all stay launch-option based", async () => {
const previousWindow = (globalThis as Record<string, unknown>).window;
const previousSteamClient = (globalThis as Record<string, unknown>).SteamClient;
- (globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout };
- (globalThis as Record<string, unknown>).SteamClient = {
- Apps: {
- RegisterForAppDetails(_appId: number, callback: (details: SteamAppDetails) => void) {
- callback({ strShortcutExe: "/usr/bin/other", strShortcutLaunchOptions: "" });
- return { unregister() {} };
- },
+ const cases = [
+ {
+ options: 'DESKTOPINTEGRATION=1 "/home/deck/AppImages/dusk.appimage"',
+ expected: 'DESKTOPINTEGRATION=1 ~/.lsfg %command% "/home/deck/AppImages/dusk.appimage"',
},
- };
+ {
+ options: "",
+ expected: "~/.lsfg %command%",
+ },
+ {
+ options: "run org.example.Game",
+ expected: "~/.lsfg %command% run org.example.Game",
+ },
+ ];
+ (globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout };
try {
- await assert.rejects(installWrapperIntegration(99, true, wrapper), /Target API is unavailable/);
- await assert.rejects(removeWrapperIntegration(99, true, wrapper, "/usr/bin/original"), /Target changed externally/);
+ for (const [index, item] of cases.entries()) {
+ let shortcutOptions = item.options;
+ const shortcutWrites: string[] = [];
+ (globalThis as Record<string, unknown>).SteamClient = {
+ Apps: {
+ RegisterForAppDetails(_appId: number, callback: (details: SteamAppDetails) => void) {
+ callback({ strShortcutLaunchOptions: shortcutOptions });
+ return { unregister() {} };
+ },
+ SetShortcutLaunchOptions(_appId: number, options: string) {
+ shortcutWrites.push(options);
+ shortcutOptions = options;
+ },
+ },
+ };
+ const installed = await installWrapperIntegration(100 + index, true, wrapper);
+ assert.equal(installed.snapshot.options, item.expected);
+ assert.deepEqual(shortcutWrites, [item.expected]);
+ const restored = await removeWrapperIntegration(100 + index, true, wrapper, installed.commandTokenAdded);
+ assert.equal(restored.options, item.options);
+ }
} finally {
if (previousWindow === undefined) delete (globalThis as Record<string, unknown>).window;
else (globalThis as Record<string, unknown>).window = previousWindow;
@@ -166,41 +173,29 @@ test("fails closed when shortcut Target ownership or setters are unavailable", a
}
});
-test("restores launch options and shortcut Target when a setter fails after changing them", async () => {
+test("launch option write failure rolls back the original value", async () => {
const previousWindow = (globalThis as Record<string, unknown>).window;
const previousSteamClient = (globalThis as Record<string, unknown>).SteamClient;
let appOptions = "FOO=bar %command%";
- let shortcutTarget = "/usr/bin/original";
- const appWrites: string[] = [];
- const targetWrites: string[] = [];
- const apps = {
- RegisterForAppDetails(appId: number, callback: (details: SteamAppDetails) => void) {
- callback(appId === 42
- ? { strLaunchOptions: appOptions }
- : { strShortcutExe: shortcutTarget, strShortcutLaunchOptions: "" });
- return { unregister() {} };
- },
- SetAppLaunchOptions(_appId: number, options: string) {
- appWrites.push(options);
- appOptions = options;
- if (options.includes(wrapper)) throw new Error("simulated launch-option write failure");
- },
- SetShortcutExe(_appId: number, executable: string) {
- targetWrites.push(executable);
- shortcutTarget = executable;
- if (executable === wrapper) throw new Error("simulated Target write failure");
+ const writes: string[] = [];
+ (globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout };
+ (globalThis as Record<string, unknown>).SteamClient = {
+ Apps: {
+ RegisterForAppDetails(_appId: number, callback: (details: SteamAppDetails) => void) {
+ callback({ strLaunchOptions: appOptions });
+ return { unregister() {} };
+ },
+ SetAppLaunchOptions(_appId: number, options: string) {
+ writes.push(options);
+ appOptions = options;
+ if (options.includes(wrapper)) throw new Error("simulated launch option failure");
+ },
},
};
- (globalThis as Record<string, unknown>).window = { setTimeout, clearTimeout };
- (globalThis as Record<string, unknown>).SteamClient = { Apps: apps };
try {
- await assert.rejects(installWrapperIntegration(42, false, wrapper), /simulated launch-option write failure/);
+ await assert.rejects(installWrapperIntegration(42, false, wrapper), /simulated launch option failure/);
assert.equal(appOptions, "FOO=bar %command%");
- assert.deepEqual(appWrites, [`FOO=bar ${wrapper} %command%`, "FOO=bar %command%"]);
-
- await assert.rejects(installWrapperIntegration(43, true, wrapper), /simulated Target write failure/);
- assert.equal(shortcutTarget, "/usr/bin/original");
- assert.deepEqual(targetWrites, [wrapper, "/usr/bin/original"]);
+ assert.deepEqual(writes, [`FOO=bar ${wrapper} %command%`, "FOO=bar %command%"]);
} finally {
if (previousWindow === undefined) delete (globalThis as Record<string, unknown>).window;
else (globalThis as Record<string, unknown>).window = previousWindow;