Skip to content

Commit aba40fc

Browse files
brookscclaude
andcommitted
test: fix navigation and focus tests after rebase
- navigation.test.ts: add focusedPanel to mock store and deep-path setStore handler to match setActiveTask's usage of store.focusedPanel - focus.test.ts: update ai-terminal panel expectation to include agent ID suffix since normalizeTaskPanel now resolves 'ai-terminal' → 'ai-terminal:<id>' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 35389af commit aba40fc

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

src/store/focus.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('focus navigation neighbor map', () => {
204204

205205
expect(mockStore.activeTaskId).toBe('task-1');
206206
expect(mockStore.sidebarFocused).toBe(false);
207-
expect(mockStore.focusedPanel['task-1']).toBe('ai-terminal');
207+
expect(mockStore.focusedPanel['task-1']).toBe('ai-terminal:agent-1');
208208
});
209209

210210
it('clamps split shell-toolbar down-moves to the last available shell', () => {

src/store/navigation.test.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
33
type MockStore = {
44
activeTaskId: string | null;
55
activeAgentId: string | null;
6-
tasks: Record<string, { id: string; agentIds: string[] }>;
6+
tasks: Record<string, { id: string; agentIds: string[]; selectedAgentId?: string }>;
77
terminals: Record<string, unknown>;
88
taskOrder: string[];
99
collapsedTaskOrder: string[];
1010
projects: Array<{ id: string }>;
11+
focusedPanel: Record<string, string>;
1112
};
1213

1314
let mockStore: MockStore;
@@ -22,9 +23,13 @@ vi.mock('./core', () => ({
2223
},
2324
),
2425
setStore: vi.fn((...args: unknown[]) => {
25-
const key = args[0] as keyof MockStore;
26-
const value = args[1];
27-
(mockStore as Record<string, unknown>)[key] = value;
26+
const value = args[args.length - 1];
27+
let target: Record<string, unknown> = mockStore as unknown as Record<string, unknown>;
28+
for (let i = 0; i < args.length - 2; i++) {
29+
const key = args[i] as string;
30+
target = target[key] as Record<string, unknown>;
31+
}
32+
target[args[args.length - 2] as string] = value;
2833
}),
2934
}));
3035

@@ -48,6 +53,7 @@ beforeEach(() => {
4853
taskOrder: ['task-1', 'task-2', 'task-3'],
4954
collapsedTaskOrder: [],
5055
projects: [],
56+
focusedPanel: {},
5157
};
5258
});
5359

@@ -82,6 +88,38 @@ describe('jumpToTask', () => {
8288
expect(mockStore.activeAgentId).toBe('agent-b');
8389
});
8490

91+
it('preserves activeAgentId when it already belongs to the target task', () => {
92+
mockStore.tasks['task-2'].agentIds = ['agent-b', 'agent-b2'];
93+
mockStore.activeAgentId = 'agent-b2';
94+
jumpToTask(1);
95+
expect(mockStore.activeAgentId).toBe('agent-b2');
96+
});
97+
98+
it('prefers the focused AI pane when switching back to a multi-agent task', () => {
99+
mockStore.tasks['task-1'].agentIds = ['agent-a', 'agent-a2'];
100+
mockStore.activeTaskId = 'task-2';
101+
mockStore.activeAgentId = 'agent-b';
102+
mockStore.focusedPanel['task-1'] = 'ai-terminal:agent-a2';
103+
104+
jumpToTask(0);
105+
106+
expect(mockStore.activeTaskId).toBe('task-1');
107+
expect(mockStore.activeAgentId).toBe('agent-a2');
108+
});
109+
110+
it('restores the per-task selected agent when focus is on a non-agent panel', () => {
111+
mockStore.tasks['task-1'].agentIds = ['agent-a', 'agent-a2'];
112+
mockStore.tasks['task-1'].selectedAgentId = 'agent-a2';
113+
mockStore.activeTaskId = 'task-2';
114+
mockStore.activeAgentId = 'agent-b';
115+
mockStore.focusedPanel['task-1'] = 'prompt';
116+
117+
jumpToTask(0);
118+
119+
expect(mockStore.activeTaskId).toBe('task-1');
120+
expect(mockStore.activeAgentId).toBe('agent-a2');
121+
});
122+
85123
it('indexes taskOrder, not collapsed tasks', () => {
86124
// Collapsed tasks live in collapsedTaskOrder and must not be reachable
87125
// by index — the user can't see them, so jumping there would surprise.

0 commit comments

Comments
 (0)