Skip to content

Conversation

@shouples
Copy link
Contributor

@shouples shouples commented Dec 30, 2025

Summary of Changes

Follow-up from #3076 to bump our Playwright version from 1.45.0 to 1.57.0. Closes https://github.com/confluentinc/vscode/security/dependabot/35

This required a couple of nontrivial changes based on Playwright release versions:

  • v1.46.0: double-array structure for fixtures that were previously arrays of objects (only affected webview tests, not E2E tests)
  • v1.50.0: change in how we handle electronApp.close() to prevent worker teardown timeout (more context below)

Click-testing instructions

  1. Add an expect(1).toBe(2); anywhere in the existing tests
  2. Run npx gulp e2e with optional -t for specific test(s)
  3. Poke around in the HTML report and trace viewer

Additional Context

  • This also handles some additional trace-related fixing so they don't drop CSS/font files, which currently makes the snapshot view pretty useless:
1.45.0 with busted traces 1.57.0 with manual tracing
image image
  • The reason here was because we previously set tracing both in playwright.config.ts as well as baseTest.ts, where we only need one.
    • We can't only use the playwright.config.ts setup since it doesn't Just Work ™️ with Electron, so we get even more useless traces:
      image

    • We also can't just use the trace fixture while starting our own manual tracing without having a clean way of stopping the trace and ensuring it's added to the test results, so we're better off manually starting and stopping the trace within the electronApp fixture. (While also making sure we don't start tracing too late and drop/miss elements.)

Note

Due to the fact that we aren't using the trace fixture anymore and are manually implementing our own traces, we also lose the screenshots for the CCloud-auth/Chromium context in that top "timeline"-like section of the trace viewer. This is because it was combining multiple trace contexts into one, and trying to manually reimplement that is
out of scope.
Instead, we'll capture a screenshot for any failure that happens during the CCloud sign-in browser flow, which will show up on the individual test result pages:
image

  • electronApp.close()
    • This version update was rough. The most problematic change to handle seemed to be going above playwright v1.50.0 (fix(electron): stalling on delayed process close microsoft/playwright#29431) since it meant electronApp.close() would wait for other Node processes/handles/etc to close down.
    • Unfortunately, there isn't a very straightforward way to determine what's left open/running once Electron is shut down and the extension is deactivated, so the most obvious answer would be that the sidecar process is sticking around (before its self-destruct). Maybe in future work we could offer a way to explicitly kill the process while the extension is still running, but that would only be for testing purposes and doesn't guarantee that some other process is still blocking the worker teardown.

Pull request checklist

Please check if your PR fulfills the following (if applicable):

Tests

  • Added new
  • Updated existing
  • Deleted existing

Release notes

  • Does anything in this PR need to be mentioned in the user-facing CHANGELOG?

Comment on lines +905 to +906
...(testFilter ? ["--grep", testFilter] : []),
...(testExcludeFilter ? ["--grep-invert", testExcludeFilter] : []),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No more -gv:

> npx playwright test --help
...
-g, --grep <grep>                Only run tests matching this regular expression (default: ".*")
  --global-timeout <timeout>       Maximum time this test suite can run in milliseconds (default: unlimited)
  --grep-invert <grep>             Only run tests that do not match this regular expression
...

@shouples shouples changed the title chore: update playwright to 1.57.0 chore: update playwright to 1.57.0 and fix traces Dec 30, 2025
export default defineConfig({
testDir: path.normalize(path.join(__dirname, "specs")),
forbidOnly: !!process.env.CI,
// maxFailures: 1, // uncomment for local dev/debugging purposes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not strictly necessary for this PR, but helpful to have as a reference

Comment on lines -161 to -169
if (!electronApp) {
throw new Error("electronApp is null - failed to launch VS Code");
}

const page = await electronApp.firstWindow();
if (!page) {
// shouldn't happen since we waited for the workbench above
throw new Error("Failed to get first window from VS Code");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need for these since electronApp will holler loudly if it can't start or we can't get the first window

Comment on lines +415 to +417
* With Playwright v1.50.0+, the behavior of `electronApp.close()` changes so it waits for the
* Electron process to exit, but if there are any lingering handles or requests, that may never
* happen, causing the test worker to hang and eventually time out.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

microsoft/playwright#29431

Wait until the process has exited before returning from ElectronApplication.close() (like for a normal browser - Browser.close() -> gracefullyClose).

test(
"should complete the browser-based Confluent Cloud sign-in flow",
{ tag: [Tag.Smoke, Tag.CCloud] },
async ({ page, electronApp, openExtensionSidebar }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

openExtensionSidebar is an auto-used fixture, so we don't need to include it here

@shouples shouples marked this pull request as ready for review January 6, 2026 16:50
@shouples shouples requested a review from a team as a code owner January 6, 2026 16:50
Copilot AI review requested due to automatic review settings January 6, 2026 16:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Playwright from version 1.45.0 to 1.57.0 and addresses multiple issues related to test tracing, particularly fixing CSS/font file capture in trace snapshots. The update required adapting to breaking changes in Playwright v1.46.0 (plugin structure) and v1.50.0 (Electron app shutdown behavior).

Key Changes:

  • Updated Playwright dependency to 1.57.0 with breaking change adaptations
  • Implemented manual trace management to properly capture Electron app traces
  • Added graceful shutdown handling with forced cleanup to prevent worker timeouts

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Bumped @playwright/test from 1.45.0 to 1.57.0
tests/e2e/playwright.config.ts Disabled automatic tracing in favor of manual implementation
tests/e2e/baseTest.ts Refactored trace management to manual control and added shutdownElectronApp() function
tests/e2e/utils/connections.ts Added TestInfo parameter and screenshot capture for CCloud auth failures
tests/e2e/specs/confluent.spec.ts Updated test to pass TestInfo to setupCCloudConnection
src/webview/*.spec.ts Wrapped plugins array in double-array structure per Playwright 1.46+ requirement
Gulpfile.js Updated test filter flags from shorthand to full names

@Cerchie Cerchie self-requested a review January 6, 2026 18:34
@shouples shouples merged commit cd9758c into main Jan 6, 2026
13 checks passed
@shouples shouples deleted the djs/update-playwright branch January 6, 2026 19:01
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