diff --git a/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx b/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx new file mode 100644 index 0000000000000..11cc88294322b --- /dev/null +++ b/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx @@ -0,0 +1,59 @@ +import { describe, expect, it } from "vite-plus/test"; +import { page } from "vite-plus/test/browser"; + +import { render } from "../../../test/render"; +import { UsageModelDialog } from "./UsageModelDialog"; + +describe("UsageModelDialog", () => { + it("exposes each stat as its own label and value to screen readers", async () => { + await using _screen = await render( + {}} + onClose={() => {}} + />, + ); + + const dialog = page.getByRole("dialog"); + for (const [label, value] of [ + ["Cost", "$2.00"], + ["Tokens", "1M"], + ["Per 1M tokens", "$2.00"], + ["Cache hit", "90.0%"], + ] as const) { + await expect + .element(dialog.getByRole("term").getByText(label, { exact: true })) + .toBeVisible(); + await expect + .element(dialog.getByRole("definition").getByText(value, { exact: true }).first()) + .toBeVisible(); + } + }); +}); diff --git a/apps/web/src/components/usage/UsageModelDialog.tsx b/apps/web/src/components/usage/UsageModelDialog.tsx index 0fb6b89ce73a4..2435f5e027de2 100644 --- a/apps/web/src/components/usage/UsageModelDialog.tsx +++ b/apps/web/src/components/usage/UsageModelDialog.tsx @@ -88,14 +88,14 @@ export function UsageModelDialog({
-
+
{stats.map((stat) => (
- {stat.label} - {stat.value} +
{stat.label}
+
{stat.value}
))} -
+ {/* Unpriced cost is unknown, not zero, so its trend shows tokens. */}
- {metric === "cost" ? formatUsd(merged.costUsd) : formatTokens(merged.totalTokens)} - - +

+

{formatCount(merged.sessions)} sessions @@ -688,7 +688,7 @@ function UsageOverview({ )} - +

{showChatGptSharing ? ( @@ -709,8 +709,8 @@ function UsageOverview({ const awaitingData = providerLoading && !providersWithData.has(provider); return (
-
- +
+
- - +
-
- + +

+

); })} @@ -783,7 +783,7 @@ function UsageOverview({

Totals

-
+
-
+
{merged.totalTokens > 0 ? ( @@ -1056,12 +1056,12 @@ function Metric({ }) { return (
- {label} - {label} +
{value} - +
); }