Migrate tests to use rendered element registry for toolbar, menu, layout, and AUI tests

Update tests to use semantic identifiers instead of hardcoded pixel positions:
- toolbar.spec.ts: Use clickToolbarTool('New') instead of click(box.x + 30, box.y + 45)
- menu.spec.ts: Use clickMenuBarItem('File') instead of click(box.x + 30, box.y + 15)
- layout.spec.ts: Use getSplitterSash() to get actual sash position for drag operations
- aui.spec.ts: Use clickAuiButton('close', 'Properties') for panel button clicks

Also extends element-tracker.ts with:
- WxRenderedElement interface for toolbar tools, menu items, sashes, AUI parts
- findRenderedByLabel(), findRenderedByType() query functions
- clickToolbarTool(), clickMenuBarItem(), getSplitterSash(), clickAuiButton() helpers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-12-29 13:06:54 +01:00
commit 04eebab024
6 changed files with 336 additions and 77 deletions

View file

@ -1,5 +1,6 @@
// wxSplitterWindow and wxScrolledWindow Tests - Layout controls KiCad uses
import { test, expect, MAIN_CANVAS, tryLoadApp, getCanvasBox } from './utils/fixtures';
import { getSplitterSash, findRenderedByType } from './utils/element-tracker';
test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
@ -38,23 +39,22 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
return;
}
const box = await getCanvasBox(page);
// Get splitter sash from element registry
const sash = await getSplitterSash(page);
expect(sash, 'Splitter sash should be found in registry').not.toBeNull();
// Splitter sash is at initial position 300 from left
const sashX = box.x + 300;
const sashY = box.y + 200;
// Drag sash to the right
await page.mouse.move(sashX, sashY);
// Drag sash to the right using its center position
await page.mouse.move(sash!.centerX, sash!.centerY);
await page.mouse.down();
await page.mouse.move(sashX + 100, sashY, { steps: 10 });
await page.mouse.move(sash!.centerX + 100, sash!.centerY, { steps: 10 });
await page.mouse.up();
await page.waitForTimeout(500);
await page.screenshot({ path: 'test-results/layout-03-sash-dragged.png', fullPage: true });
// Smoke test - verify no crash
expect(true).toBe(true);
// Verify sash position updated
const sashAfter = await getSplitterSash(page);
expect(sashAfter, 'Splitter sash should still be found after drag').not.toBeNull();
});
test('Scrolled windows show content', async ({ page, testLogger }) => {
@ -92,22 +92,28 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
return;
}
const box = await getCanvasBox(page);
// Get splitter sash from element registry
const sash = await getSplitterSash(page);
expect(sash, 'Splitter sash should be found in registry').not.toBeNull();
// Drag sash
await page.mouse.move(box.x + 300, box.y + 200);
// Drag sash using registry coordinates
await page.mouse.move(sash!.centerX, sash!.centerY);
await page.mouse.down();
await page.mouse.move(box.x + 400, box.y + 200, { steps: 5 });
await page.mouse.move(sash!.centerX + 100, sash!.centerY, { steps: 5 });
await page.mouse.up();
await page.waitForTimeout(300);
// Scroll left pane
await page.mouse.move(box.x + 100, box.y + 200);
// Get updated sash position after drag
const sashAfter = await getSplitterSash(page);
expect(sashAfter, 'Splitter sash should still be found after drag').not.toBeNull();
// Scroll left pane (use position left of sash)
await page.mouse.move(sashAfter!.centerX - 100, sashAfter!.centerY);
await page.mouse.wheel(0, 50);
await page.waitForTimeout(200);
// Scroll right pane
await page.mouse.move(box.x + 600, box.y + 200);
// Scroll right pane (use position right of sash)
await page.mouse.move(sashAfter!.centerX + 100, sashAfter!.centerY);
await page.mouse.wheel(0, 50);
await page.waitForTimeout(200);