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:
2026-09-30 22:08:10 +05:30
parent dadfe52870
commit 48c7420c7a
2 changed files with 12 additions and 1 deletions
+1
View File
@@ -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',
];