Skip to content

Add Connections pane e2e tests for PostgreSQL and SQLite - #18648

Merged
ronblum merged 42 commits into
mainfrom
test/ron/e2e-connections-pane
Aug 28, 2026
Merged

ronblum merged 42 commits into
mainfrom
test/ron/e2e-connections-pane

Conversation

@ronblum

@ronblum ronblum commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Adds a Playwright e2e suite for the Connections pane: the New Connection
wizard, connecting/disconnecting, the object explorer, and running queries
over a connection. Covers PostgreSQL and SQLite, on Desktop, across macOS,
Windows, and Linux.

Two test.fixme cases are parked and documented inline: verifying a
wizard-generated script actually connects when run (no reliable way found to
run it from a test), and a connection-removal list-refresh check (the app
doesn't always refresh the list immediately, a real product quirk, not a
test bug).

Caveat: this is not a real test of Server. A Server-only bug makes the New
Connection wizard disappear right after a session restart, so the tests that
actually connect, browse, or query a database are @desktop_only for now.
Server only gets a driver-registration and reachability check here.

ronblum added 30 commits July 31, 2026 17:05
@ronblum

ronblum commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Review

Five specialized agents reviewed this PR's diff against origin/main: code-reviewer, pr-test-analyzer, comment-analyzer, silent-failure-hunter, and type-design-analyzer.

code-reviewer

  1. Server-mode ODBCSYSINI doesn't survive an R session restart (fixtures/rstudio.fixture.ts) -- currently latent because the affected describes are @desktop_only, but will resurface once Server mode is un-skipped.
  2. odbc is now a hard-required package, but two os-e2e-deps callers (a cache-seed workflow, one Windows scheduled workflow) don't install the ODBC driver manager.
  3. The wizard-fill retry loop only rewrote the caller's own fields on retry, never Server/Port -- so the one field the corrupting race most often hits could never be repaired by a retry.
  4. Nothing in Server mode actually exercises live ODBC connectivity anymore -- a real regression there could pass green while testing nothing.
    Plus several suggestions: an unguarded JSON.parse, stale docs claiming Server coverage, a malformed port silently becoming NaN, MySQL's driver name missing its (pw) suffix, an XPath-injection risk on table names with apostrophes, a misplaced import, a redundant .first(), two undocumented product quirks with no issue reference.

pr-test-analyzer

  1. The explorer's "filtering narrows the tree" test couldn't actually fail even if filtering did nothing -- the target row was already visible from an earlier drill step.
  2. The connection-list filter box (distinct from the object-tree filter) has zero test coverage.
    Plus minor suggestions on wizard-destination coverage and blank-field submission.

comment-analyzer

  1. A comment in new_connection_wizard.page.ts was factually wrong on two counts (claimed per-keystroke DOM churn; the real mechanism is a different, unrelated one) and directly contradicted another comment in the same PR.
    Plus two minor misattributions/undocumented magic numbers.

silent-failure-hunter

  1. sandbox-teardown.ts's unguarded readDbStatus could crash the whole teardown on a malformed status file, skipping ODBC de-registration, credential scrubbing, and sandbox deletion.
  2. sandbox-setup.ts's unguarded mkdirSync for file-kind targets could crash the entire suite on a permissions/disk error, contradicting the code's own "never fatal" comment.
    Plus important findings on ambiguous provisioning-script failure modes and a Windows ODBC partial-write rollback gap.

type-design-analyzer
Rated the new DbTarget discriminated-union types 6-8/10 across encapsulation, invariant expression, usefulness, and enforcement -- confirmed working correctly at compile time. Flagged an unenforced target-name-uniqueness invariant and mutable shared nested fields as real-but-latent risks.

Assessment

