From a85f43b1fa727009b68646aa40b4d0568f799e6b Mon Sep 17 00:00:00 2001 From: pasmud Date: Tue, 29 Sep 2026 14:02:41 +0000 Subject: [PATCH] test(control-pane): assert the rollback redraws without waiting for a resize The malformed-drawing rollback test took its marker baseline before the malformed poll but only checked it after resizeAgain(). Resize redraws the accepted view on its own, so the test still passed with the immediate rollback redraw removed and the canvas left blank until the operator resized. Record the log position alongside the baseline and assert the retained markers are on the canvas immediately after the malformed poll, before any resize. Scoped to the drawing case, since the events and lanes cases fail before draw() starts and correctly do not redraw. Mutating the implementation confirms the assertion bites: disabling the rollback draw and removing it entirely both fail it with the message "the rollback must redraw the retained markers immediately". Test-only change. control-plane-view-ui 27/27, control-plane-view 13/13, control-plane-view-ui-a11y 18/18, ESLint clean on the test file. --- tests/lib/control-plane-view-ui.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/lib/control-plane-view-ui.test.js b/tests/lib/control-plane-view-ui.test.js index fc433a7dd..9eddb5155 100644 --- a/tests/lib/control-plane-view-ui.test.js +++ b/tests/lib/control-plane-view-ui.test.js @@ -539,11 +539,21 @@ let failures = 0; const eventsBefore = textOf(repaired.elements.get('events')); const lanesBefore = textOf(repaired.elements.get('lanes')); const markersBefore = markerShapes(repaired.context); + const logBeforeMalformed = repaired.context.log.length; await repaired.pollAgain(); assert.strictEqual(textOf(repaired.elements.get('events')), eventsBefore, `${name}: retain previous events`); assert.strictEqual(textOf(repaired.elements.get('lanes')), lanesBefore, `${name}: retain previous lanes`); assert.strictEqual(repaired.elements.get('status').textContent, 'offline'); const drawStart = repaired.context.log.length; + // When the malformed data fails after draw() started, the rollback + // redraws immediately, so the retained markers must be on the canvas + // before any resize. Checking only after resizeAgain() would pass even + // with the immediate redraw removed, since resize redraws the accepted + // view on its own. + if (name === 'drawing') { + assert.deepStrictEqual(markerShapes({ log: repaired.context.log.slice(logBeforeMalformed) }), markersBefore, + `${name}: the rollback must redraw the retained markers immediately`); + } assert.doesNotThrow(() => repaired.resizeAgain(), `${name}: resize must use the last accepted view`); assert.deepStrictEqual(markerShapes({ log: repaired.context.log.slice(drawStart) }), markersBefore); assert.match(repaired.labelOf('c'), /unavailable.*unknown/i);