Skip to content

test(e2e): pin desktop window size; route AceEditor through activeEditor - #17788

Merged
kevinushey merged 3 commits into
mainfrom
test/desktop-fixture-window-size
May 28, 2026
Merged

kevinushey merged 3 commits into
mainfrom
test/desktop-fixture-window-size

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Summary

Two related fixes for flakes surfaced by the full e2e run on #17785 (3 unique edit_suggestions failures on macOS GH Actions).

  • Pin Electron window to 1400x900 in desktop.fixture.ts. The schema default (1200x900) gets clamped by positionAndEnsureVisible to the runner's small virtual display (~1024x645), which drops the left column's source pane under DualWindowLayoutPanel's 60px snap threshold. The layout then promotes the Console to MAXIMIZE state and the source pane visually disappears, breaking any test that types into it. positionAndEnsureVisible accepts requested bounds that intersect any display.workArea as-is, so 1400x900 at the origin sticks even on narrow virtual displays.
  • Route empty-marker AceEditor through the window.rstudio.documents.activeEditor() bridge. Same stale-editor bug fixed for openFile/getEditorContent (ad175dc / test(e2e): expose active ace editor via automation bridge #17775) and getCompletionsInEditor (test(e2e): use activeEditor bridge in autocomplete actions #17784). Empty marker would trivially match any editor's value, so the DOM walk could land on a stale editor left in the DOM after a tab close. Non-empty markers keep the DOM-walk path (still needed for targeting non-active tabs).
  • Drop the eval-based runOnEditor while in there. The previous shape stringified the user callback via fn.toString() and reconstituted it in the browser with (0, eval)('(' + fnSource + ')') to work around page.evaluate's single-arg signature. Replace with page.evaluateHandle + handle.evaluate, which serializes the function natively.

Test plan

  • Re-run macOS desktop e2e suite; confirm the three previously failing tests pass:
    • panes/editor/edit_suggestions.test.ts >> ghost text suggestions can be prefix-matched
    • panes/editor/edit_suggestions.test.ts >> ghost text moves on document edit
    • panes/editor/edit_suggestions.test.ts >> ghost text is cleared from old row when newline inserted above
  • Confirm panes/layout/panes.test.ts ratio-based width assertions still pass with a wider viewport (10% tolerance).
  • Spot-check other new AceEditor(page, '') callers in tests/panes/editor/reformat.test.ts and tests/panes/editor/rmarkdown.test.ts.
  • npm run typecheck passes locally.

avoids dualwindowlayoutpanel auto-snapping the left column to maximize
on the small (~1024x645) macos gh actions virtual display, which was
hiding the source pane and breaking edit_suggestions tests.
empty-marker AceEditor was scanning .ace_editor DOM nodes and picking the
first non-console match -- same stale-editor bug fixed in ad175dc
(#17775) for openFile/getEditorContent and f84e454 (#17784) for
autocomplete actions. on tests with a single open file the marker '' would
trivially match, but the matched node could be a stale editor left in the
DOM after a tab close rather than the live active editor.

route empty marker through window.rstudio.documents.activeEditor() and
keep the DOM-walk path for non-empty markers (still useful when a test
needs a specific non-active tab).
the previous shape stringified the user's callback via fn.toString() and
reconstituted it in the browser with (0, eval)('(' + fnSource + ')').
that was the only way to ferry an arbitrary user function across the
node->browser boundary through page.evaluate's single-arg form.

replace it with page.evaluateHandle to resolve the editor once, then call
handle.evaluate with the user's function natively (playwright serializes
the function itself, no eval). overload run() so callers that pass no arg
stay typed; callers that need multiple args wrap in an object.

no behavior change for callers; the eval was a workaround the bridge has
since obsoleted.
@kevinushey kevinushey added this to the Blue Plumbago milestone May 27, 2026
@posit-snyk-bot

posit-snyk-bot commented May 27, 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.

@kevinushey
kevinushey merged commit 5135e8b into main May 28, 2026
7 of 8 checks passed
@kevinushey
kevinushey deleted the test/desktop-fixture-window-size branch May 28, 2026 03:16
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