From ba70ea80648dd3a79ab98982b5917e1dbcf0cfb0 Mon Sep 17 00:00:00 2001 From: MattModeCode <168686597+MattModeCode@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:24:26 -0500 Subject: [PATCH] fix: tests must never start the real app; AVENUE_SYNC_NO_LAUNCH switches the launcher off --- src/app/cli.cjs | 2 ++ test/cli.test.cjs | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/cli.cjs b/src/app/cli.cjs index d2ea59b..5f57b61 100755 --- a/src/app/cli.cjs +++ b/src/app/cli.cjs @@ -81,6 +81,8 @@ async function request(method, route, body, timeoutMs) { // Starts the app in the background, with no window and without taking focus. False when it cannot be started here. function launchApp() { + // Tests and scripts that must never start the real app set this. + if (process.env.AVENUE_SYNC_NO_LAUNCH) return false; const { spawn } = require('node:child_process'); let command; if (process.platform === 'darwin') { diff --git a/test/cli.test.cjs b/test/cli.test.cjs index ac3e724..f38db49 100644 --- a/test/cli.test.cjs +++ b/test/cli.test.cjs @@ -39,7 +39,7 @@ async function withApp(overrides, run) { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-cli-')); fs.writeFileSync(path.join(dir, 'api-port'), String(port)); fs.writeFileSync(path.join(dir, 'api-token'), TOKEN); - try { await run({ dir, calls, env: { ...process.env, AVENUE_SYNC_DATA: dir } }); } finally { await api.close(); } + try { await run({ dir, calls, env: { ...process.env, AVENUE_SYNC_DATA: dir, AVENUE_SYNC_NO_LAUNCH: '1' } }); } finally { await api.close(); } } const cli = (env, ...args) => new Promise((resolve) => { @@ -224,6 +224,13 @@ test('every tool schema names only real parameters and never exposes open', () = // ---- Starting the app on demand ---- +test('the real launcher refuses to start anything when AVENUE_SYNC_NO_LAUNCH is set', async () => { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-nolaunch-env-')); + const out = await cli({ ...process.env, AVENUE_SYNC_DATA: dir, AVENUE_SYNC_NO_LAUNCH: '1' }, 'status'); + assert.equal(out.code, 2); + assert.match(out.stderr, /not running/); +}); + test('with the app not running, a command starts it once in the background and then succeeds', async () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'avenue-launch-')); process.env.AVENUE_SYNC_DATA = dir;