Show resetting state after game end
This commit is contained in:
@@ -65,6 +65,27 @@ async function setup() {
|
||||
}
|
||||
|
||||
describe('Fleet report clock', () => {
|
||||
it('applies game lifecycle events immediately and clears them after an empty report', async () => {
|
||||
const { fleetServers } = await setup();
|
||||
const report = (event: string, time: number) => source.dispatchEvent(new MessageEvent('server-telemetry', {
|
||||
data: JSON.stringify({ serverNow: time, entries: [{ server: 't5_zombie_theater_1', event,
|
||||
receivedAt: new Date(time).toISOString(), players: [] }] })
|
||||
}));
|
||||
emit(epoch, [status(epoch, { players: 1 })]);
|
||||
report('game_end', epoch + 1000);
|
||||
expect(get(fleetServers)[0].game_ended_at).toBe(new Date(epoch + 1000).toISOString());
|
||||
report('heartbeat', epoch + 2000);
|
||||
expect(get(fleetServers)[0].game_ended_at).not.toBeNull();
|
||||
report('game_start', epoch + 3000);
|
||||
expect(get(fleetServers)[0].game_ended_at).toBeNull();
|
||||
report('game_end', epoch + 4000);
|
||||
await vi.advanceTimersByTimeAsync(5000);
|
||||
emit(epoch + 5000, [status(epoch + 5000)]);
|
||||
expect(get(fleetServers)[0].game_ended_at).toBeNull();
|
||||
emit(epoch + 6000, [status(epoch + 6000, { players: 1 })]);
|
||||
expect(get(fleetServers)[0].game_ended_at).toBeNull();
|
||||
});
|
||||
|
||||
it.each([-2500, 60_000])('keeps fresh HTTP and streamed reports healthy with a browser clock offset of %i ms', async (offset) => {
|
||||
vi.setSystemTime(epoch + offset);
|
||||
const { fleetServers, uiNow, refreshFleet } = await setup();
|
||||
|
||||
Reference in New Issue
Block a user