Skip to content

Commit fcf0da2

Browse files
olddonkeyclaude
andauthored
test(quota): move the malformed-plan pool test onto the #3198 contract (#3200)
#3198 deliberately stopped excluding uncalibrated Codex plans from the pool capacity estimate: a plan name the weight map does not list now counts at the baseline seat weight, because exclusion silently overstated the coverage an operator was reading. It updated provider-capacity.test.ts and the GUI tests, but tests/provider-quota.test.ts kept one test asserting the old exclusion shape, so it has failed deterministically on every clean dev checkout since — expecting the malformed-plan account to be dropped (weekly 11, excluded 1, incomplete) where the new contract blends it at baseline (weekly 44, both included, complete coverage). A malformed non-string plan such as `{ tier: "pro" }` is not a separate axis: codexPlanKey normalizes it to undefined exactly like an unlisted name (the tolerance 095a9a5 established), and #3198 routes every undefined key to the baseline weight. Re-splitting malformed from unknown here would reintroduce the distinction #3198 just collapsed, so the test moves to the new contract instead; `unknownPlanAccounts` still records the seat, which is the observable the test's cache half already pins. Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 55400ef commit fcf0da2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎tests/provider-quota.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,12 @@ describe("fetchProviderQuotaReports", () => {
18581858
expect(JSON.stringify(openai?.aggregation)).not.toMatch(/(?:total|consumed|remaining)Weight|projectedUsedPercent/i);
18591859
});
18601860

1861+
// #3198 changed what "tolerate" means here: an uncalibrated plan — a name the weight map
1862+
// does not list, or a malformed non-string value like the `{ tier: "pro" }` below (both
1863+
// normalize to undefined via codexPlanKey) — is now counted at the baseline seat weight
1864+
// instead of being excluded from the aggregate. Exclusion silently overstated coverage;
1865+
// baseline counting is the visibly conservative estimate. The account still shows up in
1866+
// `unknownPlanAccounts` so the operator can see the estimate is conservative for that seat.
18611867
test("pool reports tolerate a malformed persisted plan through cache and aggregation", async () => {
18621868
saveCodexAccountCredential("added", {
18631869
accessToken: "added-access",
@@ -1886,12 +1892,14 @@ describe("fetchProviderQuotaReports", () => {
18861892

18871893
const refreshed = await fetchProviderQuotaReports(config, true);
18881894
const openai = refreshed.reports.find(row => row.provider === "openai");
1889-
expect(openai?.quota.weeklyPercent).toBe(11);
1895+
// Both seats weigh the same (malformed -> baseline, "plus" -> calibrated baseline), so the
1896+
// blend of 77 and 11 lands at 44 — not the 11 the old exclusion contract produced.
1897+
expect(openai?.quota.weeklyPercent).toBe(44);
18901898
expect(openai?.aggregation).toMatchObject({
1891-
includedAccounts: 1,
1892-
excludedAccounts: 1,
1899+
includedAccounts: 2,
1900+
excludedAccounts: 0,
18931901
unknownPlanAccounts: 1,
1894-
incomplete: true,
1902+
incomplete: false,
18951903
currentAccount: { quota: { weeklyPercent: 77 } },
18961904
});
18971905
expect(openai?.aggregation?.currentAccount).not.toHaveProperty("plan");

0 commit comments

Comments
 (0)