Skip to content

test(frontend): cover JointGraphWrapper highlighting, flags, zoom and coeditor paths#6830

Merged
aglinxinyuan merged 5 commits into
apache:mainfrom
mengw15:chore/6825-joint-graph-wrapper-test
Jul 24, 2026
Merged

test(frontend): cover JointGraphWrapper highlighting, flags, zoom and coeditor paths#6830
aglinxinyuan merged 5 commits into
apache:mainfrom
mengw15:chore/6825-joint-graph-wrapper-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Extends the existing JointGraphWrapper spec to cover the remaining
unit-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 no
dia.Paper, matching the spec's existing setup. No production code was changed.

19 tests, grouped by the families the issue lists:

HighlightinghighlightLinks / unhighlightLinks,
highlightCommentBoxes / unhighlightCommentBoxes, highlightPorts /
unhighlightPorts, each asserted through the matching
getCurrentHighlighted*IDs getter and its highlight/unhighlight stream;
single-select (the default) dropping the previous highlight vs setMultiSelectMode(true)
keeping it; getCurrentHighlights / getCurrentHighlightedIDs aggregation
(ports are deliberately excluded from the latter); unhighlightElements
clearing all four families; and the group highlight streams, which operator
highlighting does not touch.

FlagssetReloadingWorkflow / getReloadingWorkflow and
setListenPositionChange / getListenPositionChange round-trips.

ZoomsetZoomProperty updating the ratio and emitting on the zoom stream,
isZoomRatioMin / isZoomRatioMax at the configured bounds, and
restoreDefaultZoomAndOffset resetting to INIT_ZOOM_VALUE while signalling a
paper-offset restore.

Cell layer / breakpoints / positiongetCellLayer (z index, and the throw
for an unknown cell), getLinkIDsWithBreakpoint, and
getElementPositionChangeEvent reporting a moved element's old/new position.

Coeditor presenceaddCoeditorOperatorHighlight /
deleteCoeditorOperatorHighlight, setCurrentEditing / removeCurrentEditing,
and setPropertyChanged / removePropertyChanged. These reach the canvas
through getMainJointPaper()?., so with no paper attached they must degrade to a
safe no-op; setCurrentEditing additionally returns a 300 ms interval, so the
test drives it under vi.useFakeTimers() and asserts removeCurrentEditing
clears 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:

  • setZoomProperty does not clamp — isZoomRatioMin/Max only report where
    the ratio sits relative to ZOOM_MINIMUM / ZOOM_MAXIMUM; clamping is the
    caller's job.
  • the port streams emit unconditionally, so single-select's "clear the
    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 was
verified by breaking an assertion to confirm the suite goes red):

ng test --watch=false --include src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.spec.ts
# Test Files 1 passed (1) | Tests 47 passed (47)
prettier --write <spec>   # clean
eslint  <spec>            # clean

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8 [1M context])

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @bobbai00
    You can notify them by mentioning @bobbai00 in a comment.

@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.53%. Comparing base (d2ab966) to head (bfd265d).
⚠️ Report is 4 commits behind head on main.

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     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from f77b572
agent-service 76.76% <ø> (ø) Carriedforward from f77b572
amber 67.33% <ø> (-0.01%) ⬇️ Carriedforward from f77b572
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from f77b572
config-service 66.66% <ø> (ø) Carriedforward from f77b572
file-service 67.21% <ø> (ø) Carriedforward from f77b572
frontend 82.29% <ø> (+0.08%) ⬆️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from f77b572
pyamber 92.15% <ø> (+0.04%) ⬆️ Carriedforward from f77b572
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from f77b572

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@mengw15
mengw15 force-pushed the chore/6825-joint-graph-wrapper-test branch from 618d5d6 to 78acf50 Compare July 23, 2026 09:33
@mengw15
mengw15 requested a review from aglinxinyuan July 23, 2026 23:26

@aglinxinyuan aglinxinyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jul 24, 2026
Merged via the queue into apache:main with commit 93141d1 Jul 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for JointGraphWrapper (remaining non-rendering methods)

4 participants