Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions gui/tests/usage-custom-range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,45 @@ for (const connected of [false, true]) {
}

test("America/Santiago midnight DST retains final-day activity and tooltip", async () => {
const previous = process.env.TZ;
process.env.TZ = "America/Santiago";
try {
expect(new Date(2026, 8, 6, 0).getHours()).toBe(1);
await mount();
await respond(0, "preset-marker");
await enter("2026-09-05T00:00", "2026-09-07T23:59");
await apply();
const gate = requests.at(-1)!;
const data = report(gate, "santiago-marker", "2026-09-07");
data.days = ["2026-09-05", "2026-09-06", "2026-09-07"].map(date => ({
date, requests: date === "2026-09-07" ? 7 : 0, measuredRequests: 0, reportedRequests: 0,
totalTokens: date === "2026-09-07" ? 700 : 0, models: [],
}));
await act(async () => gate.resolve(Response.json(data)));
const active = container.querySelector<HTMLElement>('.heatmap-grid .heatmap-cell:not(.heatmap-cell-0)');
expect(active).not.toBeNull();
await act(async () => active!.dispatchEvent(new testWindow.MouseEvent("mouseover", { bubbles: true })));
expect(container.querySelector(".heatmap-tip-date")?.textContent).toBe("2026-09-07");
expect(container.querySelector(".heatmap-tip")?.textContent).toContain("700");
} finally {
if (previous === undefined) delete process.env.TZ;
else process.env.TZ = previous;
if (process.env.TZ !== "America/Santiago") {
// Restoring an absent TZ can change Bun's effective timezone on Windows.
// Start the DST case in its timezone without mutating this suite's clock.
const timezone = { present: Object.hasOwn(process.env, "TZ"), value: process.env.TZ };
const localTime = new Date(2020, 8, 15, 10, 20).getTime();
const child = Bun.spawnSync([
process.execPath, "test", import.meta.path,
"-t", "^America/Santiago midnight DST retains final-day activity and tooltip$",
"--timeout", "10000",
], {
env: { ...process.env, TZ: "America/Santiago" },
stdout: "pipe", stderr: "pipe", timeout: 12000, killSignal: "SIGKILL",
});
const diagnostics = `${child.stdout.toString()}\n${child.stderr.toString()}`;
expect(child.exitedDueToTimeout, diagnostics).not.toBe(true);
expect(child.signalCode, diagnostics).toBeUndefined();
expect(child.exitCode, diagnostics).toBe(0);
expect({ present: Object.hasOwn(process.env, "TZ"), value: process.env.TZ }).toEqual(timezone);
expect(new Date(2020, 8, 15, 10, 20).getTime()).toBe(localTime);
return;
}
});
expect(new Date(2026, 8, 6, 0).getHours()).toBe(1);
await mount();
await respond(0, "preset-marker");
await enter("2026-09-05T00:00", "2026-09-07T23:59");
await apply();
const gate = requests.at(-1)!;
const data = report(gate, "santiago-marker", "2026-09-07");
data.days = ["2026-09-05", "2026-09-06", "2026-09-07"].map(date => ({
date, requests: date === "2026-09-07" ? 7 : 0, measuredRequests: 0, reportedRequests: 0,
totalTokens: date === "2026-09-07" ? 700 : 0, models: [],
}));
await act(async () => gate.resolve(Response.json(data)));
const active = container.querySelector<HTMLElement>('.heatmap-grid .heatmap-cell:not(.heatmap-cell-0)');
expect(active).not.toBeNull();
await act(async () => active!.dispatchEvent(new testWindow.MouseEvent("mouseover", { bubbles: true })));
expect(container.querySelector(".heatmap-tip-date")?.textContent).toBe("2026-09-07");
expect(container.querySelector(".heatmap-tip")?.textContent).toContain("700");
}, 15000);

test("Apply submits inclusive bounds once; Clear restores the held preset without custom cache entries", async () => {
await mount();
Expand Down
5 changes: 3 additions & 2 deletions tests/codex-integration/codex-auth-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,8 +1447,9 @@ describe("Codex auth context", () => {
// The caller proved admission with one of OUR secrets. That secret must never leave the
// process, so the only acceptable outcome is the stored main credential in its place.
const admissionSecret = "ocx_data_localsecret";
const storedCredential = liveJwt();
writeFileSync(join(testDir, "auth.json"), JSON.stringify({
tokens: { access_token: liveJwt(), account_id: "stored_main_acc" },
tokens: { access_token: storedCredential, account_id: "stored_main_acc" },
}));

const headers = materializeCodexUpstreamAuth(
Expand All @@ -1458,7 +1459,7 @@ describe("Codex auth context", () => {
);

expect(headers.get("authorization")).not.toContain(admissionSecret);
expect(headers.get("authorization")).toBe(`Bearer ${liveJwt()}`);
expect(headers.get("authorization")).toBe(`Bearer ${storedCredential}`);
expect(headers.get("chatgpt-account-id")).toBe("stored_main_acc");
// Unrelated forwarded headers still ride along.
expect(headers.get("openai-beta")).toBe("responses=experimental");
Expand Down
Loading