Skip to content

test(frontend): cover ContextMenuComponent template menu-item click bindings - #7335

Open
mengw15 wants to merge 1 commit into
apache:mainfrom
mengw15:chore/7332-contextmenu-test
Open

test(frontend): cover ContextMenuComponent template menu-item click bindings#7335
mengw15 wants to merge 1 commit into
apache:mainfrom
mengw15:chore/7332-contextmenu-test

Conversation

@mengw15

@mengw15 mengw15 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Extends ContextMenuComponent's spec to cover the template's menu-item (click)
bindings. The class file is already at 100%, but the existing tests call the
handlers directly and never render/click the menu, so the template sat at ~54%.

13 added tests render the menu (setting the state each item's *ngIf needs),
query the <li nz-menu-item> by its label via By.css, fire
.triggerEventHandler("click", null), and assert the click reaches the handler
the item declares — either the component method (onCopy / onCut / onPaste /
onDelete / onClickExportHighlightedExecutionResult, spied) or the injected
OperatorMenuService double (disableHighlightedOperators,
viewResultHighlightedOperators, reuseResultHighlightedOperator,
executeUpToOperator). Covers both variants of the toggle items (disable/enable,
view/remove-view, reuse/remove-reusing) and both delete paths (operators vs
links-only).

This lifts context-menu.component.html from ~54% to 97.92%. The single
remaining line is the hardcoded-nzDisabled "reuse result" item's (click):
a disabled nz-menu-item genuinely swallows the click (verified — clicking it
does not invoke the handler), so rather than force an unrealistic interaction the
test only asserts that item renders; its handler is identical to
"remove reusing result", which is clicked and covered.

No production code was changed.

Any related issues, documentation, discussions?

Closes #7332

How was this PR tested?

Extended unit tests, run locally in frontend/:

ng test --watch=false --include src/app/workspace/component/workflow-editor/context-menu/context-menu/context-menu.component.spec.ts
# Test Files 1 passed (1) | Tests 42 passed (42)   — 3 consecutive runs, 0 flakes
# context-menu.component.html: ~54% -> 97.92%
prettier --write <spec>   # formatted
eslint  <spec>            # clean

The failure path was verified by deliberately breaking a new assertion and
confirming the suite exits non-zero.

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

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

@mengw15
mengw15 requested a lite review from Copilot August 5, 2026 11:16
@mengw15 mengw15 self-assigned this Aug 5, 2026

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds unit tests that exercise ContextMenuComponent template (click) bindings by rendering the menu and triggering clicks on specific <li nz-menu-item> entries, improving template coverage without changing production code.

Changes:

  • Introduced a clickItem(label) helper to find and click menu items by rendered text.
  • Added 13 tests to verify each menu item routes to the correct component method or OperatorMenuService action.
  • Added a render-only assertion for a hardcoded-disabled “reuse result” menu item.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Aug 5, 2026

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: @eugenegujing
    You can notify them by mentioning @eugenegujing in a comment.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 5, 2026
@mengw15
mengw15 force-pushed the chore/7332-contextmenu-test branch from b50712d to da83a06 Compare August 5, 2026 11:50
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.44%. Comparing base (0f2cd49) to head (da83a06).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7335      +/-   ##
============================================
+ Coverage     83.36%   83.44%   +0.07%     
  Complexity     4128     4128              
============================================
  Files          1166     1166              
  Lines         46428    46428              
  Branches       5174     5174              
============================================
+ Hits          38705    38741      +36     
+ Misses         6003     5971      -32     
+ Partials       1720     1716       -4     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 0f2cd49
agent-service 83.65% <ø> (ø) Carriedforward from 0f2cd49
amber 80.65% <ø> (ø) Carriedforward from 0f2cd49
computing-unit-managing-service 43.60% <ø> (ø) Carriedforward from 0f2cd49
config-service 65.97% <ø> (ø) Carriedforward from 0f2cd49
file-service 69.05% <ø> (ø) Carriedforward from 0f2cd49
frontend 84.20% <ø> (+0.17%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 0f2cd49
pyamber 97.36% <ø> (ø) Carriedforward from 0f2cd49
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from 0f2cd49

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

@mengw15
mengw15 requested a review from aglinxinyuan August 5, 2026 14:12
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.

extend ContextMenuComponent template coverage

3 participants