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:
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:
getScriptwith a{ postMessage: vi.fn() }spy and a jsdomdocumentandwindow.window.dispatchEvent(new MessageEvent('message', { data })), then check the rendered DOM and the spy's calls.window.mermaidfor the state machine view, and reset modules between tests (diagram.tskeeps zoom/pan state at module level).readymessage, tab switching, show-all toggling, andopenFile/highlightmessages on click.References: