Skip to content

port edit-suggestions BRAT tests to Playwright (4 of 5) - #17705

Merged
kevinushey merged 2 commits into
mainfrom
test/migrate-brat-edit-suggestions
May 20, 2026
Merged

kevinushey merged 2 commits into
mainfrom
test/migrate-brat-edit-suggestions

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Summary

Adds `tests/panes/editor/edit_suggestions.test.ts` covering the IDE's deterministic edit-suggestion injection path (`.rs.api.showEditSuggestion`). Four of the five BRAT tests in `test-automation-edit-suggestions.R` ported and green:

  • prefix-matched ghost text accept
  • ghost text moves when content is inserted above
  • ghost text is cleared from the old row when a newline is inserted above
  • inline insertion-preview render + gutter-click accept

The fifth test ("survive document mutations") is `test.fixme`. After typing the first char into an editor with an active ghost-text suggestion, subsequent chars route to the console:

  • `typeSlowly` with a 200ms inter-char delay doesn't help.
  • Per-char `editor.focus()` re-claim between keystrokes doesn't help either -- something between the `focus()` and the next keystroke is moving keyboard focus off the source pane.
  • `editor.insert()` (Ace API) does deliver every char to the editor, but NES tracks its anchor on Ace keyboard events, so a programmatic insert leaves the anchor stuck at the original document position. The gutter-click accept then overwrites our typed characters with the suggestion at the stale range.

Worth filing as a real focus bug -- a fast-typing user during a suggestion would hit the same thing. BRAT counterpart for that one test is retained until it's unblocked.

Also exposes `AceEditor.getLine(row)` and an optional `synthetic` field on `AceToken`, so the synthetic-token check ("old row no longer has a synthetic token") can be asserted directly.

Test plan

  • `npx playwright test tests/panes/editor/edit_suggestions.test.ts --project=desktop` -- 4 pass, 1 skipped (the fixme).

Adds tests/panes/editor/edit_suggestions.test.ts. Drives the IDE's
deterministic .rs.api.showEditSuggestion injection via typeInConsole and
asserts on AceEditor.getTokens/getLine. Four of the five BRAT tests pass:

  - ghost text suggestions can be prefix-matched
  - ghost text moves on document edit
  - ghost text is cleared from old row when newline inserted above
  - edit suggestions render inline when appropriate

