test(frontend): render the dataset file preview's viewer branches - #7406
Conversation
The file renderer's class was already well covered, but its template was not: the template is a viewer switch where each displayX flag selects exactly one preview, and only the CSV path had ever been rendered. Adds 16 tests that drive each viewer and assert what reaches the screen: the four status alerts, the shared table for CSV and spreadsheets, image (including the click that opens the full-size modal), video, audio, markdown, JSON, plain text, the empty initial state, and the maximized height. Also pins the safeFileURL guards. displayMP4/MP3/Image are set as soon as the MIME type is known, while the object URL is built asynchronously, so rendering on the flag alone would emit a source-less media element. Local coverage for the component directory moves from 68.34% to 93.57% of statements. No production file is touched.
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
This PR increases frontend test coverage for UserDatasetFileRendererComponent by adding a dedicated rendering-focused test suite that exercises all template viewer branches (status alerts, tabular previews, media previews with modal interaction, and text viewers), without changing production code.
Changes:
- Adds a new “rendering” test suite that asserts which viewer elements actually render for each
displayX/status flag combination. - Introduces a TestBed configuration for rendering tests that includes
MarkdownModule.forRoot()and aDomSanitizerstub implementingsanitizeto support[src]bindings. - Adds assertions for media guards (
displayX && safeFileURL), the image modal click interaction, empty initial state, and maximized vs non-maximized height styling.
💡 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 #7406 +/- ##
============================================
+ Coverage 84.70% 84.78% +0.07%
Complexity 4151 4151
============================================
Files 1169 1169
Lines 46740 46740
Branches 5202 5202
============================================
+ Hits 39591 39627 +36
+ Misses 5433 5401 -32
+ Partials 1716 1712 -4
*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:
|
What changes were proposed in this PR?
The file renderer's class was already at 91% locally, but its template was at 25% of statements. The template is a viewer switch — each
displayXflag selects exactly one preview — and only the CSV path had ever been rendered.Adds 16 tests that drive each viewer and assert what actually reaches the screen: the four status alerts (each excluding the others), the shared table for CSV and spreadsheets, image plus the click that opens the full-size modal, video, audio, markdown, JSON, plain text, the empty initial state, and the maximized height.
It also pins the
&& safeFileURLguards on the media branches. Those are load-bearing: the flag is set as soon as the MIME type is known while the object URL is built asynchronously, so rendering on the flag alone emits a source-less<img>/<video>/<audio>.Verified by mutation, all reverted (template diff empty):
&& safeFileURLguard on the video branchdisplayJsondisplayXlsxfrom the table guardLocal coverage for the component directory: 68.34% → 93.57% of statements.
Three details are commented in the spec, each of which cost a debugging round:
detectChanges()runsngOnInit, which inspects the emptyfilePathand settles on "preview unsupported"; flags set beforehand are silently overwritten. The helper clears state via the component's ownturnOffAllDisplay()afterwards.[src]makes Angular callDomSanitizer.sanitize, which the existing stub does not provide, so the new block supplies its own.<markdown>needsMarkdownModule.forRoot(), followingagent-chat.component.spec.ts.No production file is touched.
Any related issues, documentation, discussions?
Closes #7403
How was this PR tested?
16 new on top of the existing 32.
yarn format:cipasses.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)