fix(usage): commandcode monthly total = consumed + remaining credits

This commit is contained in:
2026-08-22 14:33:53 +07:00
parent bb8d67ba9c
commit 99752a397c
2 changed files with 18 additions and 15 deletions

View File

@@ -113,9 +113,11 @@ describe("getUsageForProvider(commandcode)", () => {
total: 6,
resetAt: new Date(1786379982640).toISOString(),
});
// monthlyCredits/purchasedCredits/freeCredits are remaining balances;
// total = consumed (summary.totalCredits) + remaining, matching the CLI.
expect(usage.quotas["Monthly credits"]).toMatchObject({
used: 0.1,
total: 9.9,
total: 10,
});
});
@@ -194,8 +196,8 @@ describe("parseQuotaData(commandcode)", () => {
},
"Monthly credits": {
used: 0.1,
total: 9.9,
remainingPercentage: 98.99,
total: 10,
remainingPercentage: 99,
resetAt: null,
unit: "$",
},
@@ -205,14 +207,11 @@ describe("parseQuotaData(commandcode)", () => {
name: "5-hour window",
used: 0.05,
total: 3,
remainingPercentage: 98.33,
unit: "$",
});
expect(rows[1]).toMatchObject({
name: "Monthly credits",
used: 0.1,
total: 9.9,
remainingPercentage: 98.99,
total: 10,
});
});
});