Skip to content

fix e2e test failures, support parallel workers, and harden the test harness - #18013

Merged
kevinushey merged 10 commits into
mainfrom
test/data-viewer-pin-selector-and-e2e-timeouts
Jun 18, 2026
Merged

kevinushey merged 10 commits into
mainfrom
test/data-viewer-pin-selector-and-e2e-timeouts

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Summary

Began as an investigation into a failing data-viewer E2E test and grew into a
broader pass over the non-AI E2E suite: fixing the failures it surfaced and
hardening the harness so failures are fast and self-explanatory.

Of the 13 full-suite failures, 11 are fixed here; the other 2 (autocomplete)
were a transient Electron crash during the 1+ hour run and pass reliably in
isolation and full-file, so they need no code change.

Test fixes

  • Data viewer pin/pagination: the pinned body-cell selector and the sidebar
    unpin assertion read elements that now live in a separate frozen pane or are
    virtualized out of the column window since the continuous-column-scroll change
    (Data viewer: scroll continuously through columns instead of paginating #17977). Assert via stable elements (#pinnedBody, the sidebar pin icon).
  • saveDocument on clean documents: it unconditionally issued Save, but
    createAndOpenFile writes-then-opens so the document is already clean (Save
    disabled). Save only when dirty. Fixes the multiline-chunk, notebook-save,
    rmarkdown empty-chunk, and missing-packages-banner tests.
  • Global Options keyboard accessibility (6 tests): removed the interim,
    dev-only (SuperDevMode) dark-theme toggle button (dark theme support for modal dialogs #17242) injected into the
    dialog caption -- as a focusable button before the body in DOM order it
    displaced the modal focus trap's first/last controls, breaking initial focus
    and Tab/Shift+Tab wrapping in dev/draft builds only. The dark-theme-modal
    support itself (the pref + syncDarkThemeClass) stays.

Harness / iteration improvements

  • executeCommand now waits for the target AppCommand to be enabled (not
    just present) and, on timeout, throws an error naming the command. Executing a
    disabled command otherwise tripped an opaque dev-build assertion
    (AppCommand executed when it was not enabled) and hung the test.
  • Lowered the global per-test timeout from 5m to 2m, with explicit higher
    budgets on the package-installing hooks/tests that need them, and dropped
    redundant/sub-global per-test overrides.
  • --timeout duration units (30s / 1m / 2000ms) in the dev run scripts.

Parallel workers

  • The Desktop suite can now run with --workers > 1: per-worker
    HOME/USERPROFILE and hermetic hardlink-cloned R libraries, activated only
    when workers > 1 (resolved into PW_TOTAL_WORKERS by globalSetup) so the
    default single-worker run is byte-for-byte unchanged. Validated with
    --workers=2.

Notes

  • Primarily E2E test-infrastructure and test-fix work, plus one small dev-only
    product change (the modal toggle-button removal); not tied to a single
    tracking issue.

The "pinned column stays pinned across column pagination" test looked for
the pinned body cell in #gridBody, but #17977 moved pinned cells into the
frozen pane's own table (#pinnedBody). Point the selector at #pinnedBody.

Lower the global per-test timeout from 5 min to 2 min so a hung test fails
fast, and shift the slow-path budget to where it's actually needed:

- drop redundant (== global) and tighten-only (< global) test.setTimeout
  overrides, letting the global govern
- add test.setTimeout() to package-installing beforeAll hooks (and one
  in-test install) whose budgets exceed the new global, since a hook's
  timeout inherits the global and a cold-cache install would otherwise be
  killed mid-install
…ries

Running the Desktop suite with more than one worker previously clobbered
shared state. Partition the two remaining shared writers per worker,
activated only when workers > 1 (resolved into PW_TOTAL_WORKERS by
globalSetup) so the default single-worker run is unchanged:

- HOME / USERPROFILE: each worker copies the seeded template home into a
  per-parallel-index subtree, so RStudio user state, command history, and
  seeded AI credentials don't collide.
- R_LIBS_USER: each worker gets a hermetic hardlink clone of the prebuilt
  template library (not layered with it), so a test can install or remove
  packages -- including the uninstall/reinstall tests -- without racing on
  a shared library or leaking across workers. The clone uses fs.linkSync
  (portable to Windows/NTFS, no elevation), stays on the same volume as the
  template, and is built via a temp dir + atomic rename.

Validated with --workers=2: two workers ran concurrently with separate
homes and clones, and the DBI/praise uninstall tests passed alongside the
console tests.
…aced

executeCommand now waits for the target AppCommand to be enabled (not just
present) before dispatching, and on timeout throws an error naming the
command. Executing a disabled command otherwise trips a dev-build assertion
in AppCommand.execute() -- the handler never runs, surfacing as an opaque
"AppCommand executed when it was not enabled" client exception plus a
downstream hang. Gating here absorbs brief command-state lag and makes the
failure self-explanatory.

This surfaced that saveDocument unconditionally issued Save even when the
active document was already clean (createAndOpenFile writes the file to disk
then opens it, so Save is correctly disabled). Save only when the document
is dirty; the clean-state wait covers both branches. Fixes the multiline-
chunk, notebook-save, rmarkdown empty-chunk, and missing-packages-banner
tests.

Also: the dev run scripts now accept --timeout durations with units
(30s / 1m / 2000ms / bare ms), so a capped-timeout iteration loop reads
naturally instead of requiring raw milliseconds.

Separately, the data-viewer sidebar pin/unpin test asserted unpin by reading
column 2's header, but once unpinned the column returns to its far-left
position, scrolled out of the virtualized column window with no rendered
<th>; assert via the always-present sidebar pin icon instead.
The SuperDevMode-gated dark-theme toggle button (#17242) was injected into
the dialog caption, which sits before the dialog body in DOM order. As a
focusable <button> it became the first element returned by
getFocusableElements(), displacing the real first/last controls the modal
focus trap relies on. In dev/draft builds this broke initial keyboard focus
and Tab/Shift+Tab wrapping -- the Global Options keyboard-accessibility tests
failed in test:desktop-dev while passing in production builds (where the
button is never added).

It was an interim affordance for manually checking dark dialogs; the actual
dark-theme-modal support (the useDarkThemeModalDialogs pref and
syncDarkThemeClass) stays. Removing the button restores the focus order.
@kevinushey kevinushey added this to the 2026.07 (Pacific Dogwood) milestone Jun 17, 2026
The CDP port was random per worker (9231 + random 0..68). With a few parallel
workers there was a real chance two drew the same port, and since each launch
reclaims its port with `lsof :PORT | kill -9`, the second worker would kill the
first worker's live RStudio -- a likely source of SIGKILL / "target page
closed" flakiness under --workers > 1. Derive the port deterministically from
the parallel index (base + index) so workers never share one; the dev/logger
ports (+1000/+2000) follow and stay disjoint. PW_CDP_PORT still overrides.
@github-actions

github-actions Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
397 0 19 2
📥 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 a8ef31b8e11893966c786ef52b84432e2cb254ef · Run #94

executeCommand gated on AppCommand.isEnabled(), which is enabled_ && isVisible().
doExecute() only requires enabled_, so an invisible programmatic command
(visible="false", e.g. restoreDefaultPaneAndTabLayoutNoPrompt) always reports
disabled yet dispatches fine -- the gate blocked it forever (10s "did not become
enabled"). This broke pane_layout.test.ts's afterAll resetUILayout when the test
ran in isolation. Expose isVisible() on the automation bridge and pass the gate
when isEnabled() || !isVisible(); visible commands keep the fail-fast behavior.

Also make the @smoke startup test opt-in. It idles 30s against a 30s timeout
(full runs cap it lower), so it is the first casualty under parallel load and is
redundant alongside the full suite. Exclude it from both projects by default via
grepInvert; opt in with PW_RUN_SMOKE=1. Give it its own 60s timeout so it is
usable when run.
@gtritchie

Copy link
Copy Markdown
Member

Code review findings

Actionable items from an automated multi-agent review (general code quality, silent failures, comments, test coverage). Strengths, verified-correct items, and ratings are omitted. No critical issues were found.

Important

  1. e2e/rstudio/tests/panes/editor/notebook_save_during_execution.test.ts:20-28 — this install hook (ensurePackages(['ggplot2', 'nycflights13'], 120000)) was not given the test.setTimeout(300000) bump that the ~10 structurally identical install hooks in this PR received. The file isn't in the diff, so the global-timeout lowering (5m→2m) reaches it transitively and the sweep missed it. Warm-cache risk is low (both packages are in REQUIRED_PACKAGES and pre-populated), but on a cold/failed-prep cache the hook can hit the 2m wall mid-install. Fix: add test.setTimeout(300000); at the top of the beforeAll, matching the sibling hooks.

Suggestions

  1. e2e/rstudio/fixtures/r-libs-setup.ts:284-287 — when workers > 1 but PW_R_LIBS_TEMPLATE is unset (prep skipped via PW_RSTUDIO_R_LIBS_SKIP_PREP, or Rscript expansion failed), workerRLibsUser silently falls back to the shared library token with no log line, so the per-worker hermetic isolation the README advertises is gone and the uninstall/reinstall tests can race across workers. The docstring acknowledges the degraded mode, but a comment isn't visible while debugging a flaky parallel run. Fix: emit a console.warn here naming the lost isolation.

  2. e2e/rstudio/fixtures/desktop.fixture.ts:82-95 — workerUserHome uses an existsSync-guarded fs.cpSync, which isn't crash-safe: a copy interrupted mid-flight leaves a partial home that later reads as complete, so a worker can launch against a half-seeded HOME (missing seeded AI creds / Windows AppData scaffold). The R-libs clone in r-libs-setup.ts:298-303 solves this exact hazard with a .partial temp + atomic renameSync. Fix: mirror that atomic pattern here, or at minimum log the seed.

  3. e2e/rstudio/utils/commands.ts:379-393 — saveDocument reads dirty and confirms-clean in two separate page.evaluate round-trips. The bridge-absent / null-doc case correctly throws via the wait (not silent), but if the active document switches between the two reads, a dirty doc could be left unsaved while the wait passes on a different clean doc. No current caller triggers this interleaving. Optional hardening: capture doc.id at the gate and assert the wait observes that same id clean.

  4. e2e/rstudio/tests/smoke/startup.test.ts:5-7 — the comment says "the 30s default test timeout" and "full runs cap the global timeout even lower", but the suite configures timeout: 120000 (not 30s) and doesn't go below 30s. The reasoning (30s idle + 30s readiness wait can exceed a tight budget → pin 60s) is valid; the prose mislabels the value. Fix: reword to reference the configured budget rather than the framework default.

  5. Repeated test.setTimeout(300000) comment over-claims and is drift-prone (10+ near-identical copies, e.g. e2e/rstudio/tests/panes/editor/markdown.test.ts:22, rmarkdown.test.ts:23, notebook_inline_chunks.test.ts:46, rnotebook.test.ts:50) — "keep the headroom this install hook's ensurePackages() budget assumes" implies 300s is the budget, but those calls pass 180_000 (and ensurePackages defaults to 60s), so 300s is slack above the budget. The text has already drifted (htmlwidgets.test.ts / shinytest2.test.ts phrase it differently). Fix: use a single shared constant/comment or simpler wording ("cold-cache installs can outrun the 120s global timeout").

  6. e2e/rstudio/scripts/dev-common.ts:403-415 — parseDurationMs is a pure parser (regex + unit conversion + rounding, verified correct on 1.5m, 2000ms, 0, "", abc, -5s, whitespace) with no unit test. Deferred, not blocking: e2e/rstudio has no unit-test runner, so adding a dependency for one helper isn't worth it now — track as the obvious first test if a runner ever lands.

…rent launch

The Electron app chose the rsession backend www-port with generateRandomPort()
-- an unverified random number in [8080, 48080) -- and never re-picked it if
the bind failed. Two RStudio instances starting at the same time (e.g. parallel
E2E workers, or a user opening several projects at once) could draw the same
port; the second rsession then fails to bind with EADDRINUSE and the IDE never
loads. The existing EADDRINUSE retry in SessionHttpMethods only covers the
same-port restart race within one session, not initial cross-instance
collisions, so nothing recovered.

Add findFreePort(), which probes random candidates with a real bind on
127.0.0.1 and returns one that is actually free (falling back to an unverified
random port if probing fails). Allocate the port through it:

- generateNewPort() is now async and awaits findFreePort().
- launchFirst() now probes a fresh free port instead of reusing the unverified
  random port assigned at construction.
- buildLaunchContext()/launchNextSession() and the two call sites in
  main-window/session-launcher are threaded through the now-async port
  allocation; the session-exit and main-window launch paths handle the
  returned promise.

A narrow time-of-check/time-of-use window remains, but it is far smaller than
trusting an unverified random number, which was the dominant collision source
under parallel launches. Companion to the parallel-worker E2E support in this
branch.
@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🪟 Windows Desktop E2E · Server 2025 x64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
403 0 16 1
📥 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 · Windows Server 2025 x64 · commit a8ef31b8e11893966c786ef52b84432e2cb254ef · Run #94

GrepOperation::onStdout processed grep output against the shared
findResults() singleton without checking that the output belonged to the
current operation. When a Replace All superseded a still-draining find or
replace preview, the stopped operation's buffered stdout was processed
under the new operation's configuration -- corrupting its results and, in
replace mode, writing files under the wrong config. This surfaced as a
Replace All that modified the file on disk but reported "(No results
found)". Mirror the guard onContinue already applies: drop output once the
operation is no longer current.

Also keep the Replace All action disabled while a find or replace is in
flight (re-enabled when it ends or is stopped) so a replace cannot be
started over a running operation, and mirror the button's disabled state
to aria-disabled so it is observable. Wait for the find to finish in the
Replace All e2e tests.
Entering replace mode before the find finished built the replace preview
from incomplete search results, so a non-regex replacement showed no
matches. Gate the Find->Replace toggle on the find completing (greyed out,
pointer input blocked, aria-disabled set) by folding it into the existing
disableReplace/enableReplace, which already run at find begin/end. The
Replace->Find toggle stays usable. The replace e2e tests now wait for the
find to finish before toggling.
@kevinushey
kevinushey merged commit 9a54041 into main Jun 18, 2026
8 of 11 checks passed
@kevinushey
kevinushey deleted the test/data-viewer-pin-selector-and-e2e-timeouts branch June 18, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants