Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/unit/domain-branch-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ test("quotaCache covers normalized windows, stale exhaustion, stats and refresh
quotaCache.stopBackgroundRefresh();
});

test("quotaCache covers empty quotas, invalid dates and fallback percentage normalization", () => {
test("quotaCache distinguishes unknown fractions from reported exhaustion with invalid dates", () => {
let now = 100_000;
Date.now = () => now;

Expand All @@ -354,8 +354,10 @@ test("quotaCache covers empty quotas, invalid dates and fallback percentage norm
remainingPercentage: 0,
usedPercentage: 100,
resetAt: null,
reachedThreshold: true,
reachedThreshold: false,
});
assert.equal(quotaCache.isAccountQuotaExhausted("quota-zero-total"), false);
assert.equal(quotaCache.getQuotaWindowObservation("quota-zero-total", "daily"), null);
assert.equal(quotaCache.getQuotaWindowStatus("quota-zero-total", "unknown"), null);

quotaCache.setQuotaCache("quota-invalid-reset", "cursor", {
Expand All @@ -365,13 +367,19 @@ test("quotaCache covers empty quotas, invalid dates and fallback percentage norm
remainingPercentage: 0,
usedPercentage: 100,
resetAt: "not-a-date",
reachedThreshold: true,
reachedThreshold: false,
});
assert.equal(quotaCache.isAccountQuotaExhausted("quota-invalid-reset"), false);
assert.equal(quotaCache.getQuotaWindowObservation("quota-invalid-reset", "daily"), null);

quotaCache.setQuotaCache("quota-invalid-exhausted", "cursor", {
daily: { remainingPercentage: 0, resetAt: "still-not-a-date" },
});
assert.equal(quotaCache.isAccountQuotaExhausted("quota-invalid-exhausted"), true);
assert.equal(
quotaCache.getQuotaWindowStatus("quota-invalid-exhausted", "daily", 10)?.reachedThreshold,
true
);
});

test("policyEngine evaluates lockout, budget, fallback chains and policy class actions", () => {
Expand Down
Loading