Tests: pin the all-wrappers discard shape in the regression guards

"discards variants without hiding the original or animating stale chrome"
asserted the literal `else wrapper.style.display = 'none'`, which the
all-wrappers discard replaced. The guard keeps its intent and its
message, now over the loop, and gains the other half of the same
invariant: a target inside a `.map()` renders one wrapper per item, so
the blanking and the release that undoes it have to cover the same set,
and releasing only the first match leaves the extra items blanked with
their original never restored.

This file lives on main only, so it was not updated when the shape
changed on the fix branch. The rest of it passes as is: the shader
fallback guard still matches through the new epoch check, and the
CYCLING, resumedState, and variants_ready guards are untouched by these
commits.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vau2X53xGTjjTCXWMVBoNY
This commit is contained in:
Paul Bakaus
2026-09-04 14:31:25 +05:00
committed by Abdul Wahab
co-authored by Claude Code
parent 524fb8c950
commit 3b0f46798a
+19 -1
View File
@@ -154,9 +154,27 @@ describe('live-browser.js regression guards', () => {
assert.match(SOURCE, /if \(instant\) barEl\.style\.display = 'none'/);
assert.match(
SOURCE,
/if \(restoreOriginal\) showOriginalDuringDiscard\(cleanupSessionId\);\s*else wrapper\.style\.display = 'none';/,
/if \(restoreOriginal\) showOriginalDuringDiscard\(cleanupSessionId\);\s*else for \(const discardWrapper of discardWrappers\) discardWrapper\.style\.display = 'none';/,
'only non-discard cleanup may blank the wrapper while waiting for HMR',
);
// Same intent, one wrapper or many: a target inside a `.map()` renders one
// wrapper per item, so the blanking and the release that undoes it have to
// cover the same set or the extra items never get their original back.
assert.match(
SOURCE,
/const discardWrappers = discardedWrappers\(cleanupSessionId\);/,
'the discard blanking must collect every wrapper for the session',
);
assert.match(
SOURCE,
/function releaseDiscardedStaticWrappers\(sessionId, wrappers\)[\s\S]{0,400}?for \(const wrapper of set\) releaseDiscardedStaticWrapper\(wrapper\);/,
'the delayed release must unwind every wrapper the blanking covered',
);
assert.doesNotMatch(
SOURCE,
/releaseDiscardedStaticWrapper\(lateWrapper/,
'releasing only the first match leaves the other mapped items blanked forever',
);
});
it('stores live state off the document root and preserves the selected anchor top', () => {