Skip to content

Commit 4ec7d10

Browse files
committed
test(logs): adapt Claude e2e tests to paginated /api/logs
1 parent b7e59c0 commit 4ec7d10

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

tests/claude-messages-endpoint.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { afterEach, beforeEach, expect, test } from "bun:test";
22
import { managementFetch as fetch } from "./helpers/management-auth";
3+
import { logsFromApiBody } from "./helpers/logs-api";
34
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
45
import { tmpdir } from "node:os";
56
import { join } from "node:path";
@@ -112,9 +113,9 @@ test("POST /v1/messages?beta=true streams an Anthropic-shaped turn end to end",
112113
// Request log regression (live smoke round 2): the tap must see the PRE-translation
113114
// Responses stream — the translated Anthropic stream has no response.completed, which
114115
// used to record a bogus 502 with no usage.
115-
const logs = await (await fetch(new URL("/api/logs", server.url))).json() as {
116+
const logs = logsFromApiBody<{
116117
status: number; model: string; usage?: { inputTokens: number; outputTokens: number }; usageStatus: string;
117-
}[];
118+
}>(await (await fetch(new URL("/api/logs", server.url))).json());
118119
const row = logs.find(l => l.model === "test-model" || l.model === "mock/test-model");
119120
expect(row).toBeDefined();
120121
expect(row!.status).toBe(200);

tests/claude-native-passthrough.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { afterEach, beforeEach, expect, test } from "bun:test";
22
import { managementFetch as fetch } from "./helpers/management-auth";
3+
import { logsFromApiBody } from "./helpers/logs-api";
34
import { mkdtempSync, rmSync } from "node:fs";
45
import { tmpdir } from "node:os";
56
import { join } from "node:path";
@@ -116,8 +117,8 @@ test("unmapped claude model + sk-ant credential passes through verbatim", async
116117
expect(hit.body).toEqual(claudeBody());
117118

118119
// Request log: native provider tag + usage incl. cache detail from the SSE tap.
119-
const logs = await (await fetch(new URL("/api/logs", server.url))).json() as any[];
120-
const row = logs.find(l => l.provider === "anthropic-native");
120+
const logs = logsFromApiBody(await (await fetch(new URL("/api/logs?tail=1", server.url))).json());
121+
const row = logs.at(-1);
121122
expect(row).toBeDefined();
122123
expect(row.status).toBe(200);
123124
expect(row.model).toBe("claude-fable-5");
@@ -168,10 +169,10 @@ test("native passthrough persists conversationId from metadata.user_id", async (
168169
expect(res.status).toBe(200);
169170
await res.text();
170171

171-
const logs = await (await fetch(new URL("/api/logs?tail=1", server.url))).json() as Array<{
172+
const logs = logsFromApiBody<{
172173
provider?: string;
173174
conversationId?: string;
174-
}>;
175+
}>(await (await fetch(new URL("/api/logs?tail=1", server.url))).json());
175176
expect(logs).toHaveLength(1);
176177
expect(logs[0]?.provider).toBe("anthropic-native");
177178
expect(logs[0]?.conversationId).toBe(createHash("sha256").update(userId).digest("hex").slice(0, 32));

0 commit comments

Comments
 (0)