Show resetting state after game end

This commit is contained in:
2026-09-19 22:50:17 -04:00
parent f975911204
commit 5985959882
7 changed files with 88 additions and 9 deletions
+24
View File
@@ -30,6 +30,30 @@ async function setup() {
}
describe('database fleet and container readiness', () => {
it('keeps game_end through occupied polls until game_start or an empty lobby', async () => {
const { inspect, rcon, fanoutStatus, getServer } = await setup();
inspect.mockResolvedValue({ ok: true, state: 'running' });
const reply = (players: number) => ({ ok: true as const, endpoint: { host: 'localhost', port: 28960 }, rawReply: 'status',
status: { players, map: 'zombie_theater', gametype: 'zom', roster: [] } });
rcon.mockResolvedValue(reply(1));
await postTelemetry(gameEvent('game_start', 0, 1, 'managed'));
await postTelemetry(gameEvent('game_end', 10, 1, 'managed'));
const ended = getServer('managed')?.game_ended_at;
expect(ended).toEqual(expect.any(String));
await postTelemetry(gameEvent('heartbeat', 10, 1, 'managed'));
await fanoutStatus();
expect(getServer('managed')?.game_ended_at).toBe(ended);
await postTelemetry(gameEvent('game_start', 0, 1, 'managed'));
expect(getServer('managed')?.game_ended_at).toBeNull();
await postTelemetry(gameEvent('game_end', 10, 1, 'managed'));
rcon.mockResolvedValue(reply(0));
await fanoutStatus();
expect(getServer('managed')).toMatchObject({ game_started_at: null, game_ended_at: null });
rcon.mockResolvedValue(reply(1));
await fanoutStatus();
expect(getServer('managed')?.game_ended_at).toBeNull();
});
it('waits for game_start telemetry after log initialization and player joins', async () => {
const { inspect, rcon, fanoutStatus, getServer } = await setup();
const { GET } = await import('../../src/routes/api/servers/+server.js');