// 3D viewer toolbar vs pcbnew's hidden DOM controls. // // The 3D viewer is a secondary frame: its window div is pointer-events:none so // clicks fall through to #canvas for the C++ hit-test. pcbnew's toolbar combos // (track width / via / grid / zoom) are real DOM ) would // swallow the click. const hits = await page.evaluate(() => { const reg = window.wxElementRegistry!; const all = reg.findAllRendered({ elementType: 'tool' }); const ortho = all.find((t) => t.tooltip?.includes('orthographic'))!; return all .filter((t) => t.parentId === ortho.parentId) .map((t) => { const el = document.elementFromPoint(t.centerX, t.centerY); return { tip: (t.tooltip ?? '').split('\n')[0], x: t.centerX, y: t.centerY, hit: el ? el.tagName : 'none', }; }); }); expect(hits.length, 'viewer toolbar tools must be tracked').toBeGreaterThan(5); const hijacked = hits.filter((h) => h.hit !== 'CANVAS'); expect(hijacked, 'no viewer toolbar tool may be shadowed by a live main-frame DOM control') .toEqual([]); // The covered track-width select must carry the input barrier... const trackSelect = () => page.evaluate(() => { const sel = [...document.querySelectorAll('#main-window select.wx-dom-control')] .find((s) => [...s.options].some((o) => o.text.includes('use netclass width'))); return sel ? { inert: sel.classList.contains('wx-inert') } : null; }); const covered = await trackSelect(); expect(covered, 'pcbnew track-width select must exist').not.toBeNull(); expect(covered!.inert, 'track-width select under the viewer must be input-inert').toBe(true); // ...and the click must reach the viewer's button: toggling ortho // appends " [checked]" to its registry label. const ortho = await findByTooltip(page, 'orthographic', { elementType: 'tool' }); expect(ortho, 'toggleOrtho must be in the registry').not.toBeNull(); expect((ortho!.label ?? '').includes('[checked]')).toBe(false); await page.mouse.click(ortho!.centerX, ortho!.centerY); await expect.poll(async () => { const t = await findByTooltip(page, 'orthographic', { elementType: 'tool' }); return (t?.label ?? '').includes('[checked]'); }, { message: 'clicking toggleOrtho must toggle IT, not a hidden select', timeout: 10000 }) .toBe(true); // Closing the viewer must release the barrier. await page.evaluate(() => { const win = [...document.querySelectorAll('#window-container .window.toplevel')] .find((w) => getComputedStyle(w).display !== 'none' && w.getBoundingClientRect().width > 100)!; (win.querySelector('.window-titlebar-close') as HTMLElement).click(); }); await expect.poll(async () => (await trackSelect())!.inert, { message: 'track-width select must be interactive after the viewer closes', timeout: 10000 }) .toBe(false); }); });