pcbjam/tests/e2e/filedialog-folder-nav.spec.ts
Balint Ipkovich d735779e23 feat: pl_editor WASM port + browser file dialog fixes
Brings up KiCad's pagelayout_editor (drawing-sheet editor) in the
browser, to roughly the same "boots, canvas visible, partially usable
in-session" level as the existing pcbnew/eeschema/calculator ports.

Build:
- docker/build.sh: add pl_editor to the unified app dispatch (case,
  subdir map, all-loop).
- scripts/kicad/build-kicad-target.sh: add pl_editor to the case;
  upstream target name pl_editor under source subdir pagelayout_editor.
- scripts/kicad/build-pl_editor.sh: 7-line thin wrapper matching the
  pcbnew/eeschema/calculator pattern.
- tests/scripts/setup-kicad-wasm.sh: copy_app pl_editor.

App glue:
- wasm/stubs/nl_pl_editor_plugin_stub.cpp: no-op SpaceMouse plugin so
  pl_editor_frame.cpp's NL_PL_EDITOR_PLUGIN symbols resolve. Mirrors
  nl_pcbnew_plugin_stub.cpp.
- tests/apps/kicad/pl_editor.html: browser shell. preRun creates
  /home/kicad and FS.chdir there so file dialogs land somewhere
  friendly instead of MEMFS root (/dev/, /proc/, etc.).

E2E coverage:
- tests/kicad/pl_editor.spec.ts: 5 tests — smoke (canvas, no abort),
  wizard, File menu has Open/Save As, file-dialog folder-navigation
  regression, canvas + toolbar metrics.
- tests/e2e/filedialog-folder-nav.spec.ts: wxWidgets-level twin of
  the regression test (exercises the underlying widget directly via
  the standalone filedialog_test app).

Submodule bumps:
- kicad → feature/pl-editor (WASM gating in pagelayout_editor's
  CMakeLists + navlib stub).
- wxwidgets → feature/pl-editor (wxGenericFileDialog::OnOk navigates
  into selected directories; wasm/mouse.cpp emits wxEVT_LEFT_DCLICK
  via timestamp-based double-click detection — the latter benefits
  every wxWidgets-WASM app).

See features/pl-editor/ for the design doc + per-repo diff patches.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 10:30:56 +02:00

37 lines
1.7 KiB
TypeScript

// Regression coverage for the wxFileDialog folder-navigation fix
// (wxGenericFileDialog::OnOk now navigates into directories instead of
// closing the dialog with the folder path as a "file").
//
// Reproduces the original bug: select a folder, press Enter, expect the
// dialog to navigate into the folder rather than close.
import { test, expect, tryLoadApp, waitForRegistry, clickByLabel } from './utils/fixtures';
test('folder navigation: Enter on a folder navigates instead of closing the dialog', async ({ page, testLogger }) => {
await page.goto('/standalone/filedialog/filedialog_test.html');
const loaded = await tryLoadApp(page);
expect(loaded, 'filedialog_test should load').toBe(true);
await waitForRegistry(page);
await clickByLabel(page, 'Open File...');
await page.waitForTimeout(800);
// Type a path that's a folder in Emscripten's MEMFS and press Enter.
// Before the fix, OnOk treated /dev as a file → either showed "Please
// choose an existing file" (wxFD_FILE_MUST_EXIST) or closed the dialog
// and surfaced /dev to the calling app as if it were a file.
await page.keyboard.type('/dev');
await page.waitForTimeout(200);
await page.keyboard.press('Enter');
await page.waitForTimeout(800);
await page.screenshot({ path: 'test-results/filedlg-folder-nav.png', fullPage: true });
// No "Selected file:" log should appear — the dialog must NOT have closed
// with /dev as the picked file.
const closedWithDev = testLogger.consoleLogs.some(l =>
l.includes('[FILEDIALOG_EVENT] Selected file:') && l.includes('/dev')
);
expect(closedWithDev, 'dialog must not close and report /dev as the selected file').toBe(false);
});