test(frontend): cover the result-exportation and UI-UDF-parameters templates - #7891
Open
aglinxinyuan wants to merge 1 commit into
Open
test(frontend): cover the result-exportation and UI-UDF-parameters templates#7891aglinxinyuan wants to merge 1 commit into
aglinxinyuan wants to merge 1 commit into
Conversation
…mplates Both templates reach 100% lines, branches and functions. 37 tests to 53. ui-udf-parameters.component.html had ZERO of its five template functions covered, which its 87% line figure hid entirely. The blocker was a wrong comment in the existing spec, which asserted that the nz-autocomplete option bodies cannot be reached in jsdom because the panel never expands. NzAutocompleteTriggerDirective has a host focusin listener, so dispatching focusin attaches the panel -- verified by rendering it and firing an export from a clicked option. The options land in the overlay container in document.body, so they are queried through document.querySelectorAll rather than fixture.debugElement. 30 mutations, all 30 killed. Two candidate mutants were discarded as type-invalid under strictTemplates -- proven by ng build rather than argued -- and one as a semantically inert attribute reorder. Of the +13 Codecov lines, only +5 are raw line-hit; the other 8 move because Codecov counts a line with any unhit branch arm as missed.
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7891 +/- ##
============================================
+ Coverage 92.09% 92.22% +0.12%
Complexity 4533 4533
============================================
Files 1173 1173
Lines 47347 47347
Branches 5306 5306
============================================
+ Hits 43604 43665 +61
+ Misses 2105 2070 -35
+ Partials 1638 1612 -26
*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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Both workspace templates go to 100% lines, branches and functions. 37 tests → 53.
Measured from
frontend/withng test --coverage --coverage-reporters=lcovonly, the same spec-file filter on both sides, andrm -rf coveragebetween runs. lcov parsed with Codecov's model:DA=0is missed,DA>0with someBRDAarms at 0 is partial, and partial counts against the percentage.result-exportation.component.htmlui-udf-parameters.component.html+13 Codecov fully-covered lines, +11 branch arms, +9 functions.
Worth being precise about where that 13 comes from: the raw lcov line-hit delta is only +5. The other 8 lines move because Codecov counts a line with any unhit branch arm as missed. Both companion
.tsfiles were already at 100% lines, branches and functions before and after, so nothing here is a.tsgain.The
ui-udf-parametersfunction counter is the one I would point a reviewer at: zero of its five template functions were covered, which an 87% line figure hides entirely.An existing comment in the spec was wrong, and it was the blocker
result-exportation.component.spec.tsasserted in a comment that the nz-autocomplete option bodies are unreachable — that the option content "only enters the DOM once the autocomplete panel expands, which jsdom does not drive."That is false.
NzAutocompleteTriggerDirectivedeclares a hostfocusinlistener runninghandleFocus()→canOpen()→openPanel(), so dispatchingnew Event("focusin")on the search input and callingdetectChanges()attaches the panel. Verified by rendering it: two option nodes, and clicking one fires the export.Two mechanics that follow, both now in the spec:
document.body, so they are queried withdocument.querySelectorAll.fixture.debugElementreturns zero.Verification
30 mutations, all 30 killed, no survivors. Every mutant was re-derived from scratch against the repaired specs, one at a time. This includes all 8 that the two adversarial reviewers reported as surviving the first draft.
Three mutants were discarded as non-viable rather than counted, and by build evidence rather than argument:
[nzDescription]="…length || null"variants are type-invalid —ng buildrejects them understrictTemplates. A mutant that only fails to compile proves nothing, so they are not in the table either way.(keyup.enter)and(keyup.escape)attributes wholesale, event names included, is a pure attribute reorder with no semantic change.Corrections to the first draft
"survivors": []was true of the table it ran, but that table was defective: two of its fourteen rows were type-invalid mutants and its remaining coverage was too narrow to support the bundle's claims.|| nullfallback is load-bearing actually prove only that nz-alert renders a description node; rewritten to say that.droppedTargetsentry had correct arithmetic and the wrong conclusion.Deliberately not included
The "value editable, name and type locked" behaviour cannot be asserted through a rendered formly-field: attaching a real
FormControlbefore render makesFormlyFieldthrowTypeError: Cannot destructure property 'updateOn' of 'field.modelOptions', becausefieldChanges()assumes a fully built Formly field. Standing up a fullFormlyModule.forRootform for that is out of scope, and the behaviour is already covered at the unit level by three existing tests. The rendered-row test asserts structure instead.No production file is touched, and no production seam was needed — every one of the 13 lines was reachable from a test-only change.
Any related issues, documentation, discussions?
Closes #7890
How was this PR tested?
jsdom prints two
AggregateErrorblocks fromxhr-utils.jsduring these specs. Those are pre-existing — present identically in the untouched baseline run.frontend/junit.xmlandfrontend/coverage/are regenerated by every run and are not committed.yarn format:cipasses.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)