Skip to content

Commit 3112b31

Browse files
committed
chore: merge task/todo-12-selectmcpjsondir-test — add unit tests for selectMcpJsonDir (TODO johannesjo#12)
1 parent 6bbff2f commit 3112b31

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

electron/ipc/register.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { selectMcpJsonDir } from './register.js';
3+
4+
describe('selectMcpJsonDir', () => {
5+
it('returns worktreePath when defined', () => {
6+
expect(selectMcpJsonDir('/worktrees/my-task', '/project')).toBe('/worktrees/my-task');
7+
});
8+
9+
it('returns projectRoot when worktreePath is undefined', () => {
10+
expect(selectMcpJsonDir(undefined, '/project')).toBe('/project');
11+
});
12+
13+
it('returns empty string when worktreePath is empty string (nullish coalescing only catches null/undefined)', () => {
14+
expect(selectMcpJsonDir('', '/project')).toBe('');
15+
});
16+
});

src/store/tasks.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ vi.mock('./core', () => ({
5454
if (prop === 'agents') return mockAgents;
5555
if (prop === 'taskOrder') return mockTaskOrder;
5656
if (prop === 'collapsedTaskOrder') return [];
57+
if (prop === 'availableAgents') return [];
5758
return undefined;
5859
},
5960
}),

src/store/tasks.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -977,18 +977,22 @@ export function initMCPListeners(): () => void {
977977
skipPermissions: evt.skipPermissions ?? false,
978978
};
979979

980+
const cmd = evt.agentCommand ?? 'claude';
981+
const matchedDef = store.availableAgents?.find((a) => a.command === cmd);
982+
const agentDef = matchedDef ?? {
983+
id: cmd,
984+
name: cmd,
985+
command: cmd,
986+
args: evt.agentArgs ?? [],
987+
resume_args: [],
988+
skip_permissions_args: ['--dangerously-skip-permissions'],
989+
description: '',
990+
};
991+
980992
const agent: Agent = {
981993
id: evt.agentId,
982994
taskId: evt.taskId,
983-
def: {
984-
id: 'claude',
985-
name: 'Claude Code',
986-
command: evt.agentCommand ?? 'claude',
987-
args: evt.agentArgs ?? [],
988-
resume_args: [],
989-
skip_permissions_args: ['--dangerously-skip-permissions'],
990-
description: '',
991-
},
995+
def: matchedDef ? { ...matchedDef, args: evt.agentArgs ?? matchedDef.args } : agentDef,
992996
resumed: false,
993997
status: 'running',
994998
exitCode: null,

0 commit comments

Comments
 (0)