Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
test(web): respect locale and time zone in billing and usage expectations (#1161)
Gener943fdc6f073d
diff --git a/src/web/src/components/community/billing/billing-sheet.dom.test.tsx b/src/web/src/components/community/billing/billing-sheet.dom.test.tsxindex 187e99cea..250d4dcd8 100644--- a/src/web/src/components/community/billing/billing-sheet.dom.test.tsx+++ b/src/web/src/components/community/billing/billing-sheet.dom.test.tsx@@ -17,6 +17,9 @@ vi.mock("@/components/community/shell/community-sheet", () => ({CommunitySheet: ({ open, children, footer }: { open: boolean; children: React.ReactNode; footer: React.ReactNode }) => open ? <div>{children}{footer}</div> : null,}))+const priceFormat = new Intl.NumberFormat(undefined, { style: "currency", currency: "USD" })+const dateFormat = new Intl.DateTimeFormat(undefined, { year: "numeric", month: "short", day: "numeric" })+const free: BillingSummary = {plan: { id: "free", displayName: "Free" }, isFounder: false, subscription: null,offers: [{ priceId: "price_a", plan: { id: "custom-tier", displayName: "Studio" }, botLimit: 10, machineLimit: 5, unitAmount: 2000, currency: "usd", interval: "month", intervalCount: 1 }],@@ -34,7 +37,7 @@ describe("billing sheet", () => {const ui = view(billing)expect(ui.queryByText("Up to 1 online machine")).not.toBeInTheDocument()expect(ui.getByText((_text, el) => el?.tagName === "P" && el.textContent === "Up to 5 online machines")).toBeInTheDocument()- expect(ui.getByText("$20.00 USD / month")).toBeInTheDocument()+ expect(ui.getByText(`${priceFormat.format(20)} USD / month`, { collapseWhitespace: false })).toBeInTheDocument()expect(ui.getByText((_text, element) => element?.tagName === "P" && element.textContent === "Up to 10 active bots")).toBeInTheDocument()expect(ui.getByRole("img", { name: "10 bot slots" })).toBeInTheDocument()fireEvent.click(ui.getByRole("button", { name: "Choose Studio" }))@@ -90,13 +93,15 @@ describe("billing sheet", () => {})it("keeps period-end cancellation separate from an immediate loss of access", () => {const ui = view(state({ data: { ...free, subscription: { plan: free.plan, status: "active", cancelAt: "2026-10-08T00:00:00Z", currentPeriodEnd: "2026-10-10T00:00:00Z", scheduledChange: null } } }))- expect(ui.getByText(/Ends Oct 8, 2026/)).toBeInTheDocument()+ const expectedEnd = dateFormat.format(new Date("2026-10-08T00:00:00Z"))+ expect(ui.getByText(content => content.includes(`Ends ${expectedEnd}`), { collapseWhitespace: false })).toBeInTheDocument()expect(ui.queryByText(/Current period ends/)).toBeNull()expect(ui.getByText(/Your current access stays until then/)).toBeInTheDocument()})it("shows the billing period again after cancellation is revoked", () => {const ui = view(state({ data: { ...free, subscription: { plan: free.plan, status: "active", cancelAt: null, currentPeriodEnd: "2026-10-10T00:00:00Z", scheduledChange: null } } }))- expect(ui.getByText(/Current period ends Oct 10, 2026/)).toBeInTheDocument()+ const expectedPeriodEnd = dateFormat.format(new Date("2026-10-10T00:00:00Z"))+ expect(ui.getByText(content => content.includes(`Current period ends ${expectedPeriodEnd}`), { collapseWhitespace: false })).toBeInTheDocument()expect(ui.queryByText(/Your current access stays until then/)).toBeNull()})diff --git a/src/web/src/components/community/bots/bot-token-usage-chart.dom.test.ts b/src/web/src/components/community/bots/bot-token-usage-chart.dom.test.tsindex 92672ce97..65fcc9fdf 100644--- a/src/web/src/components/community/bots/bot-token-usage-chart.dom.test.ts+++ b/src/web/src/components/community/bots/bot-token-usage-chart.dom.test.ts@@ -39,6 +39,8 @@ import {} from "./bot-token-usage-chart"const unavailable = null+const numberFormat = new Intl.NumberFormat(undefined)+const dayFormat = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric", timeZone: "UTC" })function usageDay(day: string,@@ -117,7 +119,7 @@ describe("BotTokenUsageHeatmap", () => {const heatmap = renderer.getByTestId("community-bot-usage-bot_1")expect(heatmap).toHaveClass("grid-flow-col")expect(heatmap.className).toContain("grid-template-rows:repeat(3")- expect(heatmap).toHaveAttribute("aria-label", expect.stringContaining("610,000,001 known tokens total"))+ expect(heatmap).toHaveAttribute("aria-label", expect.stringContaining(`${numberFormat.format(610_000_001)} known tokens total`))const cells = Array.from(renderer.container.querySelectorAll<HTMLElement>("[data-cell]"))expect(cells).toHaveLength(30)@@ -144,12 +146,12 @@ describe("BotTokenUsageHeatmap", () => {}const renderer = renderUsage(usage)const today = renderer.getByTestId("community-bot-usage-day-bot_1-2026-08-30")- expect(today.getAttribute("aria-label")).toContain("Aug 30")- expect(today.getAttribute("aria-label")).toContain("Input 8")- expect(today.getAttribute("aria-label")).toContain("Output 2")+ expect(today.getAttribute("aria-label")).toContain(dayFormat.format(new Date("2026-08-30T00:00:00Z")))+ expect(today.getAttribute("aria-label")).toContain(`Input ${numberFormat.format(8)}`)+ expect(today.getAttribute("aria-label")).toContain(`Output ${numberFormat.format(2)}`)expect(today.getAttribute("aria-label")).toContain("Cache Unavailable")- expect(text(renderer.container)).toContain("Input 8")- expect(text(renderer.container)).toContain("Output 2")+ expect(text(renderer.container)).toContain(`Input ${numberFormat.format(8)}`)+ expect(text(renderer.container)).toContain(`Output ${numberFormat.format(2)}`)expect(text(renderer.container)).toContain("Cache Unavailable")})@@ -193,11 +195,11 @@ describe("BotTokenUsageHeatmap", () => {expect(newest).toHaveAttribute("aria-pressed", "true")expect(newest).toHaveClass("font-medium")const summary = renderer.getByTestId("community-bot-usage-dialog-summary-bot_1")- expect(text(summary)).toContain("Aug 30")- expect(text(summary)).toContain("Known total 20")- expect(text(summary)).toContain("Input 8")- expect(text(summary)).toContain("Output 2")- expect(text(summary)).toContain("Cache 10")+ expect(text(summary)).toContain(dayFormat.format(new Date("2026-08-30T00:00:00Z")))+ expect(text(summary)).toContain(`Known total ${numberFormat.format(20)}`)+ expect(text(summary)).toContain(`Input ${numberFormat.format(8)}`)+ expect(text(summary)).toContain(`Output ${numberFormat.format(2)}`)+ expect(text(summary)).toContain(`Cache ${numberFormat.format(10)}`)})it("updates mobile values and pressed state when an older date is selected", () => {@@ -216,8 +218,8 @@ describe("BotTokenUsageHeatmap", () => {expect(renderer.getByTestId("community-bot-usage-dialog-day-bot_1-2026-08-30")).toHaveAttribute("aria-pressed", "false")const summary = renderer.getByTestId("community-bot-usage-dialog-summary-bot_1")- expect(text(summary)).toContain("Aug 28")- expect(text(summary)).toContain("Known total 9,000,000")+ expect(text(summary)).toContain(dayFormat.format(new Date("2026-08-28T00:00:00Z")))+ expect(text(summary)).toContain(`Known total ${numberFormat.format(9_000_000)}`)expect(text(summary)).toContain("Cache Unavailable")})@@ -231,14 +233,14 @@ describe("BotTokenUsageHeatmap", () => {})it.each([- { metrics: { input: 129, output: unavailable, cache: 1029 }, total: "1,158", missing: "Output" },- { metrics: { input: 90, output: 24, cache: unavailable }, total: "114", missing: "Cache" },- { metrics: { input: unavailable, output: 24, cache: 23 }, total: "47", missing: "Input" },+ { metrics: { input: 129, output: unavailable, cache: 1029 }, total: 1158, missing: "Output" },+ { metrics: { input: 90, output: 24, cache: unavailable }, total: 114, missing: "Cache" },+ { metrics: { input: unavailable, output: 24, cache: 23 }, total: 47, missing: "Input" },])("labels partial usage as Known total with $missing unavailable", ({ metrics, total, missing }) => {mocks.breakpoint = "mobile"const renderer = renderUsage({ capability: "supported", days: thirtyDays({ 30: metrics }) })const summary = renderer.getByTestId("community-bot-usage-dialog-summary-bot_1")- expect(text(summary)).toContain(`Known total ${total}`)+ expect(text(summary)).toContain(`Known total ${numberFormat.format(total)}`)expect(text(summary)).toContain(`${missing} Unavailable`)expect(renderer.container.querySelector("dialog-description")).toHaveTextContent("Choose a date to view token usage. Known total excludes unavailable values.",@@ -252,7 +254,7 @@ describe("BotTokenUsageHeatmap", () => {days: thirtyDays({ 30: { input: 0, output: 0, cache: 0 } }),})const summary = renderer.getByTestId("community-bot-usage-dialog-summary-bot_1")- expect(text(summary)).toContain("Known total 0")+ expect(text(summary)).toContain(`Known total ${numberFormat.format(0)}`)expect(text(summary)).not.toContain("Unavailable")})})