From b024fa08bb650462388de0b53360389d99c44548 Mon Sep 17 00:00:00 2001 From: david raistrick <1108844+keen99@users.noreply.github.com> Date: Tue, 30 Jun 2026 14:04:27 -0400 Subject: [PATCH] tests: scenario rotation integrity check (every 10 rounds) Combat.scenario.test.js: per-10-round assertion - turnOrderIds no dup, currentTurnParticipantId in turnOrderIds. 299/299 phases pass. NOTE: scenario runs against firebase MOCK. Mock updateDoc merges correctly (real ws adapter would clobber per BUG-4 class). So check validates mock shape, not adapter translation. Layer 2 (ws-contract) covers adapter. --- src/tests/Combat.scenario.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tests/Combat.scenario.test.js b/src/tests/Combat.scenario.test.js index 1867cea..e9285aa 100644 --- a/src/tests/Combat.scenario.test.js +++ b/src/tests/Combat.scenario.test.js @@ -256,6 +256,22 @@ test('full 100-round combat scenario', async () => { for (let r = 1; r <= ROUNDS; r++) { await recordAsync(`round ${r} nextTurn`, () => nextTurn()); + // rotation integrity: turnOrderIds no dup, currentTurn valid + if (r % 10 === 0) { + record(`round ${r} rotation-check`, () => { + const enc = currentEncDoc(); + if (!enc) throw new Error('no encounter doc'); + const order = enc.turnOrderIds || []; + const uniq = new Set(order); + if (uniq.size !== order.length) { + throw new Error(`turnOrderIds dup: ${JSON.stringify(order)}`); + } + if (enc.currentTurnParticipantId && !order.includes(enc.currentTurnParticipantId)) { + throw new Error(`currentTurn ${enc.currentTurnParticipantId} not in turnOrderIds`); + } + }); + } + // damage front monster every other round if (r % 2 === 0) record(`round ${r} damage OrcBoss`, () => applyDamage('OrcBoss', 3)); if (r % 3 === 0) record(`round ${r} heal Cleric`, () => applyHeal('Cleric', 2));