repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/launcher/fixtures/production.mjs
Rawimport assert from 'node:assert/strict';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
// Production service -> detached uwsm boundary, never an installed application.
export default async function launcherProduction({ env, start, stop, waitFor, ipc, setFixture }) {
assert.equal(process.env.NUGULAND_UI_SANDBOX, '1');
const bin = '/tmp/launcher-route-bin';
const capture = '/evidence/launcher-route.jsonl';
mkdirSync(bin);
writeFileSync(`${bin}/uwsm`, `#!/usr/bin/node\nrequire('node:fs').appendFileSync('${capture}', JSON.stringify(process.argv.slice(2)) + '\\n');\n`, { mode: 0o700 });
const fixture = '/project/launcher-route-probe.qml';
writeFileSync(fixture, readFileSync('/project/features/launcher/fixtures/route-probe.qml', 'utf8').replaceAll('import "../../../features/', 'import "./features/'));
const child = start('qs', ['--no-color', '-p', fixture], 'launcher-route-probe', { ...env, PATH: `${bin}:/usr/bin` });
setFixture(fixture, '/evidence/launcher-route-probe.log', child);
try {
await waitFor('production launcher probe loaded', () => readFileSync('/evidence/launcher-route-probe.log', 'utf8').includes('Configuration Loaded'));
const expected = [
['app', '-s', 'a', '--', 'fixture-browser.desktop'],
['app', '-s', 'a', '--', 'fixture-browser.desktop:new-window'],
['app', '-s', 'work.slice', '--', 'fixture-terminal.desktop']
];
for (const [index, which] of ['app', 'action', 'terminal'].entries()) {
const state = JSON.parse(ipc('activate', which));
assert.equal(state.lastInteraction.executed, true);
await waitFor(`${which} reached private uwsm`, () => existsSync(capture) && readFileSync(capture, 'utf8').trim().split('\n').length === index + 1);
const captured = readFileSync(capture, 'utf8').trim().split('\n').map(JSON.parse);
assert.deepEqual(captured[index], expected[index]);
}
} finally {
await stop(child);
}
}