diff --git a/tests/provider-quota.test.ts b/tests/provider-quota.test.ts index ad3a6edbdd4..4b79062f450 100644 --- a/tests/provider-quota.test.ts +++ b/tests/provider-quota.test.ts @@ -1858,6 +1858,12 @@ describe("fetchProviderQuotaReports", () => { expect(JSON.stringify(openai?.aggregation)).not.toMatch(/(?:total|consumed|remaining)Weight|projectedUsedPercent/i); }); + // #3198 changed what "tolerate" means here: an uncalibrated plan — a name the weight map + // does not list, or a malformed non-string value like the `{ tier: "pro" }` below (both + // normalize to undefined via codexPlanKey) — is now counted at the baseline seat weight + // instead of being excluded from the aggregate. Exclusion silently overstated coverage; + // baseline counting is the visibly conservative estimate. The account still shows up in + // `unknownPlanAccounts` so the operator can see the estimate is conservative for that seat. test("pool reports tolerate a malformed persisted plan through cache and aggregation", async () => { saveCodexAccountCredential("added", { accessToken: "added-access", @@ -1886,12 +1892,14 @@ describe("fetchProviderQuotaReports", () => { const refreshed = await fetchProviderQuotaReports(config, true); const openai = refreshed.reports.find(row => row.provider === "openai"); - expect(openai?.quota.weeklyPercent).toBe(11); + // Both seats weigh the same (malformed -> baseline, "plus" -> calibrated baseline), so the + // blend of 77 and 11 lands at 44 — not the 11 the old exclusion contract produced. + expect(openai?.quota.weeklyPercent).toBe(44); expect(openai?.aggregation).toMatchObject({ - includedAccounts: 1, - excludedAccounts: 1, + includedAccounts: 2, + excludedAccounts: 0, unknownPlanAccounts: 1, - incomplete: true, + incomplete: false, currentAccount: { quota: { weeklyPercent: 77 } }, }); expect(openai?.aggregation?.currentAccount).not.toHaveProperty("plan");