fix(quota): guard remaining usage percent (#1242)
* fix(quota): guard remaining usage percent * test(quota): cover non-finite usage percents * fix(ui): clean up virtual scroll frame --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
Bohdan Triapitsyn
parent
eb8b9ed715
commit
11e5ab93a9
@@ -32,4 +32,23 @@ describe('toUsageWindow', () => {
|
||||
expect(usageWindow.resetAtFormatted).toBe(formatResetTime(0));
|
||||
expect(usageWindow.resetAfterFormatted).toBe(formatResetTime(0));
|
||||
});
|
||||
|
||||
it('does not derive remaining percent from missing usage', () => {
|
||||
expect(toUsageWindow({ usedPercent: undefined }).remainingPercent).toBeNull();
|
||||
});
|
||||
|
||||
it('does not derive remaining percent from non-finite usage', () => {
|
||||
expect(toUsageWindow({ usedPercent: NaN }).remainingPercent).toBeNull();
|
||||
expect(toUsageWindow({ usedPercent: Infinity }).remainingPercent).toBeNull();
|
||||
expect(toUsageWindow({ usedPercent: -Infinity }).remainingPercent).toBeNull();
|
||||
expect(toUsageWindow({ usedPercent: null }).remainingPercent).toBeNull();
|
||||
});
|
||||
|
||||
it('derives remaining percent from a valid usage value', () => {
|
||||
expect(toUsageWindow({ usedPercent: 60 }).remainingPercent).toBe(40);
|
||||
});
|
||||
|
||||
it('clamps remaining percent to zero when usage exceeds 100', () => {
|
||||
expect(toUsageWindow({ usedPercent: 110 }).remainingPercent).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user