test(frontend): cover ContextMenuComponent template menu-item click bindings - #7335
test(frontend): cover ContextMenuComponent template menu-item click bindings#7335mengw15 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
OperatorMenuServiceaction. - 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.
Automated Reviewer SuggestionsBased on the
|
b50712d to
da83a06
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*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:
|
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
*ngIfneeds),query the
<li nz-menu-item>by its label viaBy.css, fire.triggerEventHandler("click", null), and assert the click reaches the handlerthe item declares — either the component method (
onCopy/onCut/onPaste/onDelete/onClickExportHighlightedExecutionResult, spied) or the injectedOperatorMenuServicedouble (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.htmlfrom ~54% to 97.92%. The singleremaining line is the hardcoded-
nzDisabled"reuse result" item's(click):a disabled
nz-menu-itemgenuinely swallows the click (verified — clicking itdoes 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/: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])