Skip to content

Tests for the webview script (Vitest + jsdom) #128

Description

@CatarinaGamboa

Why: tab switching, the file/workspace toggle, and clicks that open a file or highlight a variable all live in client/src/webview/script.ts, and nothing checks them today. getScript(vscode, document, window) already takes its dependencies as arguments, so no VS Code API needs faking.

What:

  • Call getScript with a { postMessage: vi.fn() } spy and a jsdom document and window.
  • Send messages with window.dispatchEvent(new MessageEvent('message', { data })), then check the rendered DOM and the spy's calls.
  • Stub window.mermaid for the state machine view, and reset modules between tests (diagram.ts keeps zoom/pan state at module level).
  • First cases: the ready message, tab switching, show-all toggling, and openFile/highlight messages on click.

References:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testingTesting related

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions