The GitHub Actions job "Benchmarks" on texera.git/main has succeeded.
Run started by GitHub user github-merge-queue[bot] (triggered by 
github-merge-queue[bot]).

Head commit for run:
646e460838c568dc421042ac8bcd95aa534aa118 / Neil Ketteringham 
<[email protected]>
fix(test, frontend): bound the workflow-snapshot render's cost under jsdom 
(#7999)

### What changes were proposed in this PR?

`report-generation.service.spec.ts` drives the real html2canvas, which
clones the whole document
rather than the element it is pointed at. The unit-test builder runs
spec files with
`isolate: false`, so one jsdom document is shared by every spec file in
a worker and the clone
drags in whatever DOM the files before it left behind.

On the macOS runner that clone was measured at 12–37s against a 20s test
timeout, failing
`fails when the editor cannot be rendered` while ubuntu and windows
passed on the same commit.

Two changes, both test-only:

- **`report-generation.service.spec.ts`** — the snapshot suite parks the
document's existing body
nodes for the duration of the file and restores them after, so the
render's cost depends only on
the DOM these tests build. It spans the file rather than each test
because the renders outlive
the tests that start them (visible in the failing log: clone #1 finished
during test #3).

- **`jsdom-svg-polyfill.ts`** — stops jsdom announcing
`getComputedStyle(elt, pseudoElt)` and
`scrollTo` on the virtual console, which vitest forwards to
`console.error` as a full stack trace
per call. The failing job carried 5,691 of them for six renders.
Dropping `pseudoElt` changes no
behaviour: jsdom complains and then ignores the argument, returning the
element's own declaration
either way. `scrollTo` has nothing to move — jsdom has no layout, and
the one html2canvas reaches
for belongs to the throwaway clone iframe, so it is neutered as each
`contentWindow` is handed out.

### Any related issues, documentation, discussions?

Closes #8001.

This continues #7886 (closing #7887), which stopped the four
image-inlining tests in this file
waiting on the render. The flake moved to the two tests that still await
one.

Scope note for reviewers: this bounds the render's cost, it does not
remove the dependency on a
real render. The two remaining tests still await html2canvas, so a
sufficiently loaded runner
could in principle still be slow — just not by the two orders of
magnitude measured here. Taking
#7886's logic to its conclusion (no test in this file waiting on a real
render) would need a
stub html2canvas that survives `isolate: false`, which is a larger
change to what those two tests
cover; happy to do that instead if reviewers prefer it.

Unrelated pre-existing noise left alone: a full run still emits ~827
jsdom
`HTMLCanvasElement.prototype.getContext` traces from
`JointUIService.getMeasureContext`
(`joint-ui.service.ts:219`). Silencing it would change what
`measureText` returns for the
joint-ui specs, so it is out of scope here.

### How was this PR tested?

`ng test --watch=false` on this branch (base `444fc58284`), four full
runs: 201 files,
5131 passed / 1 skipped each time, no `Not implemented:
window.getComputedStyle` traces.
Clone time across the file's six renders was 79–353 ms on three warm
runs; the test that was
timing out renders in 85–114 ms. The first run on a cold checkout was
slower — up to 3.9s for a
clone — which is a reminder that machine load, not document size, is
what is left.

The effect of the console noise was measured directly by seeding the
document with 500 nodes:
clone time across the six renders went 18.8s → 13.1s with the polyfill
change alone (~30%; the
share is larger where console forwarding is slower, as on CI).

`yarn --cwd frontend format:ci` is clean.

I cannot demonstrate the macOS leg green from here — that needs CI on
this branch.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5 [1M context])

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/33113682857

With regards,
GitHub Actions via GitBox

Reply via email to