Skip to content

Commit a9a9ed2

Browse files
committed
fix: update print-cli tests to match subagent output suppression
Tests were asserting on removed subagent callbacks. Updated to verify subagent callbacks are undefined in print mode and removed assertions for subagent reasoning/content output.
1 parent 60457a5 commit a9a9ed2

1 file changed

Lines changed: 16 additions & 49 deletions

File tree

packages/code/tests/print-cli.test.ts

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test("startPrintCli handles sendMessage errors and displays usage summary", asyn
229229
consoleErrorSpy.mockRestore();
230230
});
231231

232-
test("subagent content callbacks output correctly", async () => {
232+
test("subagent content callbacks are not registered in print mode", async () => {
233233
const mockAgent = {
234234
sendMessage: vi.fn(),
235235
destroy: vi.fn(),
@@ -253,7 +253,6 @@ test("subagent content callbacks output correctly", async () => {
253253
.spyOn(process.stdout, "write")
254254
.mockImplementation(() => true);
255255

256-
// Mock console.error to suppress stderr output
257256
const consoleErrorSpy = vi
258257
.spyOn(console, "error")
259258
.mockImplementation(() => {});
@@ -262,21 +261,23 @@ test("subagent content callbacks output correctly", async () => {
262261

263262
stdoutSpy.mockClear();
264263

265-
// Test onSubagentAssistantMessageAdded callback (starts subagent response)
266-
// This callback only initializes state, no output
267-
capturedCallbacks?.onSubagentAssistantMessageAdded?.("test-subagent-123");
268-
expect(stdoutSpy).not.toHaveBeenCalled();
264+
// Subagent callbacks should not be registered in print mode
265+
expect(capturedCallbacks?.onSubagentAssistantMessageAdded).toBeUndefined();
266+
expect(capturedCallbacks?.onSubagentAssistantContentUpdated).toBeUndefined();
267+
expect(
268+
capturedCallbacks?.onSubagentAssistantReasoningUpdated,
269+
).toBeUndefined();
270+
expect(capturedCallbacks?.onSubagentUserMessageAdded).toBeUndefined();
269271

270-
// Test onSubagentAssistantContentUpdated callback (streams subagent content)
272+
// Calling them as undefined should not produce output
271273
capturedCallbacks?.onSubagentAssistantContentUpdated?.(
272274
"test-subagent-123",
273275
"Hello from subagent",
274276
"Hello from subagent",
275277
);
276-
expect(stdoutSpy).toHaveBeenCalledWith("\n ");
277-
expect(stdoutSpy).toHaveBeenCalledWith("Hello from subagent");
278+
expect(stdoutSpy).not.toHaveBeenCalled();
278279

279-
// Test onErrorBlockAdded callback
280+
// Error callback still works
280281
capturedCallbacks?.onErrorBlockAdded?.("Something went wrong");
281282
expect(stdoutSpy).toHaveBeenCalledWith("\n❌ Error: Something went wrong\n");
282283

@@ -435,45 +436,11 @@ test("reasoning callbacks output correctly", async () => {
435436
expect(stdoutSpy).not.toHaveBeenCalledWith("\n\n📝 Response:\n");
436437
expect(stdoutSpy).toHaveBeenCalledWith(" world");
437438

438-
// 3. Trigger onSubagentAssistantReasoningUpdated and verify the output
439-
stdoutSpy.mockClear();
440-
capturedCallbacks?.onSubagentAssistantReasoningUpdated?.(
441-
"sub-1",
442-
"Sub thinking...",
443-
"Sub thinking...",
444-
);
445-
expect(stdoutSpy).toHaveBeenCalledWith("\n 💭 Reasoning: ");
446-
expect(stdoutSpy).toHaveBeenCalledWith("Sub thinking...");
447-
448-
// Verify header is not printed again
449-
stdoutSpy.mockClear();
450-
capturedCallbacks?.onSubagentAssistantReasoningUpdated?.(
451-
"sub-1",
452-
" more sub thinking",
453-
"Sub thinking... more sub thinking",
454-
);
455-
expect(stdoutSpy).not.toHaveBeenCalledWith("\n 💭 Reasoning: ");
456-
expect(stdoutSpy).toHaveBeenCalledWith(" more sub thinking");
457-
458-
// 4. Trigger onSubagentAssistantContentUpdated after subagent reasoning and verify the "📝 Response:" header
459-
stdoutSpy.mockClear();
460-
capturedCallbacks?.onSubagentAssistantContentUpdated?.(
461-
"sub-1",
462-
"Sub hello!",
463-
"Sub hello!",
464-
);
465-
expect(stdoutSpy).toHaveBeenCalledWith("\n 📝 Response: ");
466-
expect(stdoutSpy).toHaveBeenCalledWith("Sub hello!");
467-
468-
// Verify header is not printed again
469-
stdoutSpy.mockClear();
470-
capturedCallbacks?.onSubagentAssistantContentUpdated?.(
471-
"sub-1",
472-
" world",
473-
"Sub hello! world",
474-
);
475-
expect(stdoutSpy).not.toHaveBeenCalledWith("\n 📝 Response: ");
476-
expect(stdoutSpy).toHaveBeenCalledWith(" world");
439+
// 3. Subagent callbacks are not registered in print mode
440+
expect(
441+
capturedCallbacks?.onSubagentAssistantReasoningUpdated,
442+
).toBeUndefined();
443+
expect(capturedCallbacks?.onSubagentAssistantContentUpdated).toBeUndefined();
477444

478445
stdoutSpy.mockRestore();
479446
});

0 commit comments

Comments
 (0)