Skip to content

run per-test e2e resets via auto fixture; capture client exceptions; pin test geometry - #17956

Merged
kevinushey merged 2 commits into
mainfrom
test/e2e-harness-robustness
Jun 12, 2026
Merged

kevinushey merged 2 commits into
mainfrom
test/e2e-harness-robustness

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Fixes #17954. Fixes #17955.

Follow-ups from validating #17953 -- the residual environment-pane flake turned out to be a deeper harness defect, and chasing it surfaced a product bug.

Product fix (#17954)

ImageFrame.replaceLocation (Plots pane) dereferenced el.contentWindow unconditionally; during pane re-parenting (quadrant swaps, snap-to-minimize churn on short windows) it is null, and the read raised an uncaught TypeError shown to the user as an error dialog. Now reports not-ready, feeding the existing onLoad retry. Verified: pane_layout.test.ts goes from 15/16 to 16/16 at 1024x640.

Harness fixes (#17955)

  • Per-test reset as an auto fixture. The module-scope test.beforeEach only attached to the first spec file loaded per worker (Node module caching), so every later file ran without resets -- the actual mechanism behind the environment-pane first-test flake. Auto fixtures run for every test in every file. Verified: three files in one worker, resets fire for each file, all green at the geometry that previously reproduced the flake.
  • Uncaught client exceptions fail the test that raised them. The automation agent wraps the uncaught-exception handler and records message + stack into window.rstudio.errors; the fixture drains it after every test (failing with the stack in the output; PW_IGNORE_CLIENT_EXCEPTIONS=1 downgrades to warnings), and warns with contents for any leaked modal the reset dismisses. New harness self-test exercises the chain end-to-end via errors.simulate() (a real throw from a $entry context), including a test.fail()-inverted check that the fail-on-exception machinery actually fails tests.
  • Pinned window geometry: 1024x645 for local and CI. macOS clamps windows to the visible frame, so CI was already running at its 1024x645 workArea while local ran 1400x900 -- geometry-sensitive bugs surfaced only on CI. 800x600 was evaluated and rejected (genuinely cramps layouts: data-viewer column tests, Import Dataset dialog; 7 failures).

Verification

87 tests green locally at the pinned geometry in one run: tests/harness, rnotebook + environment_pane (the CI failure sequence, same worker), all of tests/panes/layout, and all of tests/panes/data-viewer. ant javac and the e2e typecheck pass.

ImageFrame.replaceLocation dereferenced el.contentWindow unconditionally;
while the iframe is detached or being re-parented (e.g. a pane-layout
quadrant swap moving the Plots pane, which short windows make more likely
via the snap-to-minimize churn), contentWindow is null and the read threw
an uncaught TypeError surfaced to the user as an error dialog. Report
not-ready instead; the onLoad retry timer already repaints the stored URL
once the frame has a window again.
…exceptions

Three robustness fixes for the desktop e2e harness:

- The per-test reset was registered as a module-scope test.beforeEach in
  rstudio.fixture.ts. Node caches the module per worker, so the hook only
  attached to the FIRST spec file each worker loaded -- every later file
  ran with no per-test reset at all, which is how a leaked Viewer maximize
  from rnotebook.test.ts hid the Environment tab for the next spec's first
  test. The reset is now an auto test-scoped fixture, which runs for every
  test in every file regardless of module caching.

- Uncaught client exceptions are now recorded by the automation agent
  (window.rstudio.errors: message + stack + time, wrapping the default
  uncaught-exception handler) and drained after every test; a test that
  raised one fails with the stack in its output (opt out with
  PW_IGNORE_CLIENT_EXCEPTIONS=1). Previously the only artifact was an
  "Error" dialog with no stack, which the next reset silently dismissed.
  The reset also logs the text of any leaked modal dialog it dismisses.

- The test window geometry is pinned to 1024x645 -- the macOS CI runner's
  display workArea, to which macOS silently clamps the previous 1400x900
  request -- so local runs and CI exercise the same layout and
  geometry-sensitive bugs no longer surface only on CI. 800x600 was
  evaluated and rejected (cramps layouts; 7 test failures).
@kevinushey kevinushey added this to the Blue Plumbago milestone Jun 12, 2026
@kevinushey
kevinushey merged commit d663a5f into main Jun 12, 2026
1 of 2 checks passed
@kevinushey
kevinushey deleted the test/e2e-harness-robustness branch June 12, 2026 07:24
@github-actions

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

❌ 1 test(s) failed

███████████████████░ 99% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
371 1 9 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit dd099b666a3b056537046b1c293c738214600aeb · Run #236

kevinushey added a commit that referenced this pull request Jun 12, 2026
ScrollUtil.setScrollPositionOnLoad polled the preview frame's document
from a 50ms Scheduler timer with no try/catch. When the frame is
transiently cross-origin (mid-navigation or an interim error page),
reading contentWindow.document throws a SecurityError, which killed the
polling loop (so the scroll position was never restored) and surfaced
as an uncaught client exception that fails e2e tests since #17956.

Treat a throw like the other not-ready cases and keep polling, matching
the guarded versions of this same access in RmdOutputFramePane.
kevinushey added a commit that referenced this pull request Jun 12, 2026
* add a clear-sort button to the data viewer status bar

When a column sort is active, the "Sorted by: <column>" status at the
right of the info bar now includes a small X button that clears the
sort, restoring the frame's natural row order. The status element is
split into a text span plus a persistent button so the button's click
listener survives info-bar updates.

* use theme-aware mask icons for clear-sort and clear-filter buttons

* clarify clear-sort aria-sort comment; test cleared sort survives a refresh

* guard rmd scroll-restore poll against unreadable viewer frames

ScrollUtil.setScrollPositionOnLoad polled the preview frame's document
from a 50ms Scheduler timer with no try/catch. When the frame is
transiently cross-origin (mid-navigation or an interim error page),
reading contentWindow.document throws a SecurityError, which killed the
polling loop (so the scroll position was never restored) and surfaced
as an uncaught client exception that fails e2e tests since #17956.

Treat a throw like the other not-ready cases and keep polling, matching
the guarded versions of this same access in RmdOutputFramePane.
kevinushey added a commit that referenced this pull request Jul 2, 2026
The useSuiteSandbox beforeAll start/done bracket and the createSandbox
workdir echo were timeline instrumentation added in #17795 to correlate
"Error Opening Project" / empty-dir failures against sandbox creation.
That failure mode has since been root-caused (module-scope hooks vs
fixtures, #17955/#17956), so the three lines are now just per-suite log
noise. The real diagnostics stay: the empty-dir read warning (with
stack) and the not-under-PW_SANDBOX warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant