Skip to content

Commit 85debd0

Browse files
committed
test: refine handleExecCommand tests by removing unnecessary assertions
- Removed commented-out assertions and unnecessary test structure to enhance clarity and focus on essential test cases. - Adjusted type assertions for better readability and maintainability in the tests for handleExecCommand.
1 parent eae58b7 commit 85debd0

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

codex-cli/tests/handle-exec-command.test.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ describe("handleExecCommand", () => {
219219
spyCwd.mockRestore();
220220
});
221221

222-
// --- New Tests ---
223-
224222
it("should run in sandbox if policy dictates (macOS)", async () => {
225223
const platformSpy = vi
226224
.spyOn(process, "platform", "get")
@@ -307,10 +305,6 @@ describe("handleExecCommand", () => {
307305
customDenyMessage: "",
308306
});
309307

310-
// Add intermediate assertion (optional, keep if helpful)
311-
expect(mockedCanAutoApprove).toHaveBeenCalledTimes(0);
312-
expect(mockGetCommandConfirmation).toHaveBeenCalledTimes(0);
313-
314308
await handleExecCommand(
315309
mockExecInput,
316310
mockConfig,
@@ -370,18 +364,16 @@ describe("handleExecCommand", () => {
370364
expect(result.metadata?.["error"]).toBeUndefined(); // Access with ['error']
371365
expect(result.additionalItems).toBeDefined();
372366

373-
// --- Adjust type assertion and access path ---
374367
// The item itself has type, role, and content properties
375368
const firstItem = result.additionalItems?.[0] as ResponseInputItem & {
376369
type: "message";
377-
role: string; // Role is at this level
378-
content: Array<{ type: string; text: string }>; // Content is at this level
370+
role: string;
371+
content: Array<{ type: string; text: string }>;
379372
};
380373
// Access content directly from the firstItem
381374
expect(firstItem?.content[0]?.text).toContain(
382375
"No, don't do that — stop for now.",
383376
);
384-
// --- End adjustment ---
385377
});
386378

387379
it("should abort but add custom message if user rejects with NO_CONTINUE", async () => {
@@ -411,16 +403,14 @@ describe("handleExecCommand", () => {
411403
expect(result.outputText).toBe("aborted");
412404
expect(result.additionalItems).toBeDefined();
413405

414-
// --- Adjust type assertion and access path ---
415406
// The item itself has type, role, and content properties
416407
const firstItem = result.additionalItems?.[0] as ResponseInputItem & {
417408
type: "message";
418-
role: string; // Role is at this level
419-
content: Array<{ type: string; text: string }>; // Content is at this level
409+
role: string;
410+
content: Array<{ type: string; text: string }>;
420411
};
421412
// Access content directly from the firstItem
422413
expect(firstItem?.content[0]?.text).toBe(customMessage.trim());
423-
// --- End adjustment ---
424414
});
425415

426416
it('should skip approval prompts for "always approved" commands', async () => {
@@ -661,6 +651,4 @@ describe("handleExecCommand", () => {
661651
platformSpy.mockRestore();
662652
}
663653
});
664-
665-
// --- End New Tests ---
666654
});

0 commit comments

Comments
 (0)