mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-06-05 06:01:31 +00:00
fix(test): de-flake color-picker outside-click (unblocks master) (#1317)
Master CI failing on `test-channel-color-picker-e2e.js` outside-click
step. Test-only fix copied from PR #1300 branch (SHA 7f848848): real
mouse click instead of `element.click()`, wait for listener install.
Test-only change; no production code touched.
Co-authored-by: Kpa-clawbot <bot@kpa-clawbot.local>
This commit is contained in:
@@ -165,14 +165,24 @@ function assert(c, m) { if (!c) throw new Error(m || 'assertion failed'); }
|
||||
await page.evaluate(() =>
|
||||
window.ChannelColorPicker.show('#outsidechan', 100, 100));
|
||||
await page.waitForSelector('.cc-picker-popover');
|
||||
// Click body far away
|
||||
await page.evaluate(() => {
|
||||
document.body.click();
|
||||
});
|
||||
// Wait for the deferred (setTimeout 0) document-level click listener
|
||||
// to be installed before dispatching the outside click. Otherwise the
|
||||
// click races the listener registration and the popover stays open.
|
||||
await page.waitForFunction(() => {
|
||||
const el = document.querySelector('.cc-picker-popover');
|
||||
const rect = el && el.getBoundingClientRect();
|
||||
return rect && rect.width > 0 && rect.height > 0;
|
||||
}, { timeout: 5000 });
|
||||
// Real mouse click at a viewport coordinate that is clearly outside
|
||||
// the popover (popover anchored at 100,100; click at 700,500).
|
||||
// page.mouse.click dispatches PointerEvent + MouseEvent with real
|
||||
// coords, more representative than HTMLElement.click() and reliably
|
||||
// reaches the document-level capture-phase listener.
|
||||
await page.mouse.click(700, 500);
|
||||
await page.waitForFunction(() => {
|
||||
const el = document.querySelector('.cc-picker-popover');
|
||||
return el && el.style.display === 'none';
|
||||
}, { timeout: 3000 });
|
||||
}, { timeout: 15000 });
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
|
||||
Reference in New Issue
Block a user