test(frontend): extend UserDatasetFileRendererComponent unit test coverage#6816
test(frontend): extend UserDatasetFileRendererComponent unit test coverage#6816aglinxinyuan wants to merge 2 commits into
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 76.27% 76.71% +0.44%
Complexity 3452 3452
============================================
Files 1161 1161
Lines 45919 45920 +1
Branches 5100 5100
============================================
+ Hits 35025 35228 +203
+ Misses 9329 9159 -170
+ Partials 1565 1533 -32
*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])