test(frontend): call fixture.detectChanges() in three dashboard component specs#5181
Merged
Merged
Conversation
…nent specs `list-item`, `share-access`, and `user-dataset-file-renderer` each constructed a `ComponentFixture` but never triggered change detection, so the template's creation pass never ran and the corresponding `.component.html` files reported 0 % coverage despite the specs passing green. This violates the golden rule documented in `frontend/AGENTS.md` and `frontend/TESTING.md`. Add `fixture.detectChanges()` to each: - `list-item`: in `beforeEach`, after seeding `component.entry` with a fully-formed workflow entry. The component's `entry` getter throws when `_entry` is undefined, and `initializeEntry()` (called from `ngOnChanges`) reads `entry.workflow.isOwner`, `accessibleUserIds`, and counters, so a minimal stub is insufficient. Each test below still overwrites `component.entry` and asserts on confirm-method behavior — no behavior change to existing assertions. - `share-access`: inside the `setupComponent` helper, so every test case picks it up. - `user-dataset-file-renderer`: in `beforeEach` after `createComponent`. `ngOnInit -> reloadFileContent` hits the unsupported-MIME bail with the default empty `filePath`, so no service calls fire. Closes apache#5180
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5181 +/- ##
============================================
+ Coverage 43.71% 43.91% +0.19%
Complexity 2218 2218
============================================
Files 1049 1049
Lines 40578 40578
Branches 4327 4327
============================================
+ Hits 17739 17818 +79
+ Misses 21733 21640 -93
- Partials 1106 1120 +14
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 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?
list-item,share-access, anduser-dataset-file-renderereach constructed aComponentFixtureviaTestBed.createComponentbut never triggered change detection. The template's creation pass therefore never ran, the source-map-attributed v8 coverage stayed at 0 % for the corresponding.component.html, and the specs still passed green.Adds
fixture.detectChanges()to each:list-item.component.spec.ts— seedscomponent.entrywith a fully-formed workflow entry inbeforeEachbefore callingdetectChanges(). The component'sentrygetter throws when_entryis undefined andinitializeEntry()(called fromngOnChanges) readsentry.workflow.isOwner,accessibleUserIds, and counters, so a minimal stub is not enough. Eachitblock continues to overwritecomponent.entryand assert on confirm-method behavior; no existing assertions change.share-access.component.spec.ts—detectChanges()lives in thesetupComponenthelper so every test case picks it up.user-dataset-file-renderer.component.spec.ts—detectChanges()inbeforeEachaftercreateComponent.ngOnInit -> reloadFileContenthits the unsupported-MIME bail with the default emptyfilePath, so no service calls fire.Any related issues, documentation, discussions?
Closes #5180.
How was this PR tested?
yarn ng test --watch=false --include=…against the three affected specs locally: 3 files, 10 tests, all pass.yarn format:ciclean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7