test(frontend): extend UserProjectListItemComponent template coverage - #7418
Conversation
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
This PR extends the frontend unit tests for UserProjectListItemComponent to exercise previously unrendered template branches (e.g., color picker panel actions, editable name/description modes, action buttons), aiming to bring the component template to full coverage without changing production code.
Changes:
- Adds DOM-driven tests to cover color picker interactions (including the
cpExtraTemplateSave/Delete actions). - Adds tests for name/description edit flows (enter-to-save, focusout behavior, expand/collapse rendering).
- Adds tests for action buttons (share, delete confirm, read-only disabled branch, non-editable hidden-UI branch) and a few newly reachable class branches.
Suppressed comments (2)
frontend/src/app/dashboard/component/user/user-project/user-project-list-item/user-project-list-item.component.spec.ts:302
q(".edit-name-icon").parent!relies on a non-null assertion and will fail with a generic runtime error if the icon/button is missing. Prefer an explicit error so test failures are actionable when the template structure changes.
q(".edit-name-icon").parent!.triggerEventHandler("click", null);
frontend/src/app/dashboard/component/user/user-project/user-project-list-item/user-project-list-item.component.spec.ts:333
q(".edit-description-icon").parent!relies on a non-null assertion and will fail with a generic runtime error if the icon/button is missing. Prefer an explicit error so failures clearly indicate what element was not found.
q(".edit-description-icon").parent!.triggerEventHandler("click", null);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7418 +/- ##
============================================
+ Coverage 85.12% 85.17% +0.05%
Complexity 4152 4152
============================================
Files 1169 1169
Lines 46740 46740
Branches 5202 5202
============================================
+ Hits 39788 39812 +24
+ Misses 5237 5216 -21
+ Partials 1715 1712 -3
*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:
|
14e7794 to
128c2ab
Compare
128c2ab to
fc81f9d
Compare
What changes were proposed in this PR?
Rebased onto
mainafter #7415 landed on the same file, and reduced to what thatPR left uncovered. #7415 pins what each template branch looks like by putting the
component into the state directly; this PR pins the wiring that produces those
states, so a control losing its handler fails here. Together they take
user-project-list-item.component.htmlto 100% (110/110 statements, no uncoveredbranches — it was 77/110 after #7415).
8 new tests:
[(colorPicker)]/(colorPickerSelect)outputs, and thecpExtraTemplatemenu, whose markup exists only while the picker is open: itsSave action, and its Delete action in both states (disabled while the project has
no colour, enabled and wired once one is set). None of this was previously
rendered — it is the bulk of the gap extend UserProjectListItemComponent template coverage #7410 describes.
keyup.entersaves,focusoutcloses.focusoutsaving, and the suffix save icon closing the editor.
nzOnConfirm.entrygetter's guard,ngOnInitadopting a storedcolour, and
updateProjectColorskipping the service when the colour isunchanged (class 63/67 -> 66/67).
This block queries with
By.css+triggerEventHandlerrather thanquerySelector:nzOnConfirm,keyup.enterandcolorPickerSelectare directiveoutputs, not DOM events, so a native dispatch cannot reach them. #7415's
MarkdownModule.forRoot()is kept as-is. No production code was changed.Tests that #7415 already covers (the creation date, the
editablegating, theread-only delete branch) were dropped from this PR rather than duplicated.
One statement stays uncovered: the
if (!this.entry) throwguard insidesaveProjectName's subscribe. Theentrygetter already throws when no entry wasprovided, so that branch cannot be reached — it is dead code rather than a coverage
gap, and removing it felt out of scope for a test-only PR.
Any related issues, documentation, discussions?
Closes #7410. Builds on #7415 (#7412), which covers the same template from the
rendering side.
How was this PR tested?
ng test --watch=false --include src/app/dashboard/component/user/user-project/user-project-list-item/user-project-list-item.component.spec.ts— 28 passed (20 existing + 8 new), run 3x for determinism. Coverage (
--coverage)confirms
user-project-list-item.component.htmlat 110/110 statements with nouncovered branches, and the class at 66/67. The failure path was verified by
breaking an assertion (red, non-zero exit); eslint and prettier are clean.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])