Skip to content

Commit de98228

Browse files
committed
fix: Normalize path separators in fuzzy file search test assertions
1 parent 4e2cb26 commit de98228

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

src/__tests__/CodexACPAgent/fuzzy-file-search-events.test.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ import type { ServerNotification } from "../../app-server";
44
import { createCodexMockTestFixture, createTestSessionState, setupPromptAndSendNotifications, type CodexMockTestFixture } from "../acp-test-utils";
55
import { AgentMode } from "../../AgentMode";
66

7+
function normalizePathSeparators<T>(value: T): T {
8+
if (typeof value === "string") {
9+
return value.replace(/\\/g, "/") as unknown as T;
10+
}
11+
if (Array.isArray(value)) {
12+
return value.map(normalizePathSeparators) as unknown as T;
13+
}
14+
if (value && typeof value === "object") {
15+
const out: Record<string, unknown> = {};
16+
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
17+
out[k] = normalizePathSeparators(v);
18+
}
19+
return out as unknown as T;
20+
}
21+
return value;
22+
}
23+
724
describe("CodexEventHandler - fuzzy file search events", () => {
825
let mockFixture: CodexMockTestFixture;
926
const sessionId = "test-session-id";
@@ -55,8 +72,10 @@ describe("CodexEventHandler - fuzzy file search events", () => {
5572

5673
await setupPromptAndSendNotifications(mockFixture, sessionId, sessionState, [updated1, updated2, completed]);
5774

58-
expect(events).toHaveLength(3);
59-
expect(events[0]).toEqual({
75+
const normalizedEvents = normalizePathSeparators(events);
76+
77+
expect(normalizedEvents).toHaveLength(3);
78+
expect(normalizedEvents[0]).toEqual({
6079
method: "sessionUpdate",
6180
args: [
6281
{
@@ -78,7 +97,7 @@ describe("CodexEventHandler - fuzzy file search events", () => {
7897
},
7998
],
8099
});
81-
expect(events[1]).toEqual({
100+
expect(normalizedEvents[1]).toEqual({
82101
method: "sessionUpdate",
83102
args: [
84103
{
@@ -93,7 +112,7 @@ describe("CodexEventHandler - fuzzy file search events", () => {
93112
},
94113
],
95114
});
96-
expect(events[2]).toEqual({
115+
expect(normalizedEvents[2]).toEqual({
97116
method: "sessionUpdate",
98117
args: [
99118
{

0 commit comments

Comments
 (0)