Skip to content

Add npm run test:wdio target for webview-DOM E2E coverage #86

@jmchilton

Description

@jmchilton

Background

Recent work adds a "Preview Workflow Diagram" command (Mermaid first, Cytoscape planned) that opens a vscode.WebviewPanel and renders SVG via a bundled JS module. The current E2E harness (@vscode/test-electron + Mocha) cannot reach into webview iframes, so we can validate that the panel opens and that the LSP wire delivers a valid graph LR … payload, but not that the SVG actually rendered correctly inside the webview.

Proposal

Add a second, opt-in E2E target npm run test:wdio using wdio-vscode-service (WebdriverIO + VS Code via WebDriver). This drives the real Electron/Chromium instance and can query the webview's DOM, which:

  • Proves mermaid.render() actually injected <svg> into the panel (node count, edge count, viewBox).
  • Becomes load-bearing for the planned click-to-jump v2 work (webview → extension selectStep round-trip), which needs DOM event simulation against rendered nodes.
  • Doesn't disturb the existing Mocha suite — runs as a separate harness.

Suggested shape

  • New devDeps: @wdio/cli, wdio-vscode-service, @wdio/mocha-framework, webdriverio (>=8.14 for VS Code 1.86+).
  • wdio.conf.ts at repo root: browserName: "vscode", pinned browserVersion, wdio:vscodeOptions.extensionPath: ".", workspace pointed at test-data/.
  • client/tests/wdio/specs/diagramPreview.spec.ts: open fixture → executeWorkbench invokes galaxy-workflows.previewMermaidDiagram → switch into the webview frame → assert svg [id^="diagram-"] exists, node <g class="node"> count matches the fixture's step count.
  • Page object pattern in client/tests/wdio/pageobjects/ for reusable VS Code element locators.
  • CI: add a job (Linux uses xvfb-run); macOS/Windows headed.

Gotchas (per Apr 2026 wdio-vscode-service docs)

  • Chromedriver is auto-resolved per VS Code version; needs CI network access.
  • ~8–12s bootstrap per spec — keep specs grouped, not one-per-feature.
  • Webview iframe access is via WebDriver context switching, not CDP; sandbox/CSP restrictions don't apply.

What this enables next

  • Migrating the postMessage round-trip pattern (proposed for live-update tests in the next diagram preview commit) to direct DOM assertions, removing test-only message types.
  • Click-to-jump v2 tests that simulate <g class="node"> clicks and assert editor selection.
  • Future Cytoscape renderer tests share the same harness.

Out of scope for this issue

  • Replacing the existing Mocha E2E suite — wdio is additive.
  • The actual click-to-jump implementation.

Refs: wdio-vscode-service. Layer-1 LSP-wire tests for the diagram preview have landed locally in client/tests/e2e/suite/diagramPreview.e2e.ts on a feature branch; this issue tracks the follow-up DOM-level coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions