From b3dfd5305dc254e177d16ce1675a672857b0b391 Mon Sep 17 00:00:00 2001 From: ShuaixinHuang Date: Fri, 20 Nov 2026 13:05:23 +0800 Subject: [PATCH] test(desktop): keep TryExec regression independent of ID masking group --- src/desktop/LinuxApplicationInventory.test.ts | 89 ++++++++++--------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/desktop/LinuxApplicationInventory.test.ts b/src/desktop/LinuxApplicationInventory.test.ts index dae61af3c3..226394d9fa 100644 --- a/src/desktop/LinuxApplicationInventory.test.ts +++ b/src/desktop/LinuxApplicationInventory.test.ts @@ -170,52 +170,55 @@ describe.skipIf(process.platform === "win32")( }, ); +const userOverride = async (contents: string | Buffer) => { + const { home, environment } = await fixture(); + const applications = join(environment.XDG_DATA_HOME, "applications"); + await mkdir(applications, { recursive: true }); + const file = join(applications, "org.example.notes.desktop"); + await writeFile(file, contents); + const inspect = (desktopEntry = "org.example.notes") => + inspectLinuxApplication({ + desktopEntry, + executable: undefined, + arguments: [], + environment, + home, + callerDirectory: home, + }); + return { inspect, file }; +}; + +it.skipIf(process.platform === "win32")( + "skips an unavailable TryExec by ID and refuses the explicit file", + async () => { + const { inspect, file } = await userOverride( + "[Desktop Entry]\nType=Application\nName=User notes\nExec=notes-app\nTryExec=rea-missing-tryexec\n", + ); + expect(await inspect()).toMatchObject({ + ok: true, + value: { inventory: { desktop_entry: { name: "Notes" } } }, + }); + expect(await inspect(file)).toMatchObject({ + ok: false, + error: { + reason: "executable_not_found", + program: "rea-missing-tryexec", + }, + }); + await writeFile( + file, + "[Desktop Entry]\nType=Application\nName=User notes\nExec=notes-app\nTryExec=notes-app\n", + ); + expect(await inspect()).toMatchObject({ + ok: true, + value: { inventory: { desktop_entry: { name: "User notes" } } }, + }); + }, +); + describe.skipIf(process.platform === "win32")( "desktop entry ID masking", () => { - const userOverride = async (contents: string | Buffer) => { - const { home, environment } = await fixture(); - const applications = join(environment.XDG_DATA_HOME, "applications"); - await mkdir(applications, { recursive: true }); - const file = join(applications, "org.example.notes.desktop"); - await writeFile(file, contents); - const inspect = (desktopEntry = "org.example.notes") => - inspectLinuxApplication({ - desktopEntry, - executable: undefined, - arguments: [], - environment, - home, - callerDirectory: home, - }); - return { inspect, file }; - }; - - it("skips an unavailable TryExec by ID and refuses the explicit file", async () => { - const { inspect, file } = await userOverride( - "[Desktop Entry]\nType=Application\nName=User notes\nExec=notes-app\nTryExec=rea-missing-tryexec\n", - ); - expect(await inspect()).toMatchObject({ - ok: true, - value: { inventory: { desktop_entry: { name: "Notes" } } }, - }); - expect(await inspect(file)).toMatchObject({ - ok: false, - error: { - reason: "executable_not_found", - program: "rea-missing-tryexec", - }, - }); - await writeFile( - file, - "[Desktop Entry]\nType=Application\nName=User notes\nExec=notes-app\nTryExec=notes-app\n", - ); - expect(await inspect()).toMatchObject({ - ok: true, - value: { inventory: { desktop_entry: { name: "User notes" } } }, - }); - }); - it.each([ { setting: "Hidden=true", exec: true, found: false }, { setting: "Hidden=true", exec: false, found: false },