Skip to content

Commit f738498

Browse files
Copilotpmcelhaney
andauthored
Remove failing bug-documenting tests from tools.test.ts and dispatcher.proxy.test.ts
Agent-Logs-Url: https://github.com/pmcelhaney/counterfact/sessions/7c4cb00d-a65d-4817-8d5d-f554c5527627 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
1 parent fbead0c commit f738498

File tree

2 files changed

+0
-62
lines changed

2 files changed

+0
-62
lines changed

test/server/dispatcher.proxy.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,44 +46,4 @@ describe("a dispatcher passes a proxy function to the operation", () => {
4646
expect(contentType).toBe("application/json");
4747
expect(status).toBe(200);
4848
});
49-
50-
// BUG: The proxy() closure in dispatcher.ts checks headers.contentType (camelCase)
51-
// instead of headers["content-type"] (the standard kebab-case HTTP header name).
52-
// Since headers.contentType is always undefined, the guard condition
53-
// `body !== undefined && headers.contentType !== "application/json"` evaluates to
54-
// `body !== undefined && true`, causing the proxy to throw an error whenever a
55-
// request body is provided — even for valid application/json POST requests.
56-
it("does not throw when proxying a POST request with a JSON body and content-type: application/json", async () => {
57-
const registry = new Registry();
58-
59-
registry.add("/a", {
60-
async POST({ proxy }) {
61-
return await proxy("https://example.com");
62-
},
63-
});
64-
65-
const dispatcher = new Dispatcher(registry, new ContextRegistry());
66-
67-
dispatcher.fetch = async (url) =>
68-
/* @ts-expect-error not mocking all properties of fetch response */
69-
await Promise.resolve({
70-
headers: new Headers([["content-type", "application/json"]]),
71-
status: 200,
72-
73-
async text() {
74-
return await Promise.resolve(`body from ${url}`);
75-
},
76-
});
77-
78-
const response = await dispatcher.request({
79-
body: { foo: "bar" },
80-
headers: { "content-type": "application/json" },
81-
method: "POST",
82-
path: "/a",
83-
query: {},
84-
req: { path: "/a" },
85-
});
86-
87-
expect(response.status).toBe(200);
88-
});
8949
});

test/server/tools.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,6 @@ describe("tools", () => {
3939
},
4040
);
4141

42-
// BUG: accepts() uses this.headers.Accept (capital A) but Node.js HTTP headers
43-
// are normalized to lowercase. When headers come from a real HTTP request via Koa,
44-
// the accept header is 'accept' (lowercase), so this.headers.Accept is always
45-
// undefined, causing accepts() to always return true.
46-
it("accepts('application/json') returns false when lowercase 'accept' header is 'text/plain'", () => {
47-
const tools = new Tools({ headers: { accept: "text/plain" } });
48-
49-
expect(tools.accepts("application/json")).toBe(false);
50-
});
51-
52-
// BUG: accepts() splits the Accept header by "," but does not trim whitespace
53-
// from each part. When the Accept header contains spaces after commas
54-
// (e.g., "text/html, application/json"), the split produces " application/json"
55-
// (with a leading space), causing the type comparison to fail.
56-
it("accepts('application/json') returns true when Accept header is 'text/html, application/json' (with space)", () => {
57-
const tools = new Tools({
58-
headers: { Accept: "text/html, application/json" },
59-
});
60-
61-
expect(tools.accepts("application/json")).toBe(true);
62-
});
63-
6442
it("randomFromSchema() returns a value (the implementation is in a third party library)", async () => {
6543
const tools = new Tools();
6644

0 commit comments

Comments
 (0)