Repository navigation
ci: run the jsdom browser tests with locked dependencies - #333
Conversation
jsdom 30.1.2 started refusing focus to any element with a display:none ancestor, and its UA stylesheet gives area display:none. Browsers still focus image-map hotspots, so area.focus() became a silent no-op in the test: the popup never opened on focus, and the later ArrowDown opened a fresh popup whose link the stale tip reference did not hold. The viewer is unchanged; the failure reproduces with Cacti 1.2.x and develop jQuery UI alike and disappears on jsdom 30.1.1. Render area inline in the fixture and assert up front that the hotspot takes focus and opens its popup, so a future jsdom change fails with that message. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Add a private package.json and lockfile for tests/Browser pinning jsdom 30.1.3 and jQuery 3.7.1, and a dependency-free runner that executes each *.cjs check in its own process, names each file and stops at the first failure. It also fails when CACTI_JS_DIR lacks jquery-ui.js or no tests are found. A separate browser-tests job installs Node 24, runs npm ci with install scripts disabled and runs the suite against the Cacti core checkout's include/js. It needs no PHP or database, so it runs once rather than on every integration matrix leg. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Keep tests/Browser/README.md as on develop so this PR does not conflict with the README rewrite in #333; the loader and each check already describe themselves in their header comments. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Keep tests/Browser/README.md as on develop so this PR does not conflict with the README rewrite in #333. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Tested Two small things before merging: the locked jsdom version needs Node 24.15+ on the Node 24 line, whereas package.json currently says >=24. Also, the changelog includes the other PRs in this batch, so those entries will need trimming if any are held back. |
jsdom 30.1.3 supports Node.js 24.15 or later on the 24 line and 26 and later; package.json allowed any Node.js 24. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
|
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> #339 is held back until the node cache has a production caller again.
|
alcatron
left a comment
There was a problem hiding this comment.
Rechecked ce22ddc. The Node requirement is corrected and the deferred #339 entry is gone. Tested the eight active PRs together: 648 PHP tests and all 33 browser test files passed, without the earlier local test fixes. Looks good from my review.
* fix(cli): stop loading the unshipped overlib.js in exported HTML MakeHTML() emits data-hover/data-caption attributes for the Cacti viewer, so the overDiv container and overlib.js script tag written by the command-line HTML wrapper did nothing except request a missing file. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs: retire the bundled overLIB library from the example docs/example/overlib.js was only loaded by the static example page and built code strings for eval(). The plugin viewer renders HTMLSTYLE overlib hovers from data-hover with js/weathermap.js and never loaded it. The example page now uses plain title captions. Add a guard against overlib.js, eval() and code-string timers in the shipped JavaScript and documentation, an engine render of example.conf that checks hover content without overLIB, and a jsdom check of the static example page. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: ignore libpng's sRGB profile warning in the docs example render Newer libpng, as used by the PHP 8.6 CI leg, warns about the sRGB profile embedded in docs/example/my_router.png. Ignore only that message while the example is read and drawn; any other warning still fails the test. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: mark the docs hover test's script load as reviewed The test loads the repository's own js/weathermap.js into its jsdom context through vm.runInContext, as jsdom documents. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * Revert "test: ignore libpng's sRGB profile warning in the docs example render" This reverts commit 3b19a5c. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs: drop the invalid sRGB profile from the example router icon libpng 1.6 prints "iCCP: known incorrect sRGB profile" whenever the example map loads my_router.png, which fails the docs example render on the PHP 8.6 CI leg. Remove the iCCP chunk; the decoded pixels are unchanged. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs: describe the docs hover check in its own header Keep tests/Browser/README.md as on develop so this PR does not conflict with the README rewrite in #333. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
* refactor: split the map editor script into cohesive files Move the dialog helpers, the graph and icon pickers, the compact link and node property editors, and the image and colour library out of js/editor.js into editor.dialogs.js, editor.picker.js, editor.compact.js and editor.assets.js. The moved code is unchanged. Functions stay browser globals because inline handlers and the rest of the editor call them by name; each new file also exports its functions under CommonJS, as editor.js already does, for Node checks. Both pages that include editor.js now include the new files right after it. The browser checks load whole files through a shared helper instead of slicing source by function name, so moving a function no longer breaks them silently. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs: document the functions exported by the split editor scripts Add JSDoc with a purpose line, parameters and return value to every function the new editor files export, and to the browser test loader. Comments that described a single function become its doc block. The start page renderer, which now includes the new files, gets a purpose line. Only comments and blank lines change. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: cover the split editor scripts' API, include order and nonce Load each split editor script on its own and check that its CommonJS exports are exactly its top-level functions and that each is also a browser global. Check that both editor pages include every editor script once in the loader's order, that no function is declared in two files, and that one call into each script works once all are loaded. Render the start page and the editor page head through their PHP code in a child process with a CSP nonce double, and check each editor script is included once, in order, with the nonce. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: keep the editor script loader out of the browser test glob Move the shared loader to tests/Browser/lib/ so a runner that executes every tests/Browser/*.cjs file does not treat the helper as a test. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * chore: declare the editor state the split scripts share editor.picker.js and editor.compact.js assign graph picker state that editor.js declares. Record that with /* global */ directives so per-file analysis sees the declarations, and sort names with localeCompare in the script API checks. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs: describe the editor script loader in its own header Keep tests/Browser/README.md as on develop so this PR does not conflict with the README rewrite in #333; the loader and each check already describe themselves in their header comments. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>



Fixes #332
Run the tests/Browser jsdom suite in CI with locked dependencies (jsdom 30.1.3, jQuery 3.7.1) through a small
npm testrunner that stops at the first failure.browser-testsjob that runs against Cacti 1.2.xinclude/js.area. The test page now displays hotspots inline and asserts they can take focus. Viewer code is unchanged.Changelog: this PR carries the CHANGELOG.md entries for the whole batch (#333, #336, #337, #339, #341, #344, #345, #347), so the sibling PRs do not conflict on it.