Show configured metrics retention (Refs #141)
This commit is contained in:
@@ -439,6 +439,23 @@ describe('historical metrics', () => {
|
||||
expect(result.summary.playerHours * 3600).toBeCloseTo(30);
|
||||
});
|
||||
|
||||
it('updates retention in page loads and refreshes without new samples or cache expiry', async () => {
|
||||
const { fleetSettings, saveFleetSettings } =
|
||||
await import('../../src/lib/server/settings.js');
|
||||
const { GET } = await import('../../src/routes/api/metrics/+server.js');
|
||||
const { load } = await import('../../src/routes/metrics/+page.server.js');
|
||||
vi.spyOn(Date, 'now').mockReturnValue(Date.UTC(2026, 9, 10, 12));
|
||||
const url = new URL('http://localhost/metrics?days=7');
|
||||
const pageData = () => load({ url } as Parameters<typeof load>[0]);
|
||||
expect(await pageData()).toMatchObject({ metricsKeepDays: 31 });
|
||||
for (const metricsKeepDays of [90, 0, 1]) {
|
||||
saveFleetSettings({ ...fleetSettings(), metricsKeepDays });
|
||||
const payload = await (await GET({ url })).json();
|
||||
expect(payload.metricsKeepDays).toBe(metricsKeepDays);
|
||||
expect(payload).toEqual(await pageData());
|
||||
}
|
||||
});
|
||||
|
||||
it('shares the range parser and response contract between SSR and the uncached refresh endpoint', async () => {
|
||||
const { recordMetrics } = await import('../../src/lib/server/fleet/metrics.js');
|
||||
const { GET } = await import('../../src/routes/api/metrics/+server.js');
|
||||
|
||||
Reference in New Issue
Block a user