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.
This commit is contained in:
david raistrick
2026-06-30 14:04:27 -04:00
parent 49ea39ea93
commit b024fa08bb
+16
View File
@@ -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));