pcbjam/tests/e2e/bitmapbuttons.spec.ts
Viktor Vaczi 251056e506 Clean up test infrastructure and fix test assertions
- Replace test.skip() with proper expect() assertions when app fails to load
- Remove button-finder utility (no longer needed with element registry)
- Remove kicad tests (tested separately)
- Add findByName/clickByName helpers for bitmap buttons
- Fix element lookups: use clickByName for bitmap buttons, clickTreeItem
  for treebook pages, selectComboItem for wxChoice items
- Add SetName() to shape buttons in bitmapbuttons_test.cpp
- Remove verbose logging from print and threadpool tests
- Update README to reflect current test infrastructure

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 20:18:19 +01:00

111 lines
4.2 KiB
TypeScript

// wxBitmapButton Tests - Bitmap buttons, toggle buttons, disabled states
import { test, expect, tryLoadApp } from './utils/fixtures';
import { clickByLabel, clickByName } from './utils/element-tracker';
test.describe('wxBitmapButton Tests', () => {
test('Bitmap buttons test app loads successfully', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
await page.screenshot({ path: 'test-results/bitmapbuttons-01-loaded.png', fullPage: true });
expect(loaded, 'Bitmap buttons app should load').toBe(true);
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
});
test('Toolbar-style buttons can be clicked', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Click Select tool button using element registry (by name)
await clickByName(page, 'SelectTool');
await page.waitForTimeout(100);
// Click Line tool button
await clickByName(page, 'LineTool');
await page.waitForTimeout(100);
await page.screenshot({ path: 'test-results/bitmapbuttons-02-toolbar-click.png', fullPage: true });
});
test('Toggle buttons can be toggled', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Click F.Cu checkbox to toggle it using element registry
await clickByLabel(page, 'F.Cu');
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/bitmapbuttons-03-toggle.png', fullPage: true });
});
test('Toggle button can toggle multiple layers', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Toggle multiple layer checkboxes using element registry
await clickByLabel(page, 'F.Cu');
await page.waitForTimeout(100);
await clickByLabel(page, 'B.Cu');
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/bitmapbuttons-04-multi-toggle.png', fullPage: true });
});
test('Disabled button can be re-enabled', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Click Toggle Enable State button using element registry
await clickByLabel(page, 'Toggle Enable State');
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/bitmapbuttons-05-enable-toggle.png', fullPage: true });
});
test('Shape buttons display different icons', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Click different shape buttons using element registry (by name)
await clickByName(page, 'Rectangle');
await page.waitForTimeout(100);
await clickByName(page, 'Circle');
await page.waitForTimeout(100);
await clickByName(page, 'Triangle');
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/bitmapbuttons-06-shapes.png', fullPage: true });
});
test('Art Provider buttons display system icons', async ({ page, testLogger }) => {
await page.goto('/standalone/bitmapbuttons/bitmapbuttons_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'App should load').toBe(true);
await page.waitForTimeout(300);
// Click New, Open buttons using element registry (by name)
await clickByName(page, 'New');
await page.waitForTimeout(100);
await clickByName(page, 'Open');
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/bitmapbuttons-07-artprovider.png', fullPage: true });
});
});