From edd7c9320fb21841c0aa74d7c3a0c3be0631dce1 Mon Sep 17 00:00:00 2001 From: luvs01 <27862058+luvs01@users.noreply.github.com> Date: Tue, 8 Sep 2026 04:51:18 +0900 Subject: [PATCH 1/3] test(gui): isolate Santiago timezone fixture in a bounded subprocess (cherry picked from commit 1d8f6ff7e8d48f33c3ce7a1b7118068754bbbe83) --- gui/tests/usage-custom-range.test.tsx | 62 ++++++++++++++++----------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/gui/tests/usage-custom-range.test.tsx b/gui/tests/usage-custom-range.test.tsx index 887c31134e..02df29f3dc 100644 --- a/gui/tests/usage-custom-range.test.tsx +++ b/gui/tests/usage-custom-range.test.tsx @@ -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('.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('.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(); From 8223788bdce6c88efbbd93a65cb0576bb3cd01e5 Mon Sep 17 00:00:00 2001 From: t Date: Tue, 8 Sep 2026 08:20:38 +0900 Subject: [PATCH 2/3] test: prove Santiago child completion and align timeout boundaries --- gui/tests/usage-custom-range.test.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gui/tests/usage-custom-range.test.tsx b/gui/tests/usage-custom-range.test.tsx index 02df29f3dc..ee8572b983 100644 --- a/gui/tests/usage-custom-range.test.tsx +++ b/gui/tests/usage-custom-range.test.tsx @@ -1,5 +1,6 @@ import { afterEach, beforeEach, expect, test } from "bun:test"; import { Window } from "happy-dom"; +import { resolve } from "node:path"; import { act } from "react"; import type { Root } from "react-dom/client"; import { LanguageProvider } from "../src/i18n/provider"; @@ -154,7 +155,7 @@ for (const connected of [false, true]) { } test("America/Santiago midnight DST retains final-day activity and tooltip", async () => { - if (process.env.TZ !== "America/Santiago") { + if (process.env.OCX_USAGE_SANTIAGO_CHILD !== "1" && 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 }; @@ -164,17 +165,20 @@ test("America/Santiago midnight DST retains final-day activity and tooltip", asy "-t", "^America/Santiago midnight DST retains final-day activity and tooltip$", "--timeout", "10000", ], { - env: { ...process.env, TZ: "America/Santiago" }, + cwd: resolve(import.meta.dir, ".."), + env: { ...process.env, TZ: "America/Santiago", OCX_USAGE_SANTIAGO_CHILD: "1" }, 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(child.stdout.toString().split(/\r?\n/), diagnostics).toContain("OCX_SANTIAGO_CASE_COMPLETED"); 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(process.env.TZ).toBe("America/Santiago"); expect(new Date(2026, 8, 6, 0).getHours()).toBe(1); await mount(); await respond(0, "preset-marker"); @@ -192,7 +196,8 @@ test("America/Santiago midnight DST retains final-day activity and tooltip", asy 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); + if (process.env.OCX_USAGE_SANTIAGO_CHILD === "1") console.log("OCX_SANTIAGO_CASE_COMPLETED"); +}, process.env.OCX_USAGE_SANTIAGO_CHILD === "1" ? 10000 : 15000); test("Apply submits inclusive bounds once; Clear restores the held preset without custom cache entries", async () => { await mount(); From ce71d917143ddcbd5675b6ba92d8b1053971cd25 Mon Sep 17 00:00:00 2001 From: t Date: Tue, 8 Sep 2026 08:27:12 +0900 Subject: [PATCH 3/3] test: always isolate Santiago assertions behind the child marker --- gui/tests/usage-custom-range.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/tests/usage-custom-range.test.tsx b/gui/tests/usage-custom-range.test.tsx index ee8572b983..db257ba6b2 100644 --- a/gui/tests/usage-custom-range.test.tsx +++ b/gui/tests/usage-custom-range.test.tsx @@ -155,7 +155,7 @@ for (const connected of [false, true]) { } test("America/Santiago midnight DST retains final-day activity and tooltip", async () => { - if (process.env.OCX_USAGE_SANTIAGO_CHILD !== "1" && process.env.TZ !== "America/Santiago") { + if (process.env.OCX_USAGE_SANTIAGO_CHILD !== "1") { // 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 };