mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-18 00:56:30 +03:00
Resolve every zoom target in one handler, and stamp each poll generation
Three review findings on #582, all real and all mine. Delegating `.pip` and `.media` to `document` separately meant they could not stop each other: stopPropagation ends bubbling, not siblings on the same target. Clicking the corner inspiration opened the inspiration and then the media handler replaced it with the comp, so the corner was unusable on exactly the cards this PR set out to fix. All three targets now resolve in one delegated listener in priority order, corner before chip before slot, and a chip that is not expand keeps its own click instead of falling through. Flip-back restored the face without clearing what the pending state had added, so a slot that reached stand-in came back carrying "comp pending" beside a fresh label, and one whose art had failed came back still marked unavailable. Restore now clears both, and a slot with no art to restore returns to the honest "artwork unavailable" treatment rather than being labeled inspiration. Converting in place means the same node is reused across flip cycles, and the old poll closure outlived its cycle: a probe from the first flip could settle the second one, stripping the new shimmer and stopping the live poll while the comp stayed hidden. Each run now carries a generation stamp that flip-back bumps, and both probe callbacks bail when it moves. The test covers the corner click against the landed comp, and I confirmed it fails when the priority ordering is removed. Written with AI assistance (Claude Code). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ec189f4536
commit
f2f1cdb0bb
@@ -664,16 +664,30 @@ describe('new-work-e2e: serve-question decision page', () => {
|
||||
await page.waitForSelector(`${front} .media img.comp:not([hidden])`, { timeout: 15000 });
|
||||
await page.click(`${front} .media .chip.expand`);
|
||||
await page.waitForSelector('#lightbox:not([hidden])');
|
||||
assert.ok(
|
||||
await page.$eval('#lightbox img', (img) => Boolean(img.getAttribute('src'))),
|
||||
'the streamed-in comp opens full screen',
|
||||
);
|
||||
const compSrc = await page.$eval('#lightbox img', (img) => img.getAttribute('src'));
|
||||
assert.ok(compSrc, 'the streamed-in comp opens full screen');
|
||||
await page.click('#lightbox');
|
||||
await page.waitForSelector('#lightbox', { state: 'hidden' });
|
||||
|
||||
// Flipping back restores the card as it was dealt.
|
||||
// The corner inspiration opens the catalog art, not the comp behind it.
|
||||
// Both zoom targets are delegated to document, where stopPropagation
|
||||
// cannot stop a sibling listener, so split handlers let the media one
|
||||
// overwrite the lightbox the pip had just filled.
|
||||
const cornerSrc = await page.$eval(`${front} .media .pip img`, (img) => img.getAttribute('src'));
|
||||
await page.click(`${front} .media .pip`);
|
||||
await page.waitForSelector('#lightbox:not([hidden])');
|
||||
const pipSrc = await page.$eval('#lightbox img', (img) => img.getAttribute('src'));
|
||||
assert.notEqual(pipSrc, compSrc, 'the corner opens the inspiration, not the comp');
|
||||
assert.equal(pipSrc, cornerSrc, 'and it is exactly the art in the corner');
|
||||
await page.click('#lightbox');
|
||||
await page.waitForSelector('#lightbox', { state: 'hidden' });
|
||||
|
||||
// Flipping back keeps a comp that already landed, by design, and must
|
||||
// still leave exactly one slot. exitComp is synchronous, so there is
|
||||
// nothing to wait for.
|
||||
await page.click('.bp-opt[data-bp="code"]');
|
||||
await page.waitForTimeout(200);
|
||||
assert.equal(await page.$$eval(`${front} .media`, (els) => els.length), 1, 'still one slot after flipping back');
|
||||
assert.ok(await page.$(`${front} .media img.comp:not([hidden])`), 'the landed comp survives the flip back');
|
||||
await context.close();
|
||||
} finally {
|
||||
await stopDaemon(cwd, key);
|
||||
|
||||
Reference in New Issue
Block a user