Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/genie-commands/__tests__/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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<typeof spyOn>;

beforeEach(() => {
loadGenieConfigSyncSpy = spyOn(genieConfig, 'loadGenieConfigSync').mockReturnValue({
promptMode: 'append',
} as ReturnType<typeof genieConfig.loadGenieConfigSync>);
});

afterEach(() => {
loadGenieConfigSyncSpy.mockRestore();
});

test('always contains --team-name flag', () => {
const cmd = buildClaudeCommand('genie');
expect(cmd).toContain('--team-name');
Expand Down
Loading