test: deflake map fill gate and wall-locked under load

Map gate (a): measure the fastest of 4 fresh page loads after a warm-up (min-of-N,
TESTING 5.3) against 2x the 1 s DESIGN budget (the documented saturated-host
tolerance), and print every sample; a planted 50 ms/tile decode delay fails it.

Wall editor: an ack dispatch re-renders with the previous server record, and the
panel repopulated every control on every render, so a just-toggled checkbox was
reverted until the wall frame landed (Playwright saw 'did not change its state').
Repopulate only when the record changed (src/panels/wallSync.ts, unit-tested) and
restore the controls when the server refuses an edit.
This commit is contained in:
2026-11-21 17:37:11 +01:00
parent 9c7f9de910
commit ac5a6ac8dc
6 changed files with 160 additions and 35 deletions
+27 -1
View File
@@ -7,7 +7,8 @@ import { initialState, reduce } from '../src/reducer.ts'
import type { ReducerEvent, RootState } from '../src/reducer.ts'
import { parseServerFrame } from '../src/protocol.ts'
import type { Vec2 } from '../src/protocol.ts'
import { selectedWallId, wallOf, wallsOf } from '../src/slices/walls.ts'
import { selectedWallId, wallOf, wallViewFromFrame, wallsOf } from '../src/slices/walls.ts'
import { shouldPopulate, wallFieldsSignature } from '../src/panels/wallSync.ts'
import type { SightDir, WallPreset, WallSwitches } from '../src/wallEditor.ts'
import {
PRESETS,
@@ -300,3 +301,28 @@ describe('local validation mirrors the server rules (5.8, 6.1)', () => {
expect(validateSwitches(switches({ sightDir: dir }))).toBeNull()
})
})
describe('panel synchronisation (#76): an ack render never undoes a toggle', () => {
const view = (id = 1, overrides: Record<string, unknown> = {}) => {
const wall = wallViewFromFrame(wallBody(id, overrides))
if (!wall) throw new Error('bad wall body')
return wall
}
it('populates a newly selected wall, then leaves an identical record alone', () => {
const wall = view()
expect(shouldPopulate(null, wall)).toBe(true)
const populated = { id: wall.id, signature: wallFieldsSignature(wall) }
// The editor's own ack dispatch re-renders with the previous record (same fields, usually the
// same object): repopulating here is what reverted the GM's just-toggled checkbox.
expect(shouldPopulate(populated, view())).toBe(false)
})
it('repopulates when the server record or the selection changes', () => {
const wall = view()
const populated = { id: wall.id, signature: wallFieldsSignature(wall) }
expect(shouldPopulate(populated, view(1, { locked: true, door: true, kind: 'door' }))).toBe(true)
expect(shouldPopulate(populated, view(1, { label: 'railing' }))).toBe(true)
expect(shouldPopulate(populated, view(2))).toBe(true)
})
})