- commit
- f5d25ebf71a29c0745d2673d7c6e1c8cba574274
- parent
- cdfcc2666875afc142e05e02b6a226084e3fa41f
- author
- Dami <dami.etoile@gmail.com>
| M | src/ | 6 | ++++-- |
| M | tests/ | 20 | ++++++++++++++++++-- |
@@ -75,7 +75,8 @@ export function createTurnActions(options = {}) {
7575 announceTurn(result);7676 updateUI();7777 render();78- getStage()?.show('proof');78+ const stage = getStage();79+ if (stage?.scene !== 'proof') stage?.show('proof');7980 onRestart(now, result);8081 paintBoardFrame(now);8182 animateBoard(300);@@ -97,7 +98,8 @@ export function createTurnActions(options = {}) {
9798 announceTurn(result);9899 updateUI();99100 render();100- getStage()?.show('proof');101+ const stage = getStage();102+ if (stage?.scene !== 'proof') stage?.show('proof');101103 paintBoardFrame(now);102104 animateBoard(300);103105 } else playSound('undoEmpty');@@ -2,7 +2,7 @@ import test from 'node:test';
22 import assert from 'node:assert/strict';33 import { createTurnActions } from '../src/app/turns.js';44 5-function harness(result = { accepted: true }) {5+function harness(result = { accepted: true }, stage = null) {66 const events = [];77 let state = { won: false };88 const game = {@@ -20,7 +20,7 @@ function harness(result = { accepted: true }) {
2020 };2121 const actions = createTurnActions({2222 getGame: () => game,23- getStage: () => null,23+ getStage: () => stage,2424 getJuice: () => juice,2525 getNow: () => 10,2626 setFeedback: message => events.push(`feedback:${message}`),@@ -61,3 +61,19 @@ test('wait, undo, and restart use the same adapter boundary', () => {
6161 'sync', 'reset', 'consume', 'sync', 'clear', 'sound:restart', 'announce', 'ui', 'render', 'restart-complete', 'paint', 'animate:300',6262 ]);6363 });64+65+test('undo and restart preserve an active proof scene while returning from win', () => {66+ const proofEvents = [];67+ const proofStage = { scene: 'proof', show: scene => proofEvents.push(`show:${scene}`) };68+ const proof = harness({ accepted: true }, proofStage);69+ proof.actions.undo();70+ proof.actions.restart();71+ assert.equal(proofEvents.length, 0);72+73+ const winEvents = [];74+ const winStage = { scene: 'win', show: scene => winEvents.push(`show:${scene}`) };75+ const win = harness({ accepted: true }, winStage);76+ win.actions.undo();77+ win.actions.restart();78+ assert.deepEqual(winEvents, ['show:proof', 'show:proof']);79+});