fix(usage): forward recurring for codebuddy-intl quota packs (#4422)

parseQuotaData had a dedicated case for codebuddy-cn that forwards the
recurring field, but none for codebuddy-intl - even though
getCodeBuddyIntlUsage (open-sse/services/usage/codebuddy-cn.js) returns
the exact same quota shape, bonus packs included. Falling through to the
default case dropped recurring, so one-shot bonus packs (recurring:false,
resetAt = hard expiry) rendered as recurring and showed 'Reset in'
instead of 'Expires in'. Share the codebuddy-cn case with codebuddy-intl.

Fixes #4362
This commit is contained in:
Clayton Tavares authored and decolua committed 2026-09-28 12:55:16 +07:00
1 parent 7bf9317814
commit 1fd208e2b1
2 files changed
+34 -1

No files matched your search

@@ -619,7 +619,8 @@ export function parseQuotaData(provider, data) {
break;
case "codebuddy-cn":
// CodeBuddy CN mixes recurring refill packs ("Monthly"/"Weekly"/...)
case "codebuddy-intl":
// CodeBuddy CN/Intl mix recurring refill packs ("Monthly"/"Weekly"/...)
// with one-shot bonus packs ("Bonus Pack N"). Forward `recurring`
// so the UI can show "Expires in" for bonus packs (whose resetAt is
// a hard expiry, not a refresh) instead of "Reset in".
@@ -0,0 +1,32 @@
// #4362: parseQuotaData had a dedicated `case "codebuddy-cn"` that forwards
// `recurring`, but no case for "codebuddy-intl" — which returns the exact same
// quota shape (open-sse/services/usage/codebuddy-cn.js → getCodeBuddyIntlUsage).
// Falling through to `default` dropped `recurring`, so one-shot bonus packs
// (recurring:false, resetAt = hard expiry) rendered as "Reset in" instead of
// "Expires in".
import { describe, expect, it } from "vitest";
import { parseQuotaData } from "../../src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.js";
const quotas = {
Monthly: { used: 100, total: 1000, resetAt: "2026-11-01T00:00:00Z", recurring: true },
"Bonus Pack 1": { used: 5, total: 50, resetAt: "2026-10-15T00:00:00Z", recurring: false },
};
function byName(parsed, name) {
return parsed.find((q) => q.name === name);
}
describe("parseQuotaData forwards `recurring` for codebuddy-intl (#4362)", () => {
it("marks a bonus pack as non-recurring, like codebuddy-cn does", () => {
const intl = parseQuotaData("codebuddy-intl", { quotas });
expect(byName(intl, "Bonus Pack 1").recurring).toBe(false);
expect(byName(intl, "Monthly").recurring).toBe(true);
});
it("matches codebuddy-cn exactly for the same payload", () => {
const cn = parseQuotaData("codebuddy-cn", { quotas });
const intl = parseQuotaData("codebuddy-intl", { quotas });
expect(intl).toEqual(cn);
});
});