Replace unused server metrics with a count (Refs #139)
CI / checks (push) Successful in 4m51s
CI / checks (push) Successful in 4m51s
This commit is contained in:
@@ -19,7 +19,7 @@ const report = (days: number) => ({
|
||||
matches: emptyMatches,
|
||||
points: [],
|
||||
maps: [],
|
||||
servers: [],
|
||||
sampledServerCount: 0,
|
||||
scope: { game: null, map: null, timeZone: 'UTC' },
|
||||
scopeOptions: { games: [], maps: [] },
|
||||
registeredServerCount: 0,
|
||||
@@ -71,6 +71,26 @@ function setup(fetcher: typeof fetch) {
|
||||
}
|
||||
|
||||
describe('metrics background refresh', () => {
|
||||
it.each([undefined, null, -1, 1.5, '1'])(
|
||||
'rejects an invalid sampled-server count (%s) and accepts a count without server rows',
|
||||
async (sampledServerCount) => {
|
||||
const value = { ...report(7), sampledServerCount: 2 };
|
||||
const refresh = setup(
|
||||
vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(Response.json({ ...value, sampledServerCount }))
|
||||
.mockResolvedValueOnce(Response.json(value))
|
||||
);
|
||||
await refresh.refresh();
|
||||
expect(refresh.onData).not.toHaveBeenCalled();
|
||||
expect(refresh.onError).toHaveBeenLastCalledWith(
|
||||
'The metrics response was incomplete.'
|
||||
);
|
||||
await refresh.refresh();
|
||||
expect(refresh.onData).toHaveBeenLastCalledWith(value);
|
||||
}
|
||||
);
|
||||
|
||||
it('keeps the previous report after failure and accepts a successful retry', async () => {
|
||||
const fetcher = vi
|
||||
.fn()
|
||||
|
||||
Reference in New Issue
Block a user