All five critical/important findings were verified directly against the code (not taken at face value) before deciding. All were confirmed accurate:

  • Traced the exact call chain proving the two silent-failure-hunter crash risks are real (stopProvisionedDatabases -> readDbStatus -> unguarded JSON.parse, called ahead of credential scrubbing in globalTeardown; and the file-kind mkdirSync in provisionDatabases, contradicting its own "never fatal" comment).
  • Confirmed the ODBCSYSINI-after-restart gap by tracing applyOdbcSysIni's single worker-scoped call site against restartSessionWithSentinel's effect on the rsession environment.
  • Confirmed the wizard-fill retry bug by reading the write loop (Object.entries(written)) against the verify loop (Object.entries(expected), which additionally includes Server/Port for server targets).
  • Confirmed the comment contradiction directly (one comment says "per keystroke," a second comment in the same PR says "on field commit") -- didn't need to resolve which was right to know one was wrong.
  • Confirmed the explorer filter-test gap by reading drillExplorer against the test body: the target row was already visible before the filter box was ever touched.

Fixing the explorer filter test surfaced an additional, real bug not caught by any of the five agents: the fix initially appeared to reveal a product-level CSS bug in ObjectBrowserModel.java/ObjectBrowser.css (a class-name mismatch that would make the "hide non-matching objects" CSS rule unreachable). That read turned out to be wrong -- manual testing in real RStudio showed the filter working correctly. The actual cause was a test bug: .fill() doesn't fire the KeyUpHandler this GWT search widget listens on, the same class of gotcha already documented in this repo's Playwright skill for wizard text fields. Switching to .pressSequentially() fixed it for both the type-into and clear-out calls.

Actions Taken

Fixed:

  1. new_connection_wizard.page.ts -- corrected both comments to describe the actual DOM-duplication cause (pre-built per-driver-type pages), not a fictitious per-keystroke rebuild.
  2. db-provision.ts -- readDbStatus now catches a malformed/unreadable status file and treats it as "nothing recorded" (with a warning) instead of throwing and aborting teardown; the file-kind mkdirSync is now wrapped so a failure skips just that target instead of crashing the whole suite.
  3. connections_pane.actions.ts -- the wizard-fill retry loop now rewrites every field it verifies (expected), not just the caller's own fields (written), so a corrupted Server/Port can actually be repaired on retry.
  4. connection_explorer.test.ts -- the "filter narrows the tree" assertion now checks a sibling table disappears (not just that the target stays visible), using .pressSequentially() for both typing and clearing the filter box, plus a self-verifying check that clearing actually restores the sibling.
  5. Four small cleanups: import order in network.ts, a redundant .first(), a malformed PW_DB_<ID> port now throws like every other malformed override instead of silently becoming NaN, and MySQL's driver name now carries the (pw) suffix every other driver name has.

Deliberately not taken in this PR (tracked as follow-up, not blocking):

  • The ODBCSYSINI-after-restart gap (invisible today behind @desktop_only; a real fix needs Server mode itself un-skipped first).
  • A test for the connection-list filter box (real gap, but a new test rather than a fix-in-place).
  • runDbScript's ambiguous failure modes, the Windows ODBC partial-write rollback, and the type-hardening suggestions (Readonly wrapping, a WizardFieldKey union, a target-name-uniqueness assertion) -- all legitimate, none urgent since nothing currently exploits the gaps.
  • Filing GitHub issues for two undocumented product quirks referenced in test comments, and updating stale docs that still describe three of the five spec files as running under Server mode.

@ronblum

ronblum commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Snyk raised five issues and marked the test failed. But all five are false positives—standard Snyk noise for e2e test fixtures, not a real security issue:

  • connection_connect.test.ts:124: 'wrong-password' is the literal string typed into the wizard to test that a bad password correctly gets rejected. It's not a credential at all.
  • The four db-targets.ts hits: 'pwtest' is the fixed password for a throwaway PostgreSQL/MySQL server spun up locally on a nonstandard port for the duration of a single test run, then torn down. It's never a real account, never reachable outside the sandbox, and the value being predictable is actually the point (so tests are deterministic).

@ronblum
ronblum merged commit 1d201a1 into main Aug 28, 2026
48 of 50 checks passed
@ronblum
ronblum deleted the test/ron/e2e-connections-pane branch August 28, 2026 15:55
@ronblum

ronblum commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Addresses #18429.

This branch was previously deployed

1 inactive deployment
e2e-playwright — b7ad0d7b Deployed Aug 27, 2026 by ronblum via linux-desktop / E2E (ubuntu-24-x86_64) #716
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.

1 participant