assert(command?.program==='/opt/Visual Studio Code/code','quoted Exec program should stay intact');
assert(command.args.slice(0,3).join('|')==='--new-window|/tmp/My Project|--reuse-window',`Exec %F should stay at original position, got ${command.args.join('|')}`);
assert(!command.args.some((arg)=>arg.includes('%')),'Exec field codes should not leak into command args');
assert(ghosttyCommand?.args.join('|')==='--working-directory=/tmp/My Project|--open-uri=/tmp/My Project',`embedded %f/%u should be substituted in place, got ${ghosttyCommand?.args.join('|')}`);
assert(plainCommand?.args.join('|')==='--flag|/tmp/My Project',`target should append when Exec has no placeholder, got ${plainCommand?.args.join('|')}`);
constinstalled=awaitfilterLinuxInstalledApps(['Visual Studio Code','Hidden App','Missing App'],{entries});
assert(installed.length===1&&installed[0]==='Visual Studio Code','filter should return only visible installed apps');
assert(typeoffinderInfo?.iconDataUrl==='string'&&finderInfo.iconDataUrl.startsWith('data:image/png;base64,'),'Finder/file manager should use system PNG icon data URL');
constcodeInfo=appInfos.find((entry)=>entry.name==='Visual Studio Code');
assert(typeofcodeInfo?.iconDataUrl==='string'&&codeInfo.iconDataUrl.startsWith('data:image/png;base64,'),'desktop app should resolve Icon= theme PNG to data URL');
assert(terminalInfo?.iconDataUrl===expectedTerminalIconDataUrl,`Terminal should resolve the TerminalEmulator entry icon, got ${terminalInfo?.iconDataUrl}`);
assert(terminalInfo?.iconDataUrl!==expectedHelperIconDataUrl,'Terminal icon must not resolve to a non-terminal entry whose Exec uses a terminal launcher (loose name/exec match regression)');
assert(terminalFileSpecs[0]?.program==='ghostty','terminal desktop entry should be preferred when present');
assert(terminalFileSpecs[0]?.args.join('|')==='--working-directory=/tmp/My Project|--open-uri=/tmp/My Project',`terminal file target should use dirname, got ${terminalFileSpecs[0]?.args.join('|')}`);
assert(terminalFileSpecs[1]?.program==='xdg-terminal-exec','terminal specs should include xdg-terminal-exec fallback after desktop entry');
assert(terminalFileSpecs[1]?.args.join('|')==='--working-directory|/tmp/My Project',`terminal fallback should use file dirname, got ${terminalFileSpecs[1]?.args.join('|')}`);
assert(fallbackTerminalSpecs.length>=1,'missing terminal desktop entry should include xdg-terminal-exec fallback');
assert(fallbackTerminalSpecs[0]?.program==='xdg-terminal-exec','missing terminal entry should use xdg-terminal-exec first');
assert(fallbackTerminalSpecs[0]?.args.join('|')==='--working-directory|/tmp/My Project',`xdg-terminal-exec fallback should keep working directory args, got ${fallbackTerminalSpecs[0]?.args.join('|')}`);
assert(!fallbackTerminalSpecs.some((spec)=>(spec.args||[]).some((arg)=>arg.includes('helper-script'))),'non-terminal entry using a terminal launcher must not be launched for the generic terminal appId');
constptyxisEntry=parseDesktopEntry([
'[Desktop Entry]',
'Type=Application',
'Name=Ptyxis',
'Exec=ptyxis --working-directory=%f',
'Categories=TerminalEmulator;',
'',
].join('\n'),'/tmp/org.gnome.Ptyxis.desktop');
constterminalEmulatorSpecs=buildLinuxOpenSpecs({
targetPath:'/tmp/My Project',
appId:'terminal',
appName:'Terminal',
targetKind:'project',
entries:[ptyxisEntry,...entries],
env,
});
assert(terminalEmulatorSpecs[0]?.program==='ptyxis',`terminal emulator entry should be preferred, got ${terminalEmulatorSpecs[0]?.program}`);
assert(terminalEmulatorSpecs[0]?.args.join('|')==='--working-directory=/tmp/My Project',`ptyxis should receive working directory, got ${terminalEmulatorSpecs[0]?.args.join('|')}`);
assert(!terminalEmulatorSpecs.some((spec)=>(spec.args||[]).some((arg)=>arg.includes('helper-script'))),'non-terminal entry using a terminal launcher must not be launched when a real terminal emulator entry exists');