mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-06 16:34:36 +00:00
fix(usage): derive window names and unify pin selection (#5903)
* fix(usage): derive window names and unify pin selection Quota slots do not identify a period. Derive numeric windows and IDs from reported duration and quota scope; keep unknown lengths neutral. Resolve source defaults and explicit pins through one model, with a persisted empty selection distinct from defaults. * fix(plugins): declare the duration helper host requirement * fix(usage): verify persisted selections at the storage boundary
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
toneFromUsedPct,
|
||||
usedPctOf,
|
||||
windowFromUsedPct,
|
||||
windowFromReportedDuration,
|
||||
} from "./usage.js";
|
||||
|
||||
test("shared usage tones preserve the app threshold contract", () => {
|
||||
@@ -84,3 +85,23 @@ describe("balanceToneFromRemaining", () => {
|
||||
expect(balanceToneFromRemaining(null)).toBe("default");
|
||||
});
|
||||
});
|
||||
|
||||
test.each([
|
||||
[18000, "five_hour", "5-hour", "5h"],
|
||||
[604800, "weekly", "Weekly", "wk"],
|
||||
[7200, "7200s", "2-hour", "2h"],
|
||||
[86400, "86400s", "1-day", "1d"],
|
||||
[90, "90s", "90-second", "90s"],
|
||||
[null, "primary", "Primary limit", ""],
|
||||
])(
|
||||
"duration %s owns the window's identity and both names",
|
||||
(durationSeconds, id, label, shortLabel) => {
|
||||
expect(
|
||||
windowFromReportedDuration({
|
||||
durationSeconds: durationSeconds as number | null,
|
||||
unknown: { id: "primary", label: "Primary limit", shortLabel: "" },
|
||||
utilizationPct: 11,
|
||||
}),
|
||||
).toMatchObject({ id, label, shortLabel, usedPct: 11 });
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user