pcbjam/tests/e2e/wxwidgets.spec.ts
Viktor Vaczi 3f67fed173 Add Playwright test infrastructure for wxWidgets WASM port
- Add tests/ directory with Playwright e2e tests
- Add minimal wxWidgets WASM test application
- Add build script for test app (scripts/build-wasm-test.sh)
- Update wxWidgets submodule with WASM build fixes
- Update .gitignore for test artifacts

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 13:10:05 +01:00

70 lines
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('wxWidgets WASM', () => {
test('app loads without JavaScript errors', async ({ page }) => {
const errors: string[] = [];
page.on('pageerror', err => errors.push(err.message));
page.on('console', msg => {
if (msg.type() === 'error') {
errors.push(msg.text());
}
});
await page.goto('/minimal_test.html');
// Wait for WASM to initialize (canvas becomes visible)
await page.waitForSelector('canvas', { state: 'visible', timeout: 30000 });
// Give it a moment to settle
await page.waitForTimeout(1000);
// Filter out known non-critical errors
const criticalErrors = errors.filter(e =>
!e.includes('SharedArrayBuffer') && // COOP/COEP warning
!e.includes('cross-origin')
);
expect(criticalErrors).toHaveLength(0);
});
test('canvas element is rendered with dimensions', async ({ page }) => {
await page.goto('/minimal_test.html');
const canvas = page.locator('canvas');
await expect(canvas).toBeVisible({ timeout: 30000 });
// Canvas should have non-zero dimensions
const box = await canvas.boundingBox();
expect(box).not.toBeNull();
expect(box?.width).toBeGreaterThan(0);
expect(box?.height).toBeGreaterThan(0);
});
test('loading progress completes', async ({ page }) => {
await page.goto('/minimal_test.html');
// Progress text should eventually show completion or disappear
await page.waitForFunction(() => {
const status = document.getElementById('progress-text');
if (!status) return true;
const text = status.textContent || '';
return text.toLowerCase().includes('complete') ||
text === '' ||
status.style.display === 'none';
}, { timeout: 30000 });
});
test('WASM module initializes successfully', async ({ page }) => {
await page.goto('/minimal_test.html');
// Wait for canvas to be visible (indicates WASM loaded)
await page.waitForSelector('canvas', { state: 'visible', timeout: 30000 });
// Check that the Module object exists and is initialized
const moduleExists = await page.evaluate(() => {
return typeof (window as any).Module !== 'undefined';
});
expect(moduleExists).toBe(true);
});
});