"ghost text suggestions survive document mutations" is test.fixme: after
typing the first char into an editor with an active ghost-text
suggestion, subsequent chars route to the console (typeSlowly and
per-char focus re-claim don't help). editor.insert() bypasses focus but
leaves the NES anchor stuck at the original document position. The
BRAT counterpart for that one case is retained until the focus bug is
unblocked.

Adds AceEditor.getLine and an optional synthetic field on AceToken so
the synthetic-token check can be expressed directly.
@kevinushey kevinushey added this to the Blue Plumbago milestone May 20, 2026
@posit-snyk-bot

posit-snyk-bot commented May 20, 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 2aa5b2d into main May 20, 2026
@kevinushey
kevinushey deleted the test/migrate-brat-edit-suggestions branch May 20, 2026 22:34
@kevinushey kevinushey mentioned this pull request May 21, 2026
3 of 5 tasks
kevinushey added a commit that referenced this pull request May 21, 2026
* port path-based guardrails BRAT tests to Playwright

Adds chat-guardrails-paths.test.ts covering 27 tests from
test-automation-guardrails.R: read denials (~/.aws/credentials, ssh,
.env/.Renviron/.Rprofile variants, etc.), read allows (SSH pubkey,
normal files), write denials (outside project, ~/.ssh, file.create /
file.remove / unlink / file.copy / file.rename), write allows (tempdir),
connection denials (file() to sensitive paths, deferred-open variant),
error-message structure (Action/Path/Reason fields), system-file
denials (/etc/passwd, /etc/shadow), and path traversal.

Drives the guardrails directly via .rs.chat.injectBindings() /
.rs.chat.restoreBindings() through a one-shot .rs.test.guardrails(quote(...))
helper installed in beforeAll. Each test runs `pre; helper(...); post` as
one console submission, batching plant/guard/cleanup, and polls for an
R-runtime-generated marker (won't match the input echo) instead of
sleeping. Run time is ~1.3 min for the 27 tests vs ~3.2 min with the
naive blind-sleep design.

Trimmed test-automation-guardrails.R to the 4 binding-lifecycle tests
that stay in BRAT: .rs.chat.safeEval returns errors as conditions rather
than printing them to the console, so the "blocked in console" pattern
the Playwright tests rely on doesn't apply to safeEval/double-inject
coverage. Tracking note added inline.

Side fix: rstudio.fixture.ts:beforeEach was calling
`page.locator(DONT_SAVE_BTN).click({ timeout: 2000 })`, which polls for
the full 2s in the (overwhelmingly common) no-dialog case, adding ~2s
of dead wait to every test. Replaced with `isVisible()` + `waitFor({
state: 'hidden' })` -- no implicit wait when nothing is there, positive
signal when there is.

Migration doc updates: corrects the console.R and data-viewer.R rows
that earlier PRs reverted back to "Partial" via bad merge conflict
resolution; refreshes the summary stats and the "remaining waves"
section to reflect the current state (24 Complete / 4 Partial / 3
Dropped / 1 Fixme).

* port portable rmarkdown and quarto BRAT tests to Playwright

rmarkdown_chunks.test.ts: 7 tests (1 test.skip) covering the
non-skip_on_ci subset of test-automation-rmarkdown.R -- warn-option
round-trip, chunk-widget visibility, error-halt, command-history-after-
error (#16006), patchwork S3-method dump (#13470), paged-table auto vs
explicit (#16483). nb.html-on-save is `test.skip`'d -- `saveSourceDoc`
via the `executeCommand` bridge doesn't trigger nb.html generation;
needs follow-up to understand whether the console path is doing
something the bridge isn't.

quarto_chunks.test.ts: 4 tests covering the non-skip_on_ci subset of
test-automation-quarto.R -- warn-option round-trip on .qmd, chunk-
widget visibility (#11745), variable-width nested-chunk folding
(#15191) via the existing AceEditor wrapper, empty-quarto-block
highlight regression (#16463).

Both new files use the `executeCommand` rstudioCallbacks bridge for
chunk runs instead of `typeInConsole(".rs.api.executeCommand(...)")`
-- the latter pollutes console history, which breaks the
history-after-error test (Up-arrow walks back through the typed
command strings instead of the chunk code).

The 10 skip_on_ci rmarkdown tests (visual-mode round-trips, chunk-
options popup UI) and 7 skip_on_ci quarto tests (visual-mode +
chunk-options popup + doc outline) are dropped along with their BRAT
files. Porting them would need a chunk-options modal helper and a
visual-mode round-trip helper.

Migration doc updated: rmarkdown and quarto now Complete; summary
stats refreshed; remaining-work section rewritten.

* drop orphaned BRAT helper-pane-layout.R

The helper was sourced by test-automation-tabs.R and
test-automation-chat-satellite.R, both of which were deleted in earlier
migration PRs. No remaining BRAT file references it, so the helper is
unused -- removing.

* doc: reflect helper-pane-layout.R removal

* delete remaining BRAT files; add test.fixme stubs for the 6 unported cases

The last three BRAT files (debugger, edit-suggestions, guardrails) had
2-4 tests each retained because they didn't fit the existing Playwright
porting patterns. Rather than keep BRAT alive for those, drop the files
and convert each retained case into a test.fixme placeholder in the
Playwright file that would naturally host it:

- chat-guardrails-paths.test.ts: 4 fixmes for the binding-lifecycle
  tests (.rs.chat.safeEval auto-restore, double-inject reentrancy
  guard, safeEval blocks writes outside project, safeEval restores on
  user error). These ARE portable -- the natural form checks
  file.exists() or a follow-up write succeeding rather than the
  "blocked in console" pattern -- but they were left as TODOs so the
  next person can verify them end-to-end before un-fixme-ing.

- debugger_extras.test.ts: 2 fixmes for the package-build cycle
  tests (#15201 and the #9450 package-rebuild half). Each needs a
  full `devtools::build()` invocation, which takes ~minutes and
  doesn't fit the current fixture model. The BRAT comments are
  preserved so the next port has a starting point.

- edit_suggestions.test.ts: already had its test.fixme since #17705
  (`ghost text suggestions survive document mutations`); the BRAT
  counterpart is now removed.

Migration doc updated: BRAT files remaining = 0; the per-file table
flips debugger / edit-suggestions / guardrails to Complete (with the
fixme counts called out explicitly); the "Remaining" section is now
an inventory of the Playwright TODOs rather than BRAT TODOs.

The Wave 6 decommissioning checklist items (CLI flags, R helpers,
`.claude/CLAUDE.md` BRAT references, the `reference_brat_automation.md`
user memory) are not in this commit -- those land in a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants