Skip to content

stabilize pane-layout e2e tests and fix sidebar zero-width squeeze - #17795

Merged
kevinushey merged 15 commits into
mainfrom
test/e2e-stabilize-resets-and-animations
May 29, 2026
Merged

kevinushey merged 15 commits into
mainfrom
test/e2e-stabilize-resets-and-animations

Conversation

@kevinushey

@kevinushey kevinushey commented May 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stabilizes the pane-layout end-to-end tests, fixes an underlying
Source/Console zero-width bug uncovered while doing so, and folds in a set
of broader e2e reliability fixes surfaced by a full non-AI test run.

Product fix

  • Sidebar show no longer leaves Source/Console invisible. Showing the
    sidebar takes its width from the center (fill) column, so restoring a
    saved layout that no longer fits -- or a first-time show -- could squeeze
    Source/Console to ~0. After the post-show relayout, if the center is
    below a minimum width the other columns are reset to default widths to
    reclaim space. A center the user deliberately collapsed via the middle
    splitter is recorded at hide time and restored as-is, so the reclaim only
    triggers on an involuntary squeeze.

Test stabilization

  • Replace the fixed 300ms sleep after re-showing the sidebar with a
    waitForStableWidth on the sidebar pane in the visibility-preservation
    tests, removing a slow-CI race.
  • Add deterministic coverage for the sidebar reclaim fix's "preserve a
    deliberately-collapsed center" branch.
  • Per-test reset readiness gate: resetForNextTest now waits for
    window.rstudio.ready === true before driving the IDE, fixing a class of
    post-relaunch/post-reload flakes (bridge "markers not found", offsetWidth
    read of 0 before layout).
  • ensureVisualMode now waits for the .ProseMirror surface to mount
    instead of a fixed 2s sleep, fixing the "rmd templates display" failure
    (heavier templates convert slower than 2s).
  • Output-less chunk execution now brackets on R's busy/idle state rather
    than injecting a synthetic console marker that raced the chunk's
    asynchronous console feed -- the old path corrupted multi-line chunks
    ("Incomplete expression") and made the patchwork patchwork plots cause internal data to be dumped into chunk outputs #13470 test pass
    vacuously. Adds waitForConsoleBusy.
  • Per-test reset, sandbox paths, and pane-animation handling reworked for
    determinism; scope the execute_from_editor run-line button to the
    visible editor; review-nit fixes to reset/fixture/path comments.

Testing

ant javac clean. Targeted desktop-dev runs: full panes.test.ts (21/21,
incl. the new preserve test), rmarkdown.test.ts + quarto.test.ts (visual
mode), and rmarkdown_chunks.test.ts (patchwork now runs for real, 8.0s).

Known pre-existing failure (not addressed here)

rmarkdown_chunks.test.ts "saving an R Notebook creates an nb.html file"
fails because saving an html_notebook never clears the document's dirty
flag (a plain .Rmd saves fine in the same sandbox). It is specific to
notebook saving on this build, unrelated to pane layout, and not a timing
issue -- tracked separately.

Reduce cross-test flakiness traced to leaked modal dialogs, a close/delete
race, unguarded sandbox paths, and pane animations.

- reset: clear the whole GWT modal stack via dialogs.dismissAll at the start
  of resetForNextTest instead of clicking a single Don't Save button, so a
  leaked "Save File" error / "File Deleted" prompt can't block the next test.
- resetSourcePaneState now waits for its async close chain to settle before
  returning. closeAndDeleteSandboxFiles relied on this implicitly and was
  deleting files while editors still held them open -- the source of the
  "system error 2" Save File dialogs that then leaked into later tests.
- sandbox: assert a non-empty absolute path in createSandbox,
  createAndOpenProject, writeAndOpenFile, and closeAndDeleteSandboxFiles, so an
  unpopulated sandbox.dir fails loudly instead of building a root-relative
  "/<name>" path (the confusing "Error Opening Project" modal). Adds timeline
  logging and an empty-read guard in useSuiteSandbox for diagnosis.
- animations: enable reduced_motion in automation prefs (base-prefs.jsonc and
  the server fixture) so pane minimize/maximize/zoom transitions apply
  synchronously and can't leave the Source pane stuck minimized. Animation
  tests override the pref per-suite.

Validated locally (desktop-dev): the dialog-leak cascade is gone (0
PopupPanelGlass / Save File / File Deleted across the run) and reduced_motion
cleared the findFromSelection, notebook-save, and layoutZoom failures.
…ditor

A bare [class*=run_the_current_line_or_selection].first() also matched the hidden Untitled placeholder tab's button (kept by resetSourcePaneState), so .first() picked the hidden one and the click timed out as 'not visible'. Add SourcePane.runLineBtn scoped to the visible tabpanel (matching saveBtn et al.) and use it from the test.
Showing the sidebar takes its width from center_ (the fill column), so
restoring a saved layout that no longer fits, or a first-time show, could
squeeze the Source/Console column to ~0 and leave it invisible. Reclaim
space by resetting the other columns to default widths once the post-show
relayout reveals a sub-minimum center.

