Repository navigation
refactor: split the map editor script into cohesive files - #347
Conversation
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>
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>
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>
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>
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>
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>
|
|
Tested I also combined this with #341 and confirmed the image-options test needs updating for the split. EditorImageOptionsTest.cjs still extracts wmEditorImageSrc from editor.js. Using the shared loadEditorScripts helper to load editor.js and editor.picker.js fixes that locally. With #333 included, all 33 combined browser test files passed, covering the link workflow, image pickers, notes, label positioning and undo/redo. So the automated results look good, with that test adjustment needed when the branches come together. I'd still do one focused real-browser check of the combined editor changes for layout and focus behaviour, which the automated DOM tests don't fully cover. |
|
Real-browser check done in Safari 27.2 against Cacti 1.2.32 with #336, #341, #347 and #333 combined. All five split editor scripts load. The node, link, map properties, map style, colours, images and editor settings dialogs each open fully inside the window without covering the toolbar, move focus into the dialog, and close cleanly, with no JavaScript errors. One thing I noticed: closing a dialog leaves focus on the page rather than returning it to the toolbar button that opened it. develop does the same in Safari, so it isn't from this change; it could be a separate accessibility follow-up. |
alcatron
left a comment
There was a problem hiding this comment.
Rechecked with the updated #341 test. All 33 browser test files now pass together without a local workaround, along with 648 PHP tests. Thanks for doing the Safari dialog and focus checks. Looks good to me; the existing toolbar-focus behaviour can be handled separately.



Fixes 346
Split js/editor.js into editor.dialogs.js, editor.picker.js, editor.compact.js and editor.assets.js.
get_md5_include_js, so the CSP nonce applies. No other asset list needed changes.wmEditorImageSrc(). Whichever of refactor: build editor image lists with one library scanner #341 and this PR merges second needs that test switched to the loader. I'll update it.Fixes #346