mengw15 opened a new issue, #7538:
URL: https://github.com/apache/texera/issues/7538
### Task Summary
Two frontend units have uncovered asynchronous / branch logic (~40 uncovered
lines total) that their specs never reach. **Goal: bring the listed logic to
full coverage** — cover the branches below and use the coverage report to catch
anything remaining. Vitest/jsdom; see `frontend/TESTING.md`.
### Behavior to add
**ReportGenerationService**
(`frontend/src/app/workspace/service/report-generation/report-generation.service.ts`,
~72%, 31 lines — scope to the image pipeline)
- `fetchImageAsBase64(imageUrl)` is entirely unhit. It wraps an
`XMLHttpRequest` whose `onload` hands the blob to a `FileReader`. Cover all
three outcomes:
- success — `reader.onloadend` fires and the promise **resolves** with the
base64 string;
- `reader.onerror` — the promise **rejects** with "Failed to convert image
to Base64";
- `xhr.onerror` — the promise **rejects** with `Failed to load image from
${imageUrl}`.
- The image-collection loop above it — `Array.from(images).map(...)` with
the `if (imgSrc)` guard: cover an element **with** a src (goes through
`fetchImageAsBase64`) and one **without** (skipped).
- **Stub both async sources deterministically**: replace
`globalThis.XMLHttpRequest` with a fake whose `send()` synchronously invokes
`onload`/`onerror`, and `globalThis.FileReader` with a fake whose
`readAsDataURL` fires `onloadend`/`onerror` via `queueMicrotask`; `await
Promise.resolve()` to flush, and restore both globals in `afterEach`. Do not
rely on real network or real async timing.
- Out of scope: the `html2canvas` rendering path — leave it, it needs a real
canvas.
**shared-editing.interface.ts**
(`frontend/src/app/workspace/types/shared-editing.interface.ts`, ~82%, 9 lines)
- The gap is the `switch` dispatch and several `if` guards in the
shared-editing event handling. Yjs is a pure in-memory CRDT — construct a `new
Y.Doc()`, wire the shared type the interface expects, and drive each event kind
through the `switch` so every arm executes.
- Cover the guard arms too: the early-returns for an event with no relevant
change, and the branch taken when the awareness/state entry is absent.
- Everything stays in-process; no websocket or provider is needed.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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]