Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Electron to v14. Replace Spectron with Playwright. #1985

Merged
merged 23 commits into from
Dec 9, 2021

Conversation

mason-fish
Copy link
Contributor

@mason-fish mason-fish commented Dec 7, 2021

fixes #1934

Lot's of changes here:

Replacing our integration test framework from Spectron to Playwright: Includes 3 of our original spectron test suites (queries, ingest, and zed-events). Unfortunately there is still a lot of inconsistency with running this on Windows (only in CI, I have not seen a single failure when running locally on my PC) but since we are so desperate to upgrade electron (which requires ditching Spectron) then we can test Windows manually in our pre-release cadence for now and tackle the CI issues more later.

Upgrading electron from 11 to 14: There are a few small changes involved here but the most noteworthy is that the remote module has been extracted out of the electron package and is now it's own npm scoped module at @electron/remote. I followed their provided migration instructions for this transition and the biggest blocker I hit was changing the way we mock that in our unit tests.

There are very few changes to the app itself other than the upgrade-related api changes. I did end up synchronizing/awaiting the window.loadFile() uses and re-order the launch of the hidden window. I did this so that the app would open more deterministically which then allowed the new integration tests to perform more consistently. I also re-worked some of the file input logic in the ingest flow so that we use the provided File object instead of the filepath. This was also for testing purposes since Playwright does not currently set the filepath on File objects the way that Electron does (and for this reason, in tests, we do NOT run or test the brimcap index sub-operation facilitated by the brimcap plugin). Finally, we also have upgraded to node 14! I found no issues with that aspect of the upgrade.

@mason-fish mason-fish force-pushed the electron-bump branch 2 times, most recently from e0abb50 to 41167c5 Compare December 7, 2021 22:54
Mason Fish added 20 commits December 9, 2021 07:56
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Mason Fish added 2 commits December 9, 2021 12:05
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Signed-off-by: Mason Fish <mason@brimsecurity.com>
@mason-fish mason-fish marked this pull request as ready for review December 9, 2021 17:31
@mason-fish mason-fish requested a review from a team December 9, 2021 17:31
@mason-fish mason-fish changed the title Electron bump. Death to Spectron. Upgrade Electron to v14. Replace Spectron with Playwright. Dec 9, 2021
Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

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

Let's go!!!

xvfb-run -d -s "-screen 0 1280x1024x24" npm run itest -- --ci --forceExit

integration_test:
playwright_integration_test:
Copy link
Member

Choose a reason for hiding this comment

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

Are we still testing centos?

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, but I can play around with adding it back in separately

import {app as electronApp, remote} from "electron"
const app = electronApp || (remote && remote.app)
import {app as electronApp} from "electron"
const app = electronApp
Copy link
Member

Choose a reason for hiding this comment

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

This can run from the renderer process, so we'll need a way to tell the renderer what the environment looks like. We can make an ipc call and set a global.


const app = electronApp || (remote && remote.app)
const app = electronApp
Copy link
Member

Choose a reason for hiding this comment

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

This also may run from the renderer process.

@@ -1,5 +1,6 @@
import path from "path"
import fs from "fs-extra"
import {ReadableStream} from "web-streams-polyfill/ponyfill"
Copy link
Member

Choose a reason for hiding this comment

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

I added a web-file-polyfill for this in my own tests. You'll see it in the upcoming PR.


export const dialog = {
showMessageBox: jest.fn()
}
Copy link
Member

Choose a reason for hiding this comment

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

Perfect.

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.

electron upgrade
2 participants