mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 09:19:34 +05:30
fix(flowchart): UMD browser fallback for viewport + add to controller test mount
The 6 pre-existing flowchart-controller test failures
('ReferenceError: require is not defined') were caused by
flowchart-canvas.js falling through to require('./flowchart-viewport')
when window.FlowchartViewport was undefined — because flowchart-viewport
was added in C4a but the controller test's script loader was never
updated to include it, and viewport itself had no browser-global
fallback.
Two coordinated fixes:
- Add the same UMD wrapper to flowchart-viewport.js that the other
pure modules already use (CommonJS module.exports + window
global fallback for the standalone window and jsdom). Now the
canvas's 'window.FlowchartViewport || require(...)' short-circuits
in the browser case, matching what shapes / store / mermaid do.
- Load flowchart-viewport.js in the controller test mount helper,
in dependency order between mermaid and store. The canvas now
sees window.FlowchartViewport set and never falls through to
require() under jsdom.
Test suite: 104 suites / 1353 tests passing (was 1347 with 6 failing).
The 6 'require is not defined' failures are gone.
Amit Haridas
This commit is contained in:
@@ -44,6 +44,7 @@ async function mount(apiMockOverrides = {}) {
|
||||
const scriptPaths = [
|
||||
'flowchart/flowchart-shapes.js',
|
||||
'flowchart/flowchart-mermaid.js',
|
||||
'flowchart/flowchart-viewport.js',
|
||||
'flowchart/flowchart-store.js',
|
||||
'flowchart/flowchart-canvas.js',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user