fix: 🐛 wxWdigets popup position

This commit is contained in:
Istvan Matejcsok 2026-06-23 14:32:28 +02:00
commit a4dd0eaf3b
10 changed files with 322 additions and 6 deletions

View file

@ -1,5 +1,6 @@
// wxPopupWindow Tests - Transient popups like KiCad toolbar palettes
import { test, expect, tryLoadApp } from './utils/fixtures';
import { findByLabel, clickByLabel } from './utils/element-tracker';
test.describe('wxPopupWindow Tests', () => {
@ -25,15 +26,49 @@ test.describe('wxPopupWindow Tests', () => {
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
});
test('Tool palette button exists', async ({ page, testLogger }) => {
// Reproduces the DOM-port bug: a wxPopupTransientWindow toolbar palette (like KiCad's
// ACTION_TOOLBAR_PALETTE) must actually render as a floating overlay and be interactive.
// FAILS before the popup-overlay fix (palette never renders → its tool buttons aren't
// visible/clickable), PASSES after.
test('Tool palette opens and a tool button is clickable', async ({ page, testLogger }) => {
await page.goto('/standalone/popup/popup_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
expect(await tryLoadApp(page), 'App should load').toBe(true);
// Open the transient palette (wxPopupTransientWindow::Popup()).
expect(await clickByLabel(page, 'Show Tool Palette'),
'"Show Tool Palette" button should be clickable').toBe(true);
await page.waitForTimeout(500);
await page.screenshot({ path: 'test-results/popup-03-palette.png', fullPage: true });
await page.screenshot({ path: 'test-results/popup-03-palette-open.png', fullPage: true });
expect(loaded, 'Tool palette button should exist').toBe(true);
// The palette must actually render as an overlay: its tool buttons (T1..T9) become visible.
const t1 = await findByLabel(page, 'T1', { visible: true });
expect(t1, 'palette tool button T1 should be visible once the palette opens').not.toBeNull();
// And clicking a tool must fire its handler (logged via EM_ASM console.log in popup_test.cpp).
expect(await clickByLabel(page, 'T1', { visible: true }), 'palette tool T1 should be clickable').toBe(true);
await page.waitForTimeout(300);
expect(
testLogger.consoleLogs.some(l => l.includes('[POPUP] Tool 1 clicked')),
'clicking palette tool T1 should fire its handler'
).toBe(true);
});
// The palette is transient: clicking outside should dismiss it.
test('Tool palette dismisses on outside click', async ({ page }) => {
await page.goto('/standalone/popup/popup_test.html');
expect(await tryLoadApp(page), 'App should load').toBe(true);
expect(await clickByLabel(page, 'Show Tool Palette')).toBe(true);
await page.waitForTimeout(500);
expect(await findByLabel(page, 'T1', { visible: true }),
'palette should open before testing dismiss').not.toBeNull();
// Click far from the palette to dismiss the transient popup.
await page.mouse.click(600, 500);
await page.waitForTimeout(400);
await page.screenshot({ path: 'test-results/popup-03-palette-dismissed.png', fullPage: true });
expect(await findByLabel(page, 'T1', { visible: true }),
'palette should be dismissed (T1 no longer visible) after an outside click').toBeNull();
});
test('Color picker button exists', async ({ page, testLogger }) => {