fix(antigravity): separate weekly and short-window quotas and clean up redundant rows
- Track both weekly and 5-hour session buckets in parseWeeklyQuotaSummary, distinguishing sliding-window limits from multi-day weekly limits - Preserve disabled session buckets at 0% rather than dropping them when weekly limits are reached - Target 5-hour session rows (not weekly rows) during family exhaustion reconciliation in getAntigravityUsage - Suppress synthesized per-model duplicate rows in dashboard normalization when family summaries are present - Add unit test coverage for multi-bucket extraction, reconciliation isolation, and dashboard deduplication
This commit is contained in:
@@ -82,17 +82,97 @@ describe("Antigravity dashboard normalization with weekly quotas", () => {
|
||||
expect(weeklyRows[1].name).toMatch(/Weekly/);
|
||||
});
|
||||
|
||||
it("order: gemini family, claude family, weekly, then other", () => {
|
||||
const quotas = parseQuotaData("antigravity", data);
|
||||
it("order: session, weekly, then other models", () => {
|
||||
const dataWithBoth = {
|
||||
quotas: {
|
||||
gemini_session: {
|
||||
displayName: "Gemini (5h)",
|
||||
used: 100,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-08T05:00:00Z",
|
||||
remainingPercentage: 90,
|
||||
},
|
||||
gemini_weekly: {
|
||||
displayName: "Gemini (Weekly)",
|
||||
used: 250,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-15T00:00:00Z",
|
||||
remainingPercentage: 75,
|
||||
},
|
||||
claude_gpt_session: {
|
||||
displayName: "Claude & GPT (5h)",
|
||||
used: 50,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-08T05:00:00Z",
|
||||
remainingPercentage: 95,
|
||||
},
|
||||
claude_gpt_weekly: {
|
||||
displayName: "Claude & GPT (Weekly)",
|
||||
used: 500,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-14T00:00:00Z",
|
||||
remainingPercentage: 50,
|
||||
},
|
||||
},
|
||||
};
|
||||
const quotas = parseQuotaData("antigravity", dataWithBoth);
|
||||
const keys = quotas.map((q) => q.modelKey);
|
||||
|
||||
const geminiIdx = keys.indexOf("gemini");
|
||||
const claudeIdx = keys.indexOf("claude");
|
||||
const geminiSessionIdx = keys.indexOf("gemini_session");
|
||||
const geminiWeeklyIdx = keys.indexOf("gemini_weekly");
|
||||
const claudeSessionIdx = keys.indexOf("claude_gpt_session");
|
||||
const claudeWeeklyIdx = keys.indexOf("claude_gpt_weekly");
|
||||
|
||||
expect(geminiIdx).toBeLessThan(geminiWeeklyIdx);
|
||||
expect(claudeIdx).toBeLessThan(claudeWeeklyIdx);
|
||||
expect(geminiSessionIdx).toBeLessThan(geminiWeeklyIdx);
|
||||
expect(claudeSessionIdx).toBeLessThan(claudeWeeklyIdx);
|
||||
});
|
||||
|
||||
it("excludes redundant duplicates when individual models mirror weekly reset and summary is present", () => {
|
||||
// Exact scenario from Christian's account:
|
||||
const liveLikeData = {
|
||||
quotas: {
|
||||
"gemini-3.8-flash-high": { used: 1000, total: 1000, remainingPercentage: 0, resetAt: "2026-09-23T06:00:17Z", displayName: "Gemini 3.8 Flash (High)" },
|
||||
"claude-sonnet-4-6": { used: 1000, total: 1000, remainingPercentage: 0, resetAt: "2026-09-20T19:00:21Z", displayName: "Claude 3.7 Sonnet" },
|
||||
"gpt-oss-120b-medium": { used: 1000, total: 1000, remainingPercentage: 0, resetAt: "2026-09-20T19:00:21Z", displayName: "GPT-OSS 120B (Medium)" },
|
||||
"gemini-3.1-flash-image": { used: 1000, total: 1000, remainingPercentage: 0, resetAt: "2026-09-23T06:00:17Z", displayName: "Gemini 3.1 Flash Image" },
|
||||
gemini_weekly: {
|
||||
displayName: "Gemini (Weekly)",
|
||||
used: 1000,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-23T06:00:17Z",
|
||||
remainingPercentage: 0,
|
||||
},
|
||||
claude_gpt_weekly: {
|
||||
displayName: "Claude & GPT (Weekly)",
|
||||
used: 807,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-24T18:09:46Z",
|
||||
remainingPercentage: 19.3,
|
||||
},
|
||||
claude_gpt_session: {
|
||||
displayName: "Claude & GPT (5h)",
|
||||
used: 1000,
|
||||
total: 1000,
|
||||
resetAt: "2026-09-20T19:00:21Z",
|
||||
remainingPercentage: 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const quotas = parseQuotaData("antigravity", liveLikeData);
|
||||
const names = quotas.map((q) => q.name);
|
||||
|
||||
// Should contain unique usages:
|
||||
expect(names).toContain("Claude & GPT (5h)");
|
||||
expect(names).toContain("Claude & GPT (Weekly)");
|
||||
expect(names).toContain("Gemini (Weekly)");
|
||||
expect(names).toContain("Gemini 3.1 Flash Image");
|
||||
|
||||
// Should NOT contain redundant duplicate entries:
|
||||
expect(names).not.toContain("Gemini (Flash / Pro)"); // duplicate of Gemini (Weekly)
|
||||
expect(names).not.toContain("Claude (Sonnet / Opus)"); // duplicate of Claude & GPT (5h)
|
||||
expect(names).not.toContain("GPT-OSS 120B (Medium)"); // covered by Claude & GPT family
|
||||
expect(quotas).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("works with no weekly keys present (backward compat)", () => {
|
||||
|
||||
Reference in New Issue
Block a user