mengw15 opened a new pull request, #7541:
URL: https://github.com/apache/texera/pull/7541
### What changes were proposed in this PR?
18 new tests across two units.
| file | statements | branches | functions |
| --- | --- | --- | --- |
| `report-generation.service.ts` | 126/129 (was 98/129) | 25/25 | 34/35 |
| `shared-editing.interface.ts` | 115/115 | 79/80 | 6/6 |
**ReportGenerationService** — `fetchImageAsBase64` and the loop that feeds
it were entirely
unhit. Covered: an image whose bytes convert (its `href` is rewritten to the
base64 result),
one whose `FileReader` fails, one whose request fails, and one with no
source at all (skipped
without a request). `XMLHttpRequest` is replaced with a fake that settles
synchronously and
`FileReader` with one that fires on a microtask, so nothing depends on the
network or on real
timing; both globals are restored afterwards.
Also covered while the report was in view: the two `|| "Unknown error"`
fallbacks, the outer
`catch` that reports a failure to build the report at all, and the
visualization snapshot that
has no wrapper `div` to resize. That takes branch coverage of the file to
25/25.
**shared-editing.interface.ts** — the file is `createYTypeFromObject` /
`updateYTypeFromObject`
over Yjs types, so the tests drive real `Y.Doc`s in memory. Covered: the
`typeof` arms no
caller passes (function, symbol, bigint), the boxed-String arms of both
functions, the no-op
when a string is already up to date, an `undefined` array entry becoming
`null`, an array
element whose kind changes being replaced rather than merged, an array whose
additions sit
before its removals, and the `return false` for a type the dispatch has no
strategy for.
No production code was changed.
### Coverage that is not reachable
- `report-generation.service.ts:93-95` — the html2canvas success callback.
jsdom has no
canvas, and reaching it means standing in a CSS engine, a 2D context,
`toDataURL` and the
image loader; that is a simulated renderer rather than a test, and it
would break on an
html2canvas or jsdom upgrade. Left alone deliberately.
- `shared-editing.interface.ts:223` — the `_.isEqual` guard's false arm,
i.e. an equal pair at
the same offset *inside* an unmatched segment. A script replicating the
LCS walk and segment
construction found none across all 1,185,921 array pairs of length 2-6
over a 3-value
alphabet, so the alignment appears to preclude it.
Note that html2canvas still runs for real in the image tests and jsdom
cannot render it, so
those tests emit `Not implemented` notices on stderr. They are jsdom's, not
failures — the
tests assert on what the inlining step did, not on the render.
### One defect worth recording
`createYTypeFromObject(new String("x"))` returns an **empty** `Y.Text`: `new
Y.Text(...)` only
accepts a primitive, so the boxed value is dropped. The update path does not
share the bug —
`Y.Text.insert` coerces — so the same input round-trips correctly through
`updateYTypeFromObject`. The test asserts the real behaviour with a comment
saying what to flip
when the branch unwraps the box.
### Any related issues, documentation, discussions?
Closes #7538.
Note: the issue describes this file as a `switch` over shared-editing events
with awareness
state; the file is actually the two YType conversion functions above, with
an LCS-based array
diff. The tests follow the code.
### How was this PR tested?
`ng test --watch=false` over the two specs — 52 passed (34 existing + 18
new), run 3x for
determinism. Coverage (`--coverage`) gives the table above. The failure path
was verified by
breaking one assertion in each spec (red, non-zero exit) and restoring them;
eslint and
prettier are clean.
### 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]