test(wizard): cover MOSAIC_GATEWAY_SKIP_NPM_INSTALL gate in gateway-config stage
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

Two cases: fresh install without skipInstall calls installGatewayPackage
exactly once (baseline), and MOSAIC_GATEWAY_SKIP_NPM_INSTALL=1 suppresses
the registry install so a build-from-source gateway (install.sh --dev) is
not overwritten by @latest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMoEx7hfdFGjUiCHuN1RRi
This commit is contained in:
Jason Woltje
2026-07-09 15:20:47 -05:00
parent 4e28966fd0
commit 4b0137325b

View File

@@ -136,6 +136,7 @@ describe('gatewayConfigStage', () => {
delete process.env['MOSAIC_STORAGE_TIER'];
delete process.env['MOSAIC_DATABASE_URL'];
delete process.env['MOSAIC_VALKEY_URL'];
delete process.env['MOSAIC_GATEWAY_SKIP_NPM_INSTALL'];
});
afterEach(() => {
@@ -167,6 +168,36 @@ describe('gatewayConfigStage', () => {
expect(state.gateway?.regeneratedConfig).toBe(true);
});
it('installs the gateway package on fresh install when skipInstall is not set', async () => {
const p = buildPrompter();
const state = makeState('/home/user/.config/mosaic');
const result = await gatewayConfigStage(p, state, {
host: 'localhost',
defaultPort: 14242,
skipInstall: false,
});
expect(result.ready).toBe(true);
expect(daemonState.installPkgCalled).toBe(1);
});
it('honors MOSAIC_GATEWAY_SKIP_NPM_INSTALL=1 and skips the registry install (dev/offline installs)', async () => {
process.env['MOSAIC_GATEWAY_SKIP_NPM_INSTALL'] = '1';
const p = buildPrompter();
const state = makeState('/home/user/.config/mosaic');
const result = await gatewayConfigStage(p, state, {
host: 'localhost',
defaultPort: 14242,
skipInstall: false,
});
// The source-built global gateway must NOT be overwritten by @latest.
expect(result.ready).toBe(true);
expect(daemonState.installPkgCalled).toBe(0);
});
it('does not ask for a gateway API key when provider setup was completed with no key', async () => {
delete process.env['MOSAIC_ASSUME_YES'];
const originalIsTTY = process.stdin.isTTY;