aglinxinyuan opened a new pull request, #7406:
URL: https://github.com/apache/texera/pull/7406
### 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 `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 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 `&& safeFileURL` guards 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):
| Mutation | Result |
|---|---|
| drop the `&& safeFileURL` guard on the video branch | red |
| drop the same guard on the image branch | red |
| key the markdown branch off `displayJson` | red |
| remove the image's click handler | red |
| drop `displayXlsx` from the table guard | red |
| reword the too-large message | red |
| use 100% height when not maximized | red |
Local 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:
- The first `detectChanges()` runs `ngOnInit`, which inspects the empty
`filePath` and settles on "preview unsupported"; flags set beforehand are
silently overwritten. The helper clears state via the component's own
`turnOffAllDisplay()` afterwards.
- Binding `[src]` makes Angular call `DomSanitizer.sanitize`, which the
existing stub does not provide, so the new block supplies its own.
- `<markdown>` needs `MarkdownModule.forRoot()`, following
`agent-chat.component.spec.ts`.
No production file is touched.
### Any related issues, documentation, discussions?
Closes #7403
### How was this PR tested?
```
npx ng test --watch=false
--include="**/user-dataset-file-renderer.component.spec.ts"
```
```
Test Files 1 passed (1)
Tests 48 passed (48)
```
16 new on top of the existing 32. `yarn format:ci` passes.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]