Skip to content

Commit 118de68

Browse files
committed
test: add placeholder response methods for codex dump
1 parent d84b24d commit 118de68

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Tests live under `src/__tests__/` and use Vitest.
2121
- Favor event-driven assertions (see `src/__tests__/CodexACPAgent/*`).
2222
- Prefer snapshot-based tests using `toMatchFileSnapshot()` over inline assertions.
23+
- When snapshot response data drifts, prefer replacing that response payload with a stable placeholder over asserting fragile fields.
2324
- Focus on behavior and outputs rather than implementation details.
2425
- Use `/run-codex` skill (`.claude/skills/run-codex/`) to test with real Codex and observe actual events.
2526

src/__tests__/acp-test-utils.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ export interface TestFixture {
4040
getCodexAcpAgent(): CodexAcpServer,
4141

4242
onCodexConnectionEvent(handler: (event: CodexConnectionEvent) => void): void,
43-
getCodexConnectionDump(ignoredFields: string[]): string,
43+
getCodexConnectionDump(ignoredFields: string[], options?: CodexConnectionDumpOptions): string,
4444
clearCodexConnectionDump(): void,
4545

4646
onAcpConnectionEvent(handler: (event: MethodCallEvent) => void): void,
4747
getAcpConnectionDump(ignoredFields: string[]): string,
4848
clearAcpConnectionDump(): void,
4949
}
5050

51+
export interface CodexConnectionDumpOptions {
52+
placeholderResponseMethods?: string[];
53+
}
54+
5155
export interface AcpConnectionConfig {
5256
connection: AgentSideConnection;
5357
events: MethodCallEvent[];
@@ -86,8 +90,29 @@ export function createBaseTestFixture(config: ConnectionConfig): TestFixture {
8690
getCodexAcpClient(): CodexAcpClient {
8791
return codexAcpClient;
8892
},
89-
getCodexConnectionDump(ignoredFields: string[]): string {
90-
return createArrayDump(transportEvents, ignoredFields);
93+
getCodexConnectionDump(ignoredFields: string[], options?: CodexConnectionDumpOptions): string {
94+
const placeholderResponseMethods = new Set(options?.placeholderResponseMethods ?? []);
95+
const pendingRequestMethods: string[] = [];
96+
97+
const filteredEvents = transportEvents.flatMap((event) => {
98+
switch (event.eventType) {
99+
case "request":
100+
pendingRequestMethods.push(event.method);
101+
break;
102+
case "response":
103+
const requestMethod = pendingRequestMethods.shift();
104+
if (requestMethod && placeholderResponseMethods.has(requestMethod)) {
105+
return [{
106+
eventType: "response" as const,
107+
placeholder: requestMethod,
108+
}];
109+
}
110+
break;
111+
}
112+
113+
return [event];
114+
});
115+
return createArrayDump(filteredEvents, ignoredFields);
91116
},
92117
onCodexConnectionEvent(handler: (event: CodexConnectionEvent) => void): void {
93118
codexEventHandlers.push(handler);

0 commit comments

Comments
 (0)