test(frontend): extend UserDatasetFileRendererComponent unit test coverage - #6816
Conversation
…erage Add 15 tests covering ngOnChanges reload triggers, object-URL revocation on destroy/turn-off, the file-type viewer selection (image/mp4/mp3/markdown/json/csv), and the oversize/unsupported-preview guards. Coverage 69% -> 92%.
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
This PR expands frontend unit test coverage for UserDatasetFileRendererComponent to better exercise lifecycle-triggered reload behavior, object URL cleanup, viewer selection logic across multiple file types, and defensive guards for oversize/unsupported previews.
Changes:
- Added
ngOnChangestests to confirm reload triggers forfilePathchanges and the(did + dvid)pair, and non-triggers for unrelated/partial changes. - Added cleanup tests verifying object-URL revocation in
ngOnDestroyandturnOffAllDisplay. - Added
reloadFileContenttests covering viewer selection for image/video/audio/markdown/json/csv, plus oversized/unsupported-blob guard behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6816 +/- ##
============================================
- Coverage 78.58% 77.44% -1.14%
+ Complexity 3731 3522 -209
============================================
Files 1161 1161
Lines 46066 45910 -156
Branches 5106 5094 -12
============================================
- Hits 36199 35554 -645
- Misses 8258 8790 +532
+ Partials 1609 1566 -43
*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:
|
|
Closing as it doesn't increase coverage |
|
It actually increase the coverage. |
Use realistic SimpleChange(previous, current, firstChange) inputs for the
ngOnChanges tests instead of empty {} placeholders, set safeFileURL to an object
with a toString() (matching the SafeUrl runtime) rather than a raw string cast,
and drop the undefined-as-never cast on the notification warning spy.
What changes were proposed in this PR?
Extends
user-dataset-file-renderer.component.spec.tswith 15 tests (18 -> 33), coveringngOnChangesreload triggers, object-URL revocation on destroy / turn-off, the file-type viewer selection switch (image / mp4 / mp3 / markdown / json / csv, with CSV parsed into a table), and the in-callback oversize and unsupported-preview guards. Coverage 69% -> 92% lines. No existing tests modified.Any related issues, documentation, discussions?
Closes #6812.
How was this PR tested?
ng test --include='**/user-dataset-file-renderer.component.spec.ts'-> 33/33 passing.yarn format:cipasses.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])