fix(turn): log addParticipants + updateParticipant (logging gaps)
addParticipants + updateParticipant returned log:null → invisible in
combat log. Contract test caught them. Now both return
log:{ message, undo:{ participants }}.
App.js handlers wired (handleAddAllCharacters, handleUpdateParticipant,
handleInlineInitiative) — call logAction on logged mutations.
Logging contract now complete: every mutating combat op produces a log
entry. No gaps. turn.logging.test.js proves it.
238 tests green.
This commit is contained in:
@@ -166,23 +166,38 @@ describe('Logging undo payloads', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Logging: gaps (currently unlogged mutations)', () => {
|
||||
// Document current behavior. addParticipants + updateParticipant return
|
||||
// null log → invisible in combat log. May be intended (bulk/no-op) or bug.
|
||||
describe('Logging: addParticipants + updateParticipant', () => {
|
||||
let e;
|
||||
beforeEach(() => {
|
||||
e = enc([p('a', 10), p('b', 7)]);
|
||||
});
|
||||
|
||||
test('addParticipants returns null log (bulk gap?)', () => {
|
||||
test('addParticipants logs', () => {
|
||||
const r = addParticipants(e, [p('c', 3)]);
|
||||
// Currently null. Document so decision is explicit.
|
||||
expect(r.log).toBeNull();
|
||||
expectLogged(r);
|
||||
});
|
||||
|
||||
test('updateParticipant returns null log (edit gap?)', () => {
|
||||
test('updateParticipant (same slot) logs', () => {
|
||||
const r = updateParticipant(e, 'b', { name: 'B' });
|
||||
// Currently null. Document so decision is explicit.
|
||||
expect(r.log).toBeNull();
|
||||
expectLogged(r);
|
||||
});
|
||||
|
||||
test('updateParticipant (init change) logs', () => {
|
||||
const r = updateParticipant(e, 'b', { initiative: 5 });
|
||||
expectLogged(r);
|
||||
});
|
||||
|
||||
test('addParticipants undo restores prior list', () => {
|
||||
const orig = e.participants.map(p => p.id);
|
||||
const r = addParticipants(e, [p('c', 3)]);
|
||||
const restored = { ...e, ...r.log.undo };
|
||||
expect(restored.participants.map(p => p.id)).toEqual(orig);
|
||||
});
|
||||
|
||||
test('updateParticipant undo restores prior participant', () => {
|
||||
const orig = e.participants.map(p => p.id);
|
||||
const r = updateParticipant(e, 'b', { name: 'B' });
|
||||
const restored = { ...e, ...r.log.undo };
|
||||
expect(restored.participants.map(p => p.id)).toEqual(orig);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user