Add KiCad PCBnew WASM test infrastructure
- Add pcbnew-load.spec.ts: Tests for WASM runtime initialization - Add pcbnew.html: Test harness for loading KiCad in browser - Add setup-kicad-wasm.sh: Script to copy WASM from Docker build - Add serve.json: COOP/COEP headers for SharedArrayBuffer support - Update package.json: Add npm run test:kicad and setup:kicad scripts - Update .gitignore: Exclude generated WASM/JS files from kicad/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
af2adda002
commit
71f800d6a5
7 changed files with 304 additions and 3 deletions
96
tests/e2e/kicad/pcbnew-load.spec.ts
Normal file
96
tests/e2e/kicad/pcbnew-load.spec.ts
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
import { test, expect } from '../utils/fixtures';
|
||||
|
||||
test.describe('KiCad PCBnew WASM', () => {
|
||||
|
||||
test('WASM runtime initializes', async ({ page, testLogger }) => {
|
||||
// Navigate to KiCad app
|
||||
await page.goto('/kicad/pcbnew.html');
|
||||
|
||||
// Wait for runtime initialization (longer timeout for KiCad - 15MB WASM)
|
||||
await page.waitForFunction(() => {
|
||||
return document.querySelector('#canvas')?.style.display === 'block';
|
||||
}, { timeout: 120000 }); // 2 min timeout for large WASM
|
||||
|
||||
// Verify canvas is visible
|
||||
const canvas = page.locator('#canvas');
|
||||
await expect(canvas).toBeVisible();
|
||||
|
||||
// Check for successful initialization logs
|
||||
const initLog = testLogger.consoleLogs.find(l =>
|
||||
l.includes('[KICAD] Runtime initialized')
|
||||
);
|
||||
expect(initLog).toBeTruthy();
|
||||
|
||||
// Check that app started creating
|
||||
const appLog = testLogger.consoleLogs.find(l =>
|
||||
l.includes('[KICAD_OUT] Creating app')
|
||||
);
|
||||
expect(appLog).toBeTruthy();
|
||||
|
||||
// Take screenshot of initial state
|
||||
await page.screenshot({
|
||||
path: 'test-results/kicad-pcbnew-01-initial.png',
|
||||
fullPage: true
|
||||
});
|
||||
|
||||
// Log any errors for debugging (but don't fail on WASM exceptions yet)
|
||||
const errors = testLogger.errors.filter(e =>
|
||||
!e.includes('favicon') &&
|
||||
!e.includes('SharedArrayBuffer')
|
||||
);
|
||||
|
||||
if (errors.length > 0) {
|
||||
console.log('Errors during initialization:', errors);
|
||||
}
|
||||
|
||||
// For now, we expect initialization errors due to incomplete port
|
||||
// The test passes if runtime initializes - we track errors for debugging
|
||||
});
|
||||
|
||||
test('canvas is properly sized', async ({ page }) => {
|
||||
await page.goto('/kicad/pcbnew.html');
|
||||
|
||||
// Wait for load
|
||||
await page.waitForFunction(() => {
|
||||
return document.querySelector('#canvas')?.style.display === 'block';
|
||||
}, { timeout: 120000 });
|
||||
|
||||
// Wait for initial render
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Get canvas and verify it's sized properly
|
||||
const canvas = page.locator('#canvas');
|
||||
const box = await canvas.boundingBox();
|
||||
expect(box).toBeTruthy();
|
||||
expect(box!.width).toBeGreaterThan(100);
|
||||
expect(box!.height).toBeGreaterThan(100);
|
||||
|
||||
// Screenshot for visual inspection
|
||||
await page.screenshot({
|
||||
path: 'test-results/kicad-pcbnew-02-rendered.png',
|
||||
fullPage: true
|
||||
});
|
||||
});
|
||||
|
||||
// This test documents the current state - expect to fail until port is complete
|
||||
test.skip('loads without errors', async ({ page, testLogger }) => {
|
||||
await page.goto('/kicad/pcbnew.html');
|
||||
|
||||
await page.waitForFunction(() => {
|
||||
return document.querySelector('#canvas')?.style.display === 'block';
|
||||
}, { timeout: 120000 });
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Check for errors
|
||||
const errors = testLogger.errors.filter(e =>
|
||||
!e.includes('favicon') &&
|
||||
!e.includes('SharedArrayBuffer')
|
||||
);
|
||||
|
||||
// This will fail until KiCad WASM port is complete
|
||||
// Current known issue: WASM exception during wxWidgets initialization
|
||||
expect(errors).toHaveLength(0);
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue