New tooling in tests/tools/screenshots/ (TypeScript via tsx): - compare.ts: one pixelmatch engine (AA-excluded), connected-component "where to look" boxes, old|new+boxes|heatmap triptych, per-engine floors. - promote.ts: churn-free updater — overwrite a baseline only when decoded pixels differ beyond the floor, copying CI bytes verbatim (no re-encode churn); pulls a CI run via `gh run download` or a local --from dir. - post-discord.ts: always-on CI-on-main report (SHA + e2e status + the track-only runtime-perf table), then screenshot triptychs, batched + size-capped + flood-collapsed + 429-aware. - perf-report.ts: perf table with Δ vs the previous main run (via gh). - changelog.ts: no-build git-history baseline differ (Discord trigger B). - noise.ts / gen-manifest.ts: calibration + manifest generation. CI wiring: - wasm-build.yml: post-test step runs the gate + report on the already- produced test-results (no extra build); report-only (continue-on-error), posts only on push to main, inert without DISCORD_WEBHOOK_URL. - ci-ubicloud.yml: secrets: inherit (pass the webhook through). - screenshot-changelog.yml: ~30s no-build changelog on baseline changes. screenshot-manifest.json: canonical 354-name set + best-effort engine tags (313 chromium-swiftshader / 41 firefox-llvmpipe). Normalize scale:'device'->'css' across 18 spec files (no-op at CI DSF=1) so committed baselines are uniformly css-scaled. Design: CI's Linux render is the single source of truth; no pinned container (accept rare env drift -> re-promote); dev commits via promote. Replaces the byte-cmp compare-screenshots.sh + file-size-proxy update-baseline-screenshots.sh (kept for now until the first re-baseline). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87 lines
2.8 KiB
TypeScript
87 lines
2.8 KiB
TypeScript
import { test, expect, type Page } from '@playwright/test';
|
|
import { clickMenuBarItem, clickMenuItem } from '../e2e/utils/element-tracker';
|
|
|
|
/**
|
|
* Tool-switch e2e: eeschema Tools → "Switch to PCB Editor" (and the reverse)
|
|
* must navigate the browser to the other tool's URL.
|
|
*
|
|
* Native KiCad spawns a process for this via ExecuteFile (common/gestfich.cpp);
|
|
* the WASM build delegates to window.kicadWebOpenTool (WasmTool.tsx), which
|
|
* maps the MEMFS file path to the project-relative file and calls
|
|
* location.assign(/p/demo/<tool>/<file>). Each direction is a full page
|
|
* navigation followed by a fresh wasm boot — hence the generous timeouts.
|
|
*/
|
|
|
|
async function waitForToolReady(page: Page, titleRe: RegExp): Promise<void> {
|
|
await expect(page.locator('#canvas')).toBeVisible({ timeout: 120000 });
|
|
await expect
|
|
.poll(() => page.title(), {
|
|
message: `editor never reached title ${titleRe}`,
|
|
timeout: 120000,
|
|
intervals: [1000],
|
|
})
|
|
.toMatch(titleRe);
|
|
// The menu helpers drive the rendered-element registry.
|
|
await page.waitForFunction(
|
|
() =>
|
|
!!(window as unknown as { wxElementRegistry?: { findAllRendered?: unknown } })
|
|
.wxElementRegistry,
|
|
null,
|
|
{ timeout: 30000 }
|
|
);
|
|
}
|
|
|
|
async function switchTool(
|
|
page: Page,
|
|
menuLabel: string,
|
|
expectedUrl: RegExp,
|
|
expectedTitle: RegExp
|
|
): Promise<void> {
|
|
expect(await clickMenuBarItem(page, 'Tools'), 'Tools menubar item clickable').toBe(true);
|
|
await page.waitForTimeout(400); // popup render settle, same as tests/kicad specs
|
|
|
|
expect(await clickMenuItem(page, menuLabel), `"${menuLabel}" menu item clickable`).toBe(true);
|
|
|
|
await page.waitForURL(expectedUrl, { timeout: 30000 });
|
|
await waitForToolReady(page, expectedTitle);
|
|
}
|
|
|
|
test.describe('web app — tool switching', () => {
|
|
test('eeschema → Switch to PCB Editor navigates to pcbnew', async ({ page }) => {
|
|
test.setTimeout(420000); // two full wasm boots
|
|
|
|
await page.goto('/p/demo/eeschema/demo.kicad_sch');
|
|
await waitForToolReady(page, /demo — Schematic Editor/i);
|
|
|
|
await switchTool(
|
|
page,
|
|
'Switch to PCB Editor',
|
|
/\/p\/demo\/pcbnew\/demo\.kicad_pcb/,
|
|
/demo — PCB Editor/i
|
|
);
|
|
|
|
await page.screenshot({
|
|
path: 'test-results/web-switch-sch-to-pcb.png',
|
|
scale: 'css',
|
|
});
|
|
});
|
|
|
|
test('pcbnew → Switch to Schematic Editor navigates to eeschema', async ({ page }) => {
|
|
test.setTimeout(420000);
|
|
|
|
await page.goto('/p/demo/pcbnew/demo.kicad_pcb');
|
|
await waitForToolReady(page, /demo — PCB Editor/i);
|
|
|
|
await switchTool(
|
|
page,
|
|
'Switch to Schematic Editor',
|
|
/\/p\/demo\/eeschema\/demo\.kicad_sch/,
|
|
/demo — Schematic Editor/i
|
|
);
|
|
|
|
await page.screenshot({
|
|
path: 'test-results/web-switch-pcb-to-sch.png',
|
|
scale: 'css',
|
|
});
|
|
});
|
|
});
|