Server-Neustart im laufenden Match: Map wieder laden, volle Leerlauf-Frist ab Start

This commit is contained in:
mregosar committed 2026-10-29 16:09:45 +01:00
1 parent 1b3536452c
commit dfcca1be82
2 files changed
+37 -4

No files matched your search

+31
View File
@@ -477,3 +477,34 @@ test('Spieler verlassen die Lobby, Captain geht über', async () => {
await close();
}
});
test('Neustart im laufenden Match: Map wird wieder geladen, Server läuft die volle Frist', async () => {
const { app, call, close } = await setup({ idleTimeoutMinutes: 30 });
try {
const { id, org, tokens } = await readyWingmanMatch(call, 'bo1');
await call('POST', `/matches/${id}/veto/start`, { token: org });
await playVeto(call, id, { A: tokens.a1, B: tokens.b1 });
await app.manager.poll();
await waitFor(() => app.service.getMatch(id).status === 'live', { label: 'live' });
// Lange nichts los, dann stoppt der Server
const hourAgo = Date.now() - 60 * 60_000;
app.db.prepare('UPDATE matches SET last_activity_at = ? WHERE id = ?').run(hourAgo, id);
await call('POST', `/matches/${id}/server/stop`, { token: org });
await waitFor(() => app.service.serverRow(id).status === 'stopped', { label: 'gestoppt' });
// Neustart durch den Organisator: Server fährt hoch und lädt die Map wieder (Match ist weiter "live")
const res = await call('POST', `/matches/${id}/server/retry`, { token: org });
assert.equal(res.status, 200, JSON.stringify(res.body));
await waitFor(async () => { await app.manager.poll(); return app.service.serverRow(id).status === 'configured'; }, { label: 'neu konfiguriert' });
assert.equal(app.service.getMatch(id).status, 'live');
// Die Abschaltung darf den frisch gestarteten Server nicht sofort wieder stoppen
await app.manager.reap();
assert.equal(app.service.serverRow(id).status, 'configured');
// Nach Ablauf der Frist ab dem Neustart dagegen schon
await app.manager.reap(Date.now() + 31 * 60_000);
assert.equal(app.service.serverRow(id).status, 'stopped');
} finally {
await close();
}
});