Clean up abandoned matches and fix analytics validation

This commit is contained in:
2026-10-19 15:23:16 +09:00
parent 65c3941e29
commit 6f44ec0d15
14 changed files with 232 additions and 10 deletions
+14
View File
@@ -17,6 +17,20 @@ import { EQUIPMENT_IDS } from '../constants/cosmetics.js';
import { createRoomStore } from '../src/server/rooms.js';
const integration = { skip: !process.env.TEST_MONGODB_URI };
test('orphan cleanup unblocks the same player without blocking independent browsers or live tabs', integration, async () => {
const f = await fixture();
try {
await f.sessions.register(f.a, { requestId: 'bot', matchId: 'bot', mode: 'bot', expectedPreviousSeq: 0 });
assert.equal((await f.service.join('player-b', f.b.gameSessionId)).status, 'queued');
await f.service.cancel('player-b', f.b.gameSessionId);
await assert.rejects(f.service.join('player-a', f.a2.gameSessionId), /MATCH_PENDING/);
f.clock.time += 90000; await f.sessions.touchPresence(f.a);
f.clock.time += 31000; await f.sessions.cleanupDisconnectedMatches();
await assert.rejects(f.service.join('player-a', f.a2.gameSessionId), /MATCH_PENDING/);
f.clock.time += 90000; await f.sessions.cleanupDisconnectedMatches();
assert.equal((await f.service.join('player-a', f.a2.gameSessionId)).status, 'queued');
} finally { await f.close(); }
});
async function pairAndAccept(service: Awaited<ReturnType<typeof createRankedService>>, sessionA: string, sessionB: string) {
const paired = await service.join('player-b', sessionB);
assert.equal(paired.status, 'confirming');