test(frontend): cover JointGraphWrapper highlighting, flags, zoom and coeditor paths#6830
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the frontend unit test suite for JointGraphWrapper to cover additional non-rendering behaviors when used with a headless joint.dia.Graph() (no dia.Paper), aligning with the testing goals in issue #6825. No production code changes are included.
Changes:
- Added tests for highlighting/unhighlighting links, comment boxes, and ports (including single- vs multi-select behavior and aggregation getters).
- Added tests for workflow flags and zoom ratio behaviors (streams, bounds reporting, and default restore signaling).
- Added tests for cell layer lookup, element position-change events, and “no attached paper” coeditor paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6830 +/- ##
============================================
+ Coverage 76.48% 76.53% +0.04%
+ Complexity 3456 3452 -4
============================================
Files 1161 1161
Lines 45922 45919 -3
Branches 5101 5100 -1
============================================
+ Hits 35125 35142 +17
+ Misses 9256 9238 -18
+ Partials 1541 1539 -2
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The 300ms interval is registered through zone.js's patched setInterval, and driving vitest's fake clock through that patched pair is Node-version dependent -- clearInterval did not remove the entry from the fake timer queue on CI (Node 24), so advanceTimersByTime invoked the animation callback with no paper attached and it threw. Assert on a clearInterval spy instead; the test body is fully synchronous, so the callback can never run before it is cleared.
618d5d6 to
78acf50
Compare
What changes were proposed in this PR?
Extends the existing
JointGraphWrapperspec to cover the remainingunit-testable (non-rendering) methods
(
frontend/src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.ts).The wrapper is built over a headless
new joint.dia.Graph()with nodia.Paper, matching the spec's existing setup. No production code was changed.19 tests, grouped by the families the issue lists:
Highlighting —
highlightLinks/unhighlightLinks,highlightCommentBoxes/unhighlightCommentBoxes,highlightPorts/unhighlightPorts, each asserted through the matchinggetCurrentHighlighted*IDsgetter and its highlight/unhighlight stream;single-select (the default) dropping the previous highlight vs
setMultiSelectMode(true)keeping it;
getCurrentHighlights/getCurrentHighlightedIDsaggregation(ports are deliberately excluded from the latter);
unhighlightElementsclearing all four families; and the group highlight streams, which operator
highlighting does not touch.
Flags —
setReloadingWorkflow/getReloadingWorkflowandsetListenPositionChange/getListenPositionChangeround-trips.Zoom —
setZoomPropertyupdating the ratio and emitting on the zoom stream,isZoomRatioMin/isZoomRatioMaxat the configured bounds, andrestoreDefaultZoomAndOffsetresetting toINIT_ZOOM_VALUEwhile signalling apaper-offset restore.
Cell layer / breakpoints / position —
getCellLayer(z index, and the throwfor an unknown cell),
getLinkIDsWithBreakpoint, andgetElementPositionChangeEventreporting a moved element's old/new position.Coeditor presence —
addCoeditorOperatorHighlight/deleteCoeditorOperatorHighlight,setCurrentEditing/removeCurrentEditing,and
setPropertyChanged/removePropertyChanged. These reach the canvasthrough
getMainJointPaper()?., so with no paper attached they must degrade to asafe no-op;
setCurrentEditingadditionally returns a 300 ms interval, so thetest drives it under
vi.useFakeTimers()and assertsremoveCurrentEditingclears it (real timers restored in a
finally).Two behaviours are asserted as the code actually behaves rather than as the issue
describes them, and are commented in the spec:
setZoomPropertydoes not clamp —isZoomRatioMin/Maxonly report wherethe ratio sits relative to
ZOOM_MINIMUM/ZOOM_MAXIMUM; clamping is thecaller's job.
previous ports first" step surfaces as an extra empty batch on the unhighlight
stream.
Out of scope per the issue (they need a real
dia.Paper/ geometry):attachMainJointPaper/getMainJointPaper,autoLayoutJoint,getElementPosition/setElementPosition/setAbsolutePosition,restorePaperOffset.Any related issues, documentation, discussions?
Closes #6825
How was this PR tested?
Extended unit tests, run locally in
frontend/(all green; the failure path wasverified by breaking an assertion to confirm the suite goes red):
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])