From 79f2f72f455272dc006ea9625f33539f57dba600 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Fri, 4 Sep 2026 04:32:55 -0400 Subject: [PATCH] test(cli): split task-list brief cases out of the orchestration handler suite The handler suite crossed the 800-line test cap after the retry-ID fix; full lint failed while the changed-code gate stayed green. --- .../orchestration-task-list-brief.test.ts | 57 +++++++++++++++++++ src/cli/handlers/orchestration.test.ts | 50 ---------------- 2 files changed, 57 insertions(+), 50 deletions(-) create mode 100644 src/cli/handlers/orchestration-task-list-brief.test.ts diff --git a/src/cli/handlers/orchestration-task-list-brief.test.ts b/src/cli/handlers/orchestration-task-list-brief.test.ts new file mode 100644 index 00000000000..968b0a979eb --- /dev/null +++ b/src/cli/handlers/orchestration-task-list-brief.test.ts @@ -0,0 +1,57 @@ +import { describe, expect, it, vi } from 'vitest' + +const callMock = vi.fn() + +// Why: isolate the handler's flag-to-param mapping; printResult only writes output. +vi.mock('../format', () => ({ printResult: vi.fn() })) + +import { ORCHESTRATION_HANDLERS } from './orchestration' +import { printResult } from '../format' + +async function runTaskListBrief(): Promise<{ + result: { tasks: { spec: string; spec_truncated: boolean }[] } +}> { + vi.mocked(printResult).mockClear() + await ORCHESTRATION_HANDLERS['orchestration task-list']({ + flags: new Map([['brief', true]]), + client: { call: callMock }, + json: true + } as never) + return vi.mocked(printResult).mock.calls[0]?.[0] as { + result: { tasks: { spec: string; spec_truncated: boolean }[] } + } +} + +describe('orchestration task-list brief output', () => { + it('requests server-side brief and falls back client-side for older runtimes', async () => { + callMock.mockReset().mockResolvedValue({ + result: { + // No spec_truncated field — the pre-brief-runtime signature. + tasks: [{ id: 'task_1', spec: `First line\n${'detail '.repeat(40)}`, status: 'ready' }], + count: 1 + } + }) + + const response = await runTaskListBrief() + + expect(callMock).toHaveBeenCalledWith( + 'orchestration.taskList', + expect.objectContaining({ brief: true }) + ) + expect(response.result.tasks[0].spec).toHaveLength(160) + expect(response.result.tasks[0].spec_truncated).toBe(true) + }) + + it('passes server-abbreviated rows through untouched', async () => { + const serverTasks = [ + { id: 'task_1', spec: 'already brief…', status: 'ready', spec_truncated: true } + ] + callMock.mockReset().mockResolvedValue({ result: { tasks: serverTasks, count: 1 } }) + + const response = await runTaskListBrief() + + // Why: re-abbreviating a server-truncated spec would flip spec_truncated + // back to false (the truncated text fits the cap). + expect(response.result.tasks).toBe(serverTasks) + }) +}) diff --git a/src/cli/handlers/orchestration.test.ts b/src/cli/handlers/orchestration.test.ts index af939ac41e2..fc838654ec8 100644 --- a/src/cli/handlers/orchestration.test.ts +++ b/src/cli/handlers/orchestration.test.ts @@ -878,53 +878,3 @@ describe('orchestration timeout flag validation', () => { expect(callMock).not.toHaveBeenCalled() }) }) - -describe('orchestration task-list brief output', () => { - it('requests server-side brief and falls back client-side for older runtimes', async () => { - callMock.mockReset().mockResolvedValue({ - result: { - // No spec_truncated field — the pre-brief-runtime signature. - tasks: [{ id: 'task_1', spec: `First line\n${'detail '.repeat(40)}`, status: 'ready' }], - count: 1 - } - }) - vi.mocked(printResult).mockClear() - - await ORCHESTRATION_HANDLERS['orchestration task-list']({ - flags: new Map([['brief', true]]), - client: { call: callMock }, - json: true - } as never) - - expect(callMock).toHaveBeenCalledWith( - 'orchestration.taskList', - expect.objectContaining({ brief: true }) - ) - const response = vi.mocked(printResult).mock.calls[0]?.[0] as { - result: { tasks: { spec: string; spec_truncated: boolean }[] } - } - expect(response.result.tasks[0].spec).toHaveLength(160) - expect(response.result.tasks[0].spec_truncated).toBe(true) - }) - - it('passes server-abbreviated rows through untouched', async () => { - const serverTasks = [ - { id: 'task_1', spec: 'already brief…', status: 'ready', spec_truncated: true } - ] - callMock.mockReset().mockResolvedValue({ result: { tasks: serverTasks, count: 1 } }) - vi.mocked(printResult).mockClear() - - await ORCHESTRATION_HANDLERS['orchestration task-list']({ - flags: new Map([['brief', true]]), - client: { call: callMock }, - json: true - } as never) - - const response = vi.mocked(printResult).mock.calls[0]?.[0] as { - result: { tasks: { spec: string; spec_truncated: boolean }[] } - } - // Why: re-abbreviating a server-truncated spec would flip spec_truncated - // back to false (the truncated text fits the cap). - expect(response.result.tasks).toBe(serverTasks) - }) -})