Skip to content

test(frontend): add unit test coverage for ContextMenuComponent actions - #7148

Queued
eugenegujing wants to merge 1 commit into
apache:mainfrom
eugenegujing:test/context-menu-component-spec
Queued

test(frontend): add unit test coverage for ContextMenuComponent actions#7148
eugenegujing wants to merge 1 commit into
apache:mainfrom
eugenegujing:test/context-menu-component-spec

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

ContextMenuComponent backs the canvas right-click menu, but its existing 13 tests only cover canExecuteOperator and its helpers; none of the action methods was invoked by any test.

This PR extends context-menu.component.spec.ts with 16 tests covering the remaining public surface:

  • onCopy / onPaste: delegate to OperatorMenuService, each also asserting the sibling method is not called.
  • onCut: copy happens before delete (asserted via mock invocation order).
  • onDelete (mocked): all three deletion kinds are issued with the snapshotted id lists inside exactly one bundleActions call; nothing is deleted when the bundleActions callback is not run; the hasLinkWithID guard skips links no longer in the graph; highlighted ids are snapshotted before deletion mutates the live highlight arrays.
  • onDelete (real WorkflowActionService on a seeded graph): deleting an operator together with its attached highlighted link does not double-delete the link (the real deleteLinkWithID throws on a missing link); a standalone highlighted link is deleted while its endpoint operators survive; highlighted comment boxes are deleted; the whole mixed deletion is a single undo stack entry that one undo fully restores.
  • hasHighlightedLinks: false/true per link highlight state.
  • onClickExportHighlightedExecutionResult: modal opens with ResultExportationComponent, the workflow name, and the context-menu source marker.
  • Constructor subscriptions: highlightedOperatorIds / highlightedCommentBoxIds follow the service stream emissions.

No production code is changed. The only shared-stub change is the OperatorMenuService stub's two highlight streams becoming BehaviorSubjects instead of of([]) so the subscription tests can push emissions; both emit [] on subscribe, so the pre-existing tests are unaffected.

Any related issues, documentation, discussions?

Closes #7147

How was this PR tested?

This PR only adds tests. From frontend/, npx ng test --watch=false --include='**/context-menu.component.spec.ts' passes 29/29 (13 pre-existing + 16 new); prettier and eslint are clean. With coverage enabled, context-menu.component.ts reaches 100% statements, functions and branches.

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

Co-authored by: Claude Code (Claude Fable 5)

Extends `context-menu.component.spec.ts` with 16 tests for the previously untested action surface of `ContextMenuComponent`: `onCopy`/`onPaste` delegation to `OperatorMenuService`, `onCut` copy-before-delete ordering, `onDelete` (all deletions in one `bundleActions` call, the `hasLinkWithID` guard against double-deleting a link removed with its operator, id snapshot before mutation, plus four tests through the real `WorkflowActionService` on a seeded graph including single-undo-step restoration), `hasHighlightedLinks`, the `onClickExportHighlightedExecutionResult` modal parameters, and the two constructor highlight subscriptions. No production code is changed.
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 30, 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: @Ma77Ball
    You can notify them by mentioning @Ma77Ball in a comment.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.64%. Comparing base (ffbda03) to head (5cf8821).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7148      +/-   ##
============================================
+ Coverage     79.59%   79.64%   +0.04%     
  Complexity     3839     3839              
============================================
  Files          1159     1159              
  Lines         46122    46162      +40     
  Branches       5127     5133       +6     
============================================
+ Hits          36710    36764      +54     
+ Misses         7787     7773      -14     
  Partials       1625     1625              
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from ffbda03
agent-service 77.42% <ø> (ø) Carriedforward from ffbda03
amber 73.12% <ø> (ø) Carriedforward from ffbda03
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from ffbda03
config-service 66.66% <ø> (ø) Carriedforward from ffbda03
file-service 67.21% <ø> (ø) Carriedforward from ffbda03
frontend 83.16% <ø> (+0.10%) ⬆️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from ffbda03
pyamber 97.36% <ø> (ø) Carriedforward from ffbda03
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from ffbda03

*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.

@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 31, 2026
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 ContextMenuComponent actions

3 participants