Verify normalized historical tokens across provider card sections

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-10-04 01:06:17 -07:00
1 parent 964c454a12
commit 2c6bfb013b
1 file changed
+24
@@ -15,6 +15,30 @@ describe("provider cost shares", () => {
expect(html).toContain("50% of company budget");
expect(html).not.toContain("of allocation");
});
it("renders normalized mixed-era OpenAI totals consistently across models, windows, and subscription shares", () => {
// The report API combines one inclusive historical row and one exclusive
// receipt-backed row into 40 ordinary + 160 cached + 20 output per group.
const rows = (["metered_api", "subscription_included"] as const).map(billingType => ({
provider: "openai", biller: "openai", model: `test-${billingType}`, billingType,
costCents: 18, inputTokens: 40, cachedInputTokens: 160, outputTokens: 20,
apiRunCount: billingType === "metered_api" ? 2 : 0,
subscriptionRunCount: billingType === "subscription_included" ? 2 : 0,
subscriptionInputTokens: billingType === "subscription_included" ? 40 : 0,
subscriptionCachedInputTokens: billingType === "subscription_included" ? 160 : 0,
subscriptionOutputTokens: billingType === "subscription_included" ? 20 : 0,
}));
const html = renderToStaticMarkup(<ProviderQuotaCard provider="openai" rows={rows}
budgetMonthlyCents={0} totalCompanySpendCents={36} weekSpendCents={36} showDeficitNotch={false}
windowRows={[{ provider: "openai", biller: "openai", window: "5h", windowHours: 5,
costCents: 36, inputTokens: 80, cachedInputTokens: 320, outputTokens: 40 }]} />);
expect(html).toContain('>400</span> in');
expect(html).toContain('>40</span> out');
expect(html.match(/220 tok/g)).toHaveLength(2);
expect(html).toContain("440 tok");
expect(html).toContain("50% of token usage via subscription");
expect(html.match(/title="50% of provider tokens"/g)).toHaveLength(2);
expect(html).toContain("$0.36");
});
it("hides historical spend-to-monthly-budget comparisons for providers and billers", () => {
const common = { budgetMonthlyCents: 1000, totalCompanySpendCents: 20000, weekSpendCents: 0, showBudgetUtilization: false };
const provider = renderToStaticMarkup(<ProviderQuotaCard {...common} provider="openai" rows={[]} windowRows={[]} showDeficitNotch={false} />);