diff --git a/src/genie-commands/__tests__/session.test.ts b/src/genie-commands/__tests__/session.test.ts index ee2434214..b470007c0 100644 --- a/src/genie-commands/__tests__/session.test.ts +++ b/src/genie-commands/__tests__/session.test.ts @@ -7,9 +7,14 @@ * Run with: bun test src/genie-commands/__tests__/session.test.ts */ -import { afterEach, beforeEach, describe, expect, test } from 'bun:test'; +import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test'; import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'; import { basename, join } from 'node:path'; +// Import the real genie-config module so we can spyOn individual exports. +// Using spyOn instead of mock.module avoids leaking an incomplete mock to +// other test files (bun 1.3.x leaks mock.module across parallel workers — +// see PR #1169). Pattern mirrors src/term-commands/init-bootstrap.test.ts. +import * as genieConfig from '../../lib/genie-config.js'; import { HEARTBEAT_TEMPLATE, SOUL_TEMPLATE, scaffoldAgentFiles } from '../../templates/index.js'; import { buildClaudeCommand, getAgentsFilePath, sanitizeWindowName } from '../session.js'; @@ -18,6 +23,23 @@ import { buildClaudeCommand, getAgentsFilePath, sanitizeWindowName } from '../se // ============================================================================ describe('buildClaudeCommand', () => { + // Pin promptMode so tests asserting --append-system-prompt-file don't depend + // on the host's ~/.genie/config.json. Without this, a host configured with + // promptMode: "system" causes buildTeamLeadCommand to emit --system-prompt-file + // instead, failing the append-system-prompt-file assertions below. + // Closes the tail surfaced during PR #1169 QA. + let loadGenieConfigSyncSpy: ReturnType; + + beforeEach(() => { + loadGenieConfigSyncSpy = spyOn(genieConfig, 'loadGenieConfigSync').mockReturnValue({ + promptMode: 'append', + } as ReturnType); + }); + + afterEach(() => { + loadGenieConfigSyncSpy.mockRestore(); + }); + test('always contains --team-name flag', () => { const cmd = buildClaudeCommand('genie'); expect(cmd).toContain('--team-name');