Rework backend #1

Merged
robert merged 86 commits from rework-backend into main 2026-07-01 19:29:34 -04:00
2 changed files with 50 additions and 0 deletions
Showing only changes of commit b2fd06ed17 - Show all commits
+4
View File
@@ -26,6 +26,10 @@
- Future NEXT_TURN continues from jumped position.
- UI button: "Make This Turn"
- Backend action: new endpoint or via generic doc patch.
- RED test: `shared/tests/turn.jump.test.js` (3 tests, 2 RED).
- jump sets currentTurn, future nextTurn continues
- jump to first stays same round
- jump invalid throws (green via TypeError)
## Confirmed bugs (tests written, NOT fixed)
+46
View File
@@ -0,0 +1,46 @@
// JUMP_TURN_TO feature: DM clicks participant → turn jumps → future NEXT_TURN
// continues from jumped position. Missing feature, not bug.
// Test asserts desired behavior = RED (function doesn't exist).
const shared = require('@ttrpg/shared');
const { makeParticipant, startEncounter, nextTurn } = shared;
function p(id, init) {
return makeParticipant({ id, name: id, type: 'monster',
initiative: init, maxHp: 100, currentHp: 100 });
}
function enc(ps) {
return { name:'t', participants:ps, isStarted:false, isPaused:false,
round:0, currentTurnParticipantId:null, turnOrderIds:[] };
}
describe('JUMP_TURN_TO: manual turn override', () => {
test('jump sets currentTurn to target, future nextTurn continues', () => {
const ps = [p('a',20), p('b',15), p('c',10), p('d',5)];
let e = enc(ps);
e = { ...e, ...startEncounter(e).patch };
// current=a
e = { ...e, ...shared.jumpTurnTo(e, 'c').patch };
expect(e.currentTurnParticipantId).toBe('c');
// next turn continues from c → d
e = { ...e, ...nextTurn(e).patch };
expect(e.currentTurnParticipantId).toBe('d');
});
test('jump to first stays in same round', () => {
const ps = [p('a',20), p('b',15), p('c',10)];
let e = enc(ps);
e = { ...e, ...startEncounter(e).patch };
e = { ...e, ...nextTurn(e).patch }; // b
e = { ...e, ...shared.jumpTurnTo(e, 'a').patch };
expect(e.round).toBe(1);
expect(e.currentTurnParticipantId).toBe('a');
});
test('jump to invalid id throws', () => {
const ps = [p('a',20), p('b',15)];
let e = enc(ps);
e = { ...e, ...startEncounter(e).patch };
expect(() => shared.jumpTurnTo(e, 'zzz')).toThrow();
});
});