A user can also deliberately collapse the center via the middle splitter.
In that case restoring it near-zero on the next sidebar show is the
correct, faithful restore, not a squeeze -- so record whether the center
was already collapsed when the sidebar was hidden and skip the reclaim
when restoring that state.
…ggle

The sidebar-visibility preservation tests slept a fixed 300ms after
re-showing the sidebar before reading column widths, which lost the race
on slow CI. Settle on the sidebar's own width instead: it reveals in the
same relayout pass as the columns, so once it stops animating the column
widths are final.
@kevinushey kevinushey added this to the Blue Plumbago milestone May 28, 2026
@posit-snyk-bot

posit-snyk-bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gtritchie

Copy link
Copy Markdown
Member

Review Summary

A well-scoped PR: a real GWT product fix (sidebar show no longer collapses Source/Console to ~0) plus solid e2e stabilization work. The code is sound — no critical bugs found. Two issues are worth addressing before merge.

Important Issues

1. Comment-rot: "animation tests override reduced_motion" describes a pattern that doesn't exist
e2e/rstudio/fixtures/base-prefs.jsonc:18 and e2e/rstudio/fixtures/server.fixture.ts:269
Both comments claim tests override the pref with setPref(page, 'reduced_motion', false) and restore it. A full search finds no test that does this — the only writers are these two fixtures, both setting true. A future maintainer will trust a convention that isn't implemented. Fix: drop the sentence or reword as forward-looking intent ("if a future test needs real animations, override per-test...").

2. resetForNextTest doc promises a hook that can't fail, but three of its four steps can throw
e2e/rstudio/utils/test-reset.ts:67,101,108
The contract ("best-effort: don't fail the hook") is only enforced on the inner settle-waits. dismissAllModals(page), the page.evaluate inside resetSourcePaneState, and executeCommand(page, 'activateConsole') are all unguarded — if window.rstudio is gone they throw out of beforeEach, failing the next test with a misleading reset-hook stack (exactly what the contract aims to avoid). Decide explicitly: either guard those calls and warn, or narrow the comments to say only the settle-waits are best-effort while structural failures intentionally fail loud.

Suggestions

  • Missing test coverage for both branches of the fix (e2e/rstudio/tests/panes/layout/panes.test.ts). Neither the reclaim branch nor the preserve-deliberately-collapsed branch (savedCenterCollapsed_) is actually exercised — no test drives the center column below MINIMUM_CENTER_WIDTH (50px) before a sidebar show. The claim that the existing 20-test suite covers the fix is inaccurate; those are flakiness fixes on pre-existing tests. The waitForStableWidth infrastructure to write these reliably already exists. The savedCenterCollapsed_ preserve branch is the one most likely to regress unnoticed.
  • numModalsShowing(page).catch(() => 0) e2e/rstudio/utils/test-reset.ts:68 — catching to 0 means a failed count read produces no warning, a false-negative on the very signal this block exists to emit. Consider .catch(() => -1) and warn on < 0.
  • Imprecise comment in paths.ts — the cited bad input "/reformat-styler-project/..." is actually accepted by path.win32.isAbsolute. The guard correctly rejects the real failure input (empty string ''), so it works; the comment's example is the downstream symptom, not an input the guard screens. One-line tweak someday.

Recommended Action

  1. Fix the reduced_motion comment rot (Clone fail-Permission denied (publickey) #1) — quick, clearly wrong.
  2. Resolve the resetForNextTest contract mismatch (Autocompletion of delimiters #2) — decide guard-vs-narrow-comments.
  3. Consider adding the two targeted layout tests, or drop the claim that the existing suite covers the fix.
  4. Optionally apply the minor numModalsShowing and paths.ts comment tweaks.

The product fix itself is shippable as-is; the action items are about test coverage and doc/contract accuracy, not correctness of the fix.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Some non-blocking nitpicks re: tests, comments

kevinushey added 11 commits May 28, 2026 16:51
Per PR #17795 review feedback:
- reduced_motion: reword the base-prefs and server-fixture comments to
  forward-looking intent; no test currently overrides the pref, so the old
  "tests override this" wording described a convention that doesn't exist.
- resetForNextTest: document the error-handling contract explicitly -- the
  debug-exit step is guarded/best-effort, while modal dismissal, source-pane
  reset, and console focus intentionally fail loud if the automation bridge
  is gone (guarding the source reset would silently leak buffers forward).
- numModalsShowing: use a -1 sentinel on read failure instead of 0, so a
  failed count read warns rather than masquerading as "no modals left".
- paths.ts: clarify that the screened input is an empty sandbox.dir; the
  root-relative path is the resulting symptom, not what the guard rejects.
Per PR #17795 review feedback: the existing suite exercised the reclaim
branch (via "Sidebar show uses default widths after columns resized while
hidden") but not the savedCenterCollapsed_ preserve branch deterministically.

Add a test that deliberately collapses the center column below the minimum
width via the middle splitter, hides and re-shows the sidebar, and asserts
the center is restored as-is rather than reclaimed to a default width. Also
add comments to both tests naming which MainSplitPanel branch each covers.
The worker-scoped session can be mid-relaunch or mid-reload when a spec
starts (a prior test reloaded the page, or the session restarted), so
window.rstudio may be installed while the workbench is still wiring up.
Driving it then races init -- a command bridge call returns "markers not
found", or an offsetWidth read returns 0 before layout (both seen as
intermittent failures, e.g. create_projects and "Default quadrants").

Wait for window.rstudio.ready === true at the top of resetForNextTest --
the DeferredInitCompletedEvent signal openProject already relies on. It's
independent of any leaked modal (a glass panel doesn't reset ready, and the
dismissAll in step 1 clears it via the bridge regardless), and a genuinely
dead session still fails loud here with a precise timeout.
ensureVisualMode clicked the toggle then slept a fixed 2s and returned,
gating the click on aria-pressed === 'false'. For a heavier document (an
R Markdown template with chunks/plots) the pandoc->ProseMirror conversion
outlasts 2s, so callers asserted against a still-source-mode editor and the
.ProseMirror lookup found nothing ("rmd templates display" failed here).

Detect mode via the .ProseMirror surface and wait for it to actually mount
instead of sleeping, so the helper returns only once visual mode is live.
For chunks with no visible output, the helper cat()'d a synthetic marker via
the console right after dispatching executeCurrentChunk. But that command only
dispatches -- the chunk feeds the console asynchronously -- so for a multi-line
chunk the marker landed mid-continuation, corrupting R's input buffer
(NotebookQueue raised "Incomplete expression") and silently skipping the chunk
body. The patchwork #13470 test then passed vacuously: its registerS3method
override never installed, so of course no output dumped.

Drop the marker and bracket the chunk on R's busy state instead -- wait for the
console to go busy (tolerating a chunk too fast to observe it) then idle. No
input-buffer race, and no console-history pollution. The patchwork test now
runs the override for real (8.0s vs 2.1s) and still passes.

Adds waitForConsoleBusy alongside waitForConsoleIdle.
executeInConsole was fire-and-forget, so firing several commands in
quick succession left the later ones queued (not yet in recall history)
when a test started navigating. That made the console "arrow keys cycle"
test flaky: a single ArrowUp recalled the only history entry.

Wait for R to go idle by default (opt out with wait: false for the
fire-and-forget pattern). Simplify ensurePackage/uninstallPackage to
wait-for-idle instead of polling a done-marker, and read TRUE/FALSE via
parens auto-print + a [1]-anchored regex instead of unique markers.

Tag the flaky edit_suggestions "prefix-matched" test @ai to defer it.
.rs.api.showDialog/showPrompt/showQuestion block the R thread until the
client dismisses the modal, so with executeInConsole now waiting for R
idle by default these timed out. Submit them fire-and-forget (wait:
false) and drive the dialog from the test as before.
Cases 4/5/6 (all useAir=true) require the Air binary; on a runner
without it they fail with unformatted output. Add a beforeAll preflight
that calls .rs.air.ensureAvailable() (mirroring the reformat path,
autoinstall included) and skips those three cases when Air can't be
resolved. The useAir=false cases keep running everywhere.

Promote ConsolePaneActions.evalRLogical to a public state-probe helper
so the preflight can read the availability boolean from R.
Rewrite the local waitForSessionRestart in create_projects to poll
window.rstudio.ready (false->true across the restart) instead of echoing
a cat() marker through the console. The marker loop was flaky: the marker
could land in the old console moments before the in-place restart cleared
it, and each inner executeInConsole idle-wait could consume the whole
budget. closeCurrentProject and createProjectInNewDir now pre-reset the
flag before triggering the restart so the wait sees a clean edge rather
than the prior session's stale true.

Also enrich openProject's active-project post-check: when ready flips true
but the path never matches (a silently-failed open, since
OpenProjectErrorEvent also sets ready=true), surface the actual active
project instead of an opaque waitForFunction timeout.
@kevinushey
kevinushey merged commit 9981a05 into main May 29, 2026
8 checks passed
@kevinushey
kevinushey deleted the test/e2e-stabilize-resets-and-animations branch May 29, 2026 15:49
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

Development

Successfully merging this pull request may close these issues.

3 participants