|
1 | 1 | import { afterEach, beforeEach, expect, test } from "bun:test"; |
2 | 2 | import { managementFetch as fetch } from "./helpers/management-auth"; |
| 3 | +import { logsFromApiBody } from "./helpers/logs-api"; |
3 | 4 | import { mkdtempSync, rmSync } from "node:fs"; |
4 | 5 | import { tmpdir } from "node:os"; |
5 | 6 | import { join } from "node:path"; |
@@ -116,8 +117,8 @@ test("unmapped claude model + sk-ant credential passes through verbatim", async |
116 | 117 | expect(hit.body).toEqual(claudeBody()); |
117 | 118 |
|
118 | 119 | // 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); |
121 | 122 | expect(row).toBeDefined(); |
122 | 123 | expect(row.status).toBe(200); |
123 | 124 | expect(row.model).toBe("claude-fable-5"); |
@@ -168,10 +169,10 @@ test("native passthrough persists conversationId from metadata.user_id", async ( |
168 | 169 | expect(res.status).toBe(200); |
169 | 170 | await res.text(); |
170 | 171 |
|
171 | | - const logs = await (await fetch(new URL("/api/logs?tail=1", server.url))).json() as Array<{ |
| 172 | + const logs = logsFromApiBody<{ |
172 | 173 | provider?: string; |
173 | 174 | conversationId?: string; |
174 | | - }>; |
| 175 | + }>(await (await fetch(new URL("/api/logs?tail=1", server.url))).json()); |
175 | 176 | expect(logs).toHaveLength(1); |
176 | 177 | expect(logs[0]?.provider).toBe("anthropic-native"); |
177 | 178 | expect(logs[0]?.conversationId).toBe(createHash("sha256").update(userId).digest("hex").slice(0, 32)); |
|
0 commit comments