Skip to content

Commit 0afd2d6

Browse files
committed
test(logs): expect /api/logs envelope in #725 timezone suite
Merging current dev brought in a bare-array assertion that conflicts with #726's {timeZone,total,logs} response shape.
1 parent ef84c3e commit 0afd2d6

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tests/logs-timezone.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ const config = { providers: [] } as unknown as OcxConfig;
99
* #725: the dashboard rendered request-log timestamps in the BROWSER's zone, so a proxy
1010
* running in KST viewed from a UTC browser reported every request nine hours off.
1111
*
12-
* The zone rides on /api/settings rather than /api/logs. PR #790 put it in a
13-
* `{timeZone, logs}` envelope on /api/logs, which would have broken four tests that read
14-
* that response as an array (server-auth:1623, claude-native-passthrough:119,
15-
* openai-provider-option-e2e:489, server-403-permission-e2e:86) without touching any of them.
12+
* The zone is on /api/settings and also on the /api/logs envelope (`{ timeZone, total, logs }`,
13+
* #726). Consumers that still need the row list go through `logsFromApiBody`.
1614
*/
1715
describe("log timestamp timezone (#725)", () => {
1816
test("/api/settings reports the server's IANA zone", async () => {
@@ -26,13 +24,19 @@ describe("log timestamp timezone (#725)", () => {
2624
expect(() => new Intl.DateTimeFormat("en-US", { timeZone: body.timeZone as string })).not.toThrow();
2725
});
2826

29-
test("/api/logs still returns a bare array", async () => {
30-
// The contract four other suites depend on. If this ever becomes an object, those
31-
// suites fail somewhere far from here, so assert it at the source.
27+
test("/api/logs envelope includes a usable timeZone", async () => {
3228
const url = new URL("http://localhost/api/logs");
3329
const response = await handleManagementAPI(new Request(url), url, config);
3430
expect(response?.status).toBe(200);
35-
expect(Array.isArray(await response!.json())).toBe(true);
31+
const body = await response!.json() as {
32+
timeZone?: unknown;
33+
total?: unknown;
34+
logs?: unknown;
35+
};
36+
expect(typeof body.timeZone).toBe("string");
37+
expect(typeof body.total).toBe("number");
38+
expect(Array.isArray(body.logs)).toBe(true);
39+
expect(() => new Intl.DateTimeFormat("en-US", { timeZone: body.timeZone as string })).not.toThrow();
3640
});
3741
});
3842

0 commit comments

Comments
 (0)