Skip to content
Open
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
49 changes: 49 additions & 0 deletions apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "@t3tools/contracts";
import { CHATGPT_USAGE_URL } from "@t3tools/shared/usageLimits";
import { describe, expect, it } from "vite-plus/test";
import { page, userEvent } from "vite-plus/test/browser";

import { render } from "../../../test/render";
import { UsageLimitsPooled } from "./UsageLimitsPooled";
Expand Down Expand Up @@ -63,3 +64,51 @@ describe("UsageLimitsPooled ChatGPT usage card", () => {
.toBeVisible();
});
});

describe("UsageLimitsPooled account popover", () => {
it("exposes each detail as its own label and value to screen readers", async () => {
const now = "2026-11-12T14:00:00.000Z";
const claude: ServerProvider = {
...managedChatGpt("claude", "Claude"),
driver: ProviderDriverKind.make("claudeAgent"),
auth: { status: "authenticated", label: "Claude Pro Subscription" },
usageLimits: {
checkedAt: now,
windows: [
{
id: "weekly",
kind: "weekly",
label: "Weekly",
usedPercent: 0,
resetsAt: "2026-11-18T12:00:00.000Z",
windowDurationMins: 10_080,
},
],
},
};
const presentations = new Map([
[
EnvironmentId.make("desk"),
{ entry: { target: { label: "Desk" } }, serverConfig: { providers: [claude] } },
],
]);
await using screen = await render(
<UsageLimitsPooled presentations={presentations} now={Date.parse(now)} />,
);

await userEvent.click(screen.getByRole("button", { name: /% left/ }));
const popover = page.getByRole("dialog");
for (const [label, value] of [
["Plan", "Claude Pro Subscription"],
["Signed in", "Desk"],
["Left", "100%"],
] as const) {
await expect
.element(popover.getByRole("term").getByText(label, { exact: true }))
.toBeVisible();
await expect
.element(popover.getByRole("definition").getByText(value, { exact: true }))
.toBeVisible();
}
});
});
12 changes: 6 additions & 6 deletions apps/web/src/components/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ function AccountName({
function Row({ label, children }: { readonly label: string; readonly children: ReactNode }) {
return (
<div className="grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-3">
<span className="text-muted-foreground">{label}</span>
<span className="min-w-0 text-foreground tabular-nums">{children}</span>
<dt className="text-muted-foreground">{label}</dt>
<dd className="min-w-0 text-foreground tabular-nums">{children}</dd>
</div>
);
}
Expand Down Expand Up @@ -174,13 +174,13 @@ function SegmentPopover({
/>
) : null}
</div>
<div className="flex flex-col gap-1 border-t border-border/60 pt-2.5">
<dl className="flex flex-col gap-1 border-t border-border/60 pt-2.5">
{account.plan ? <Row label="Plan">{account.plan}</Row> : null}
{where ? (
<Row label={account.environments.length > 0 ? "Signed in" : "Via"}>{where}</Row>
) : null}
</div>
<div className="flex flex-col gap-1 border-t border-border/60 pt-2.5">
</dl>
<dl className="flex flex-col gap-1 border-t border-border/60 pt-2.5">
<Row label="Left">{remaining}%</Row>
{window.resetsAt ? (
<Row label="Resets">
Expand All @@ -192,7 +192,7 @@ function SegmentPopover({
{reset && reset.restoresPercent > 0 ? (
<Row label="Restores">+{reset.restoresPercent}% of pool</Row>
) : null}
</div>
</dl>
{choices.length > 0 && redeem ? (
<div className="flex flex-col gap-1.5 border-t border-border/60 pt-2.5 text-muted-foreground">
{choices.map((choice) => (
Expand Down
Loading