Show configured metrics retention (Refs #141)

This commit is contained in:
2026-10-10 17:57:02 -04:00
parent 528ed7f37a
commit d6041e40ef
8 changed files with 62 additions and 3 deletions
+12
View File
@@ -12,6 +12,7 @@ const emptyMatches = {
};
const report = (days: number) => ({
days,
metricsKeepDays: 31,
now: 1000,
since: 0,
summary: totals,
@@ -80,6 +81,13 @@ function setup(fetcher: typeof fetch) {
}
describe('metrics background refresh', () => {
it.each([90, 1, 0])('accepts configured retention of %i days', async (metricsKeepDays) => {
const value = { ...report(7), metricsKeepDays };
const refresh = setup(vi.fn().mockResolvedValue(Response.json(value)));
await refresh.refresh();
expect(refresh.onData).toHaveBeenLastCalledWith(value);
});
it.each([
null,
{ ...report(7).autoscaling, added: -1 },
@@ -297,6 +305,10 @@ describe('metrics background refresh', () => {
maps: [{ ...value.maps[0], running: { average: 1, peak: 1, capturedHours: null } }]
},
{ ...value, autoscalingPaused: undefined },
...[undefined, null, '90', -1, 1.5].map((metricsKeepDays) => ({
...value,
metricsKeepDays
})),
{ ...value, running: undefined },
{ ...value, previous: { ...value.previous, running: undefined } },
{ ...value, maps: [{ ...value.maps[0], policy: { id: 'moon' } }] },