Skip to content

Commit d17098a

Browse files
test(web): pooled segments cut the pace gap through the track
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dbc114d commit d17098a

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,23 @@ it("omits an empty reset plate but keeps countdowns and banked credits visible",
177177
expect(plate()?.textContent).toBe("1");
178178
});
179179

180+
it("cuts the pace gap through the segment track and keeps the tick inside it", async () => {
181+
setup();
182+
// Five hours before the reset is the start of the window, the right-hand end of the bar.
183+
await using _screen = await render(
184+
<UsageLimitsPooled
185+
presentations={presentations("2026-09-03T14:00:00Z", 0)}
186+
now={Date.parse("2026-09-03T09:00:00Z")}
187+
/>,
188+
);
189+
const segment = page.getByRole("button", { name: /^Alpha:/ }).element();
190+
const tick = segment.querySelector(':scope > span[style*="left"]')!.getBoundingClientRect();
191+
const rect = segment.getBoundingClientRect();
192+
expect(getComputedStyle(segment).backgroundImage).toMatch(/^linear-gradient/);
193+
expect(tick.left).toBeGreaterThanOrEqual(rect.left);
194+
expect(tick.right).toBeLessThanOrEqual(rect.right);
195+
});
196+
180197
it("moves the one limit popover between windows on hover", async () => {
181198
setup();
182199
await using screen = await render(initial());

‎apps/web/test/fixtures/usage-limits-hub/hub.mjs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// Fake CLIProxyAPI management API serving the Limits scenarios in scenarios.json.
22
// Usage: node hub.mjs <state.json> [port]. state.json is {"scenario": "A", "n0": <epoch ms>};
33
// it is re-read on every request, so edit it and press Refresh limits to switch scenarios.
4-
import { readFileSync } from "node:fs";
5-
import { createServer } from "node:http";
4+
import * as NodeFS from "node:fs";
5+
import * as NodeHttp from "node:http";
66

77
const [statePath, port = "18517"] = process.argv.slice(2);
88
if (!statePath) throw new Error("usage: node hub.mjs <state.json> [port]");
9-
const scenarios = JSON.parse(readFileSync(new URL("./scenarios.json", import.meta.url), "utf8"));
9+
const scenarios = JSON.parse(
10+
NodeFS.readFileSync(new URL("./scenarios.json", import.meta.url), "utf8"),
11+
);
1012
const MINUTE = 60_000;
1113

1214
// A window is [usedPercent, minutesFromN0 | null]; null is unknown reset timing.
@@ -52,11 +54,11 @@ const json = (response, body) => {
5254
response.end(JSON.stringify(body));
5355
};
5456

55-
createServer((request, response) => {
57+
NodeHttp.createServer((request, response) => {
5658
let raw = "";
5759
request.on("data", (chunk) => (raw += chunk));
5860
request.on("end", () => {
59-
const { scenario, n0 } = JSON.parse(readFileSync(statePath, "utf8"));
61+
const { scenario, n0 } = JSON.parse(NodeFS.readFileSync(statePath, "utf8"));
6062
const accounts = scenarios[scenario];
6163
if (!accounts) return json(response, { files: [] });
6264
if (request.url.endsWith("/v0/management/auth-files")) {

0 commit comments

Comments
 (0)