// Copyright (c) 2025-2026, RTE (https://www.rte-france.com) // SPDX-License-Identifier: MPL-2.0 /** * End-to-end render test for the overflow-graph iframe overlay JS. * * The overlay is a Python f-string in * ``expert_backend/services/overflow_overlay.py`` — the unit tests in * ``test_overflow_overlay.py`` only assert that the produced JS *contains* * the right keywords. This test goes one layer deeper: it loads the * overlay JS into a jsdom document, builds a synthetic graphviz-style * SVG, simulates a ``cs4g:pins`` postMessage, and asserts that pin glyphs * actually land in the DOM. * * This is the regression guard for the user-reported bug "no pins are * rendered on the overflow analysis tab" — without it, a typo / scope * issue in the overlay's render() loop is invisible to the rest of the * test suite (the Python tests only check keywords). */ import { readFileSync } from 'node:fs'; import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, it, expect, beforeEach, vi } from 'vitest'; const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..'); const OVERLAY_PY = resolve(REPO_ROOT, 'expert_backend/services/overflow_overlay.py'); const PIN_GLYPH_JS = resolve(REPO_ROOT, 'frontend/src/utils/svg/pinGlyph.js'); /** * Extract the inlined overlay `` block out by * regex — same shape ``inject_overlay`` ships at runtime — and * strip Python's ``{{`` / ``}}`` doubling so the result is valid JS. */ function loadOverlayScript(): string { const py = readFileSync(OVERLAY_PY, 'utf-8'); const m = py.match(/