mengw15 opened a new pull request, #7470:
URL: https://github.com/apache/texera/pull/7470

   ### What changes were proposed in this PR?
   
   Extends `HuggingFaceImageUploadComponent`'s spec to render the template. The
   class file is already at 100%, but the existing tests only drive the handlers
   directly, so the preview panel never rendered and
   `hugging-face-image-upload.component.html` sat at ~32%.
   
   7 added tests render the component and assert on the DOM:
   
   - No preview panel while no image is selected.
   - The preview `<img>` is bound to the stored data URL (`src`, `alt`).
   - The panel's label falls back to `"Uploaded image"` when no file name is 
known, and shows the selected file name once one is.
   - The **Clear** button clears the control and removes the panel.
   - The error block renders the current `errorMessage`.
   - A `change` event with no file selected leaves the control untouched — this 
also covers the file input's `(change)` binding while staying fully synchronous 
(the guard returns before any `FileReader`/canvas work).
   
   This lifts the template from **~32% to 100% statements**. Branches land at 
50%,
   which is the maximum reachable — see below.
   
   **The `"Selected image"` fallback is unreachable.** The issue asks for a test
   where `displayFileName` is empty so `{{ displayFileName || "Selected image" 
}}`
   renders the fallback, but that state cannot occur:
   
   - the panel only renders when `previewSrc` is truthy, which requires 
`hasImage`;
   - `displayFileName` returns `fileName` when set, otherwise `"Uploaded 
image"` when `hasImage` — so with `hasImage` true it is never empty.
   
   So whenever the fallback could be shown, the left-hand side is already 
truthy. I
   did not force it with a fabricated getter override, since that would assert a
   state the component cannot reach. If desired, the template could simply 
become
   `{{ displayFileName }}` in a follow-up — left out here because this change is
   test-only.
   
   **Determinism:** no fake timers and no async image pipeline in the added 
tests
   (the no-file `change` path returns synchronously); no layout/geometry 
assertions.
   No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7467
   
   ### How was this PR tested?
   
   Extended unit tests, run locally in `frontend/`:
   
   ```
   ng test --watch=false --include 
src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.spec.ts
   # Test Files 1 passed (1) | Tests 42 passed (42)   — 3 consecutive runs, 0 
flakes
   # hugging-face-image-upload.component.html: ~32% -> 100% statements
   prettier --write <spec>   # formatted
   eslint  <spec>            # clean
   ```
   
   The failure path was verified by deliberately breaking a new assertion and
   confirming the suite exits non-zero.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])
   


-- 
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]

Reply via email to