Skip to content

Commit 7e289ae

Browse files
test(web): pooled Limits segments narrower than 6px draw no pace mark; fixture README (#22453)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 5d4c202 commit 7e289ae

2 files changed

Lines changed: 83 additions & 6 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,26 @@ it("cuts the pace gap through the segment track and keeps the tick inside it", a
194194
expect(tick.right).toBeLessThanOrEqual(rect.right);
195195
});
196196

197+
it("drops the pace gap and tick when a segment is narrower than 6px", async () => {
198+
setup();
199+
await using _screen = await render(
200+
<UsageLimitsPooled
201+
presentations={presentations("2026-09-03T14:00:00Z", 0)}
202+
now={Date.parse("2026-09-03T11:30:00Z")}
203+
/>,
204+
);
205+
const segment = page.getByRole("button", { name: /^Alpha:/ }).element();
206+
const tick = () => segment.querySelector(':scope > span[style*="left"]');
207+
expect(tick()).not.toBeNull();
208+
// Pooled grid columns have no minimum width; squeeze the segment the way a crowded pool does.
209+
await act(() => {
210+
segment.style.width = "4.5px";
211+
});
212+
await expect.poll(tick).toBeNull();
213+
expect(getComputedStyle(segment).backgroundImage).toBe("none");
214+
expect(getComputedStyle(segment.querySelector(":scope > div > div")!).clipPath).toBe("none");
215+
});
216+
197217
it("moves the one limit popover between windows on hover", async () => {
198218
setup();
199219
await using screen = await render(initial());
Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
11
# Usage limits hub fixture
22

3-
A fake CLIProxyAPI hub that serves the Limits evidence scenarios in `scenarios.json`
4-
(A mixed, B one account per provider, C six long-named Codex accounts, L named accounts,
5-
T forty accounts). Run `node hub.mjs state.json 18517` with `state.json` set to
6-
`{"scenario": "A", "n0": <epoch ms>}`, add `http://127.0.0.1:18517` with any management key
7-
under Settings → Usage limit sources in a dev server, and freeze the browser clock at `n0`.
8-
Edit `state.json` and press Refresh limits to switch scenarios.
3+
A fake CLIProxyAPI hub that serves the Limits evidence scenarios in `scenarios.json`:
4+
5+
| Scenario | Accounts |
6+
| -------- | -------------------------------------------------------------- |
7+
| A | mixed Codex and Claude accounts |
8+
| B | one account per provider |
9+
| C | six long-email Codex accounts |
10+
| L | named accounts (no email, so segments show the auth-file name) |
11+
| T | forty accounts, so pooled segments are 4px wide at 390px |
12+
13+
Reset times are minute offsets from `n0`.
14+
15+
## Rebuild a capture
16+
17+
1. Start a dev server with empty provider homes, so local logins add no accounts:
18+
19+
```sh
20+
CODEX_HOME=$(mktemp -d) CLAUDE_CONFIG_DIR=$(mktemp -d) vp run dev
21+
```
22+
23+
2. Write `state.json` as `{"scenario": "A", "n0": 1792515540000}`. That `n0` is 2026-10-20T16:59:00Z, the instant every published capture uses. Then start the hub:
24+
25+
```sh
26+
node hub.mjs state.json 18517
27+
```
28+
29+
3. Under Settings → Providers → Usage limit sources, add a hub with URL `http://127.0.0.1:18517`, any management key, and label `Team hub`. The composer panel prints that label on every account row.
30+
31+
4. Freeze the browser clock at `n0` from the devtools console:
32+
33+
```js
34+
const T = 1792515540000;
35+
const R = Date;
36+
window.Date = class extends R {
37+
constructor(...a) {
38+
super(...(a.length ? a : [T]));
39+
}
40+
static now() {
41+
return T;
42+
}
43+
};
44+
```
45+
46+
Then re-read the time:
47+
- On the Usage page, select Cost and then Limits again.
48+
- Open the composer panel with `/usage-limits` after freezing.
49+
- The sidebar's relative timestamp picks up the frozen clock on its next minute tick.
50+
51+
5. Viewports and themes: emulate `prefers-color-scheme` light and dark, and wait a few seconds after switching theme or size so transitions and overlay scrollbars settle.
52+
53+
| Surface | Viewport |
54+
| ----------------------------------------------- | ------------------------------------- |
55+
| Usage page | 1440×900 and 390×1500 |
56+
| Scenario T | 390×3100, so the page does not scroll |
57+
| Composer panel, Codex thread (`gpt-6-astra`) | 1440×900 |
58+
| Composer panel, Claude thread (Claude Opus 5.5) | 390×1300 |
59+
60+
6. Edit `state.json` and press Refresh limits to switch scenarios.
61+
62+
## Not from the fixture
63+
64+
- **"Codex: Could not read limits."** That banner comes from the local Codex install, which is unauthenticated with an empty `CODEX_HOME`.
65+
- **"Claude API Key" rows** in the Claude composer panel come from the local Claude install, not the fixture.

0 commit comments

Comments
 (0)