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

Update Electron #2934

Merged
merged 8 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"d3": "^6.7.0",
"date-fns": "^2.16.1",
"decompress": "^4.2.1",
"electron": "22.3.25",
"electron": "28.0.0",
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.2.0",
"electron-devtools-assembler": "^1.2.0",
Expand Down
7 changes: 6 additions & 1 deletion apps/zui/src/core/main/main-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import createLake from "src/js/models/lake"
import {getAuthToken} from "../../js/api/core/get-zealot"
import {Abortables} from "src/app/core/models/abortables"
import * as zui from "src/zui"
import log from "electron-log"

export class MainObject {
public isQuitting = false
Expand Down Expand Up @@ -63,7 +64,11 @@ export class MainObject {
) {}

async start() {
if (this.args.lake) this.lake.start()
if (this.args.lake) {
if (!(await this.lake.start())) {
log.error("Failed to start lake process after 5 seconds")
}
}
if (this.args.devtools) await installExtensions()
await this.windows.init()
}
Expand Down
6 changes: 4 additions & 2 deletions apps/zui/src/electron/run-main/before-boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import {MainArgs} from "./args"
import {setLogLevel} from "../set-log-level"
import {runMigrations} from "./run-migrations"

app.disableHardwareAcceleration()

export async function beforeBoot(
args: Partial<MainArgs>
): Promise<string | null> {
// Disable security warnings
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true"
// process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true"
// Setup app paths, this must be first
appPathSetup()
setLogLevel()
// Disable for certain platforms
app.disableHardwareAcceleration()

// Ensure only one instance of the app is ever on (windows)
const lock = app.requestSingleInstanceLock()
if (args.singleInstance && !lock) {
Expand Down
4 changes: 2 additions & 2 deletions apps/zui/src/electron/run-main/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function boot(args: Partial<MainArgs> = {}) {
// 6. Protocol Handler
runProtocolHandlers()
// 7. Start the app
app.whenReady().then(() => main.start())

await app.whenReady()
await main.start()
return main
}
8 changes: 0 additions & 8 deletions apps/zui/src/electron/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ jest.mock("@brimdata/zed-node")

afterEach(teardown)

test("start is called in zed lake", async () => {
const appMain = (await main({
devtools: false,
autoUpdater: false,
})) as MainObject
expect(appMain.lake.start).toHaveBeenCalledTimes(1)
})

Copy link
Member Author

Choose a reason for hiding this comment

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

This test was causing problems and is not necessary. If the lake doesn't start, many many other tests will fail.

test("app opens a window on startup", async () => {
const appMain = (await main({
devtools: false,
Expand Down
5 changes: 2 additions & 3 deletions apps/zui/src/js/flows/lake/buildAndAuthenticateLake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ export const buildAndAuthenticateLake =
return [false, null]
}

const dialogOpts = {
const dialogChoice = await showMessageBox({
Copy link
Member Author

Choose a reason for hiding this comment

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

TypeScript liked this better.

type: "info",
buttons: ["Continue", "Cancel"],
title: "Redirect to Browser",
message:
"This lake requires authentication. Continue to log in with your browser?",
}
const dialogChoice = await showMessageBox(dialogOpts)
})
if (dialogChoice.response === 1) return [true, null]

try {
Expand Down
1 change: 1 addition & 0 deletions apps/zui/src/test/system/boot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function boot(name: string, args: Partial<BootArgs> = {}) {
autoUpdater: false,
singleInstance: false,
})) as MainObject

await waitFor(async () => fetch(`http://localhost:${lakePort}/version`), {
timeout: 20_000,
})
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"@nx/js": "16.10.0",
"@nx/linter": "16.10.0",
"@nx/workspace": "16.10.0",
"@nxkit/playwright": "^2.3.0",
"@playwright/test": "1.27.1",
"@swc/cli": "~0.1.55",
"@swc/core": "^1.2.173",
"@swc/jest": "0.2.20",
Expand All @@ -41,7 +39,6 @@
"jest-environment-node": "^29.4.1",
"nx": "16.10.0",
"open-cli": "^7.2.0",
"playwright-chromium": "1.27.1",
"prettier": "^2.6.2",
"serve": "^14.2.0",
"ts-jest": "^29.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/zed-node/src/lake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Lake {
const args = [
'serve',
'-l',
this.addr(),
':' + this.port,
'-lake',
this.root,
'-log.level=info',
Expand Down
4 changes: 2 additions & 2 deletions packages/zui-player/helpers/test-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default class TestApp {
if (role instanceof RegExp) {
return this.mainWin.getByText(role);
} else {
return this.mainWin.getByRole(role, { name });
return this.mainWin.getByRole(role, { name, exact: true });
}
}

Expand Down Expand Up @@ -236,7 +236,7 @@ const getAppInfo = () => {
};
}

return { bin: null, entry: 'apps/zui' };
return { bin: null, entry: '../../apps/zui' };
};

function waitForTrue(check: () => boolean | Promise<boolean>) {
Expand Down
8 changes: 7 additions & 1 deletion packages/zui-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"name": "zui-player",
"private": true,
"main": "./index.ts",
"scripts": {
"test": "playwright test --config playwright.config.js"
},
"dependencies": {
"fs-extra": "^11.2.0"
"@playwright/test": "next",
"fs-extra": "^11.2.0",
"playwright": "next",
"playwright-chromium": "next"
}
}
8 changes: 0 additions & 8 deletions packages/zui-player/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
"tsConfig": "packages/zui-player/tsconfig.json",
"main": "packages/zui-player/index.ts"
}
},
"test": {
"executor": "@nxkit/playwright:test",
"options": {
"outputPath": "dist/packages/zui-player/test-results",
"playwrightConfig": "packages/zui-player/playwright.config.js",
"baseUrl": "https://example.com"
}
}
}
}
4 changes: 3 additions & 1 deletion packages/zui-player/tests/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ test.describe('Export tests', () => {
});
await menu.getByRole('button', { name: 'Export' }).click();
const dialog = app.mainWin.getByRole('dialog');
await dialog.getByRole('radio', { name: `${label}` }).click();
await dialog
.getByRole('radio', { name: `${label}`, exact: true })
.click();
await dialog.getByRole('button').filter({ hasText: 'Export' }).click();
await app.mainWin
.getByText(new RegExp('Export Completed: .*results\\.' + label))
Expand Down
2 changes: 1 addition & 1 deletion packages/zui-player/tests/pool-loads.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test.describe('Pool Loads', () => {
await app.click('treeitem', 'prs.json');
await app.dropFile(getPath('prs.json'));
await app.page
.getByLabel('Pool')
.getByLabel('Pool', { exact: true })
.nth(0)
.selectOption({ label: 'prs.json' });
await app.click('button', 'Load');
Expand Down
93 changes: 57 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3777,15 +3777,6 @@ __metadata:
languageName: node
linkType: hard

"@nxkit/playwright@npm:^2.3.0":
version: 2.3.0
resolution: "@nxkit/playwright@npm:2.3.0"
peerDependencies:
"@playwright/test": ^1.25.2
checksum: 57fa8cc56cfb17cd1ba5bb51c433c1631a61df96d58836ac7ebab99e8cb62f3bbc2f9709170bb086475d81417951a2cb5a2d62010fb1cef768ffdc531077cd1f
languageName: node
linkType: hard

"@open-draft/until@npm:^1.0.3":
version: 1.0.3
resolution: "@open-draft/until@npm:1.0.3"
Expand Down Expand Up @@ -3815,15 +3806,14 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:1.27.1":
version: 1.27.1
resolution: "@playwright/test@npm:1.27.1"
"@playwright/test@npm:next":
version: 1.41.0-alpha-dec-20-2023
resolution: "@playwright/test@npm:1.41.0-alpha-dec-20-2023"
dependencies:
"@types/node": "*"
playwright-core: 1.27.1
playwright: 1.41.0-alpha-dec-20-2023
bin:
playwright: cli.js
checksum: 92f219a78c21da03c6599d92c313c914e73cc374306366130fb3bd4701555179394ec5a3000d9375ce59f5a03c00f20d1ddaae50c85583ce475e17795a622699
checksum: 0b177a16bf503150268adb6165d8f7f58dd24f7ea8e942d94fcefcef8e4bdd60c2fd39b88c43eb726d43aaaaea0d613818924915229302820af6151b60c7b108
languageName: node
linkType: hard

Expand Down Expand Up @@ -5087,7 +5077,7 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*, @types/node@npm:^16.11.26":
"@types/node@npm:*":
version: 16.18.6
resolution: "@types/node@npm:16.18.6"
checksum: 85b6a11c347e1edfe014eb2c520aec37117152c932b632f455d4e2a71a311fb25578602c7c25f825c6f1c3e4a912506857c1aa679717318296f5590ac0d33254
Expand All @@ -5101,6 +5091,15 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^18.11.18":
version: 18.19.3
resolution: "@types/node@npm:18.19.3"
dependencies:
undici-types: ~5.26.4
checksum: 58c4fa45a78fcec75c78182a4b266395905957633654eb0311c5f9c30ac15c179ea2287ab1af034e46c2db7bb0589ef0000ee64c1de8f568a0aad29eaadb100c
languageName: node
linkType: hard

"@types/normalize-package-data@npm:^2.4.0, @types/normalize-package-data@npm:^2.4.1":
version: 2.4.1
resolution: "@types/normalize-package-data@npm:2.4.1"
Expand Down Expand Up @@ -8899,16 +8898,16 @@ __metadata:
languageName: node
linkType: hard

"electron@npm:22.3.25":
version: 22.3.25
resolution: "electron@npm:22.3.25"
"electron@npm:28.0.0":
version: 28.0.0
resolution: "electron@npm:28.0.0"
dependencies:
"@electron/get": ^2.0.0
"@types/node": ^16.11.26
"@types/node": ^18.11.18
extract-zip: ^2.0.1
bin:
electron: cli.js
checksum: be8af444bd7c9ca5504a445b660da172831150c0645b3ab46ee867ce6793ec7f77c38e5deb554caf7e4bdf2a910b500a98009a6edbeb3a2a5423a5efd8367a90
checksum: 5e0da4f3a8b6746cc597b20453cec89a346c9b64b6d3e3dbc7ba015c1e7d1dcaf43c2fc7c3115fc57f68853724049a6b21e40a82becb49df2d8207cbf6cbc3ea
languageName: node
linkType: hard

Expand Down Expand Up @@ -10211,7 +10210,7 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
"fsevents@npm:2.3.2, fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
Expand All @@ -10221,7 +10220,7 @@ __metadata:
languageName: node
linkType: hard

"fsevents@patch:fsevents@^2.3.2#~builtin<compat/fsevents>, fsevents@patch:fsevents@~2.3.2#~builtin<compat/fsevents>":
"fsevents@patch:fsevents@2.3.2#~builtin<compat/fsevents>, fsevents@patch:fsevents@^2.3.2#~builtin<compat/fsevents>, fsevents@patch:fsevents@~2.3.2#~builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
dependencies:
Expand Down Expand Up @@ -15279,23 +15278,38 @@ __metadata:
languageName: node
linkType: hard

"playwright-chromium@npm:1.27.1":
version: 1.27.1
resolution: "playwright-chromium@npm:1.27.1"
"playwright-chromium@npm:next":
version: 1.41.0-alpha-dec-20-2023
resolution: "playwright-chromium@npm:1.41.0-alpha-dec-20-2023"
dependencies:
playwright-core: 1.27.1
playwright-core: 1.41.0-alpha-dec-20-2023
bin:
playwright: cli.js
checksum: 2ea86a8f7562333bf6bcb8fc7485bd9b084d067087e9a0d0aeaaa116b16cbbd3a7d6f14f509e943a962415a415ee26ef232a51317f0d4d966d0ca55f9de4bdc1
checksum: 3482da232430d58ce3f354cb877581638eec6338be540b30515615bfbc779bfed24d98cfa5fc0989cfac3611e0e825027f139a5443646e4c519374b14c00a674
languageName: node
linkType: hard

"playwright-core@npm:1.27.1":
version: 1.27.1
resolution: "playwright-core@npm:1.27.1"
"playwright-core@npm:1.41.0-alpha-dec-20-2023":
version: 1.41.0-alpha-dec-20-2023
resolution: "playwright-core@npm:1.41.0-alpha-dec-20-2023"
bin:
playwright-core: cli.js
checksum: 4d07324fbd42753a9c5ba0606c619b4d0c79209b9f8d6c385da62eee3c7992ac247b4ac9bc3af0dcfe8c44b5be48c2172aac54dd4fc173dfd97ff3ea2b769eaa
languageName: node
linkType: hard

"playwright@npm:1.41.0-alpha-dec-20-2023, playwright@npm:next":
version: 1.41.0-alpha-dec-20-2023
resolution: "playwright@npm:1.41.0-alpha-dec-20-2023"
dependencies:
fsevents: 2.3.2
playwright-core: 1.41.0-alpha-dec-20-2023
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: fd65d3eb29978e0e7a755158625e8922a66ca9d599b7c24ddf920822b261d81c51a5964ef8e0e5ed9b2b12dc64541c5949b6a898d965e107f43261964e8c29a0
checksum: 102ab0df329a007c02b5418dd38da2e82734db156fdd46c9cc409461fe357a0b585d0ca8f29061f728862fa00929e53a8bad71135bcacd8b03dc7cb226bc2532
languageName: node
linkType: hard

Expand Down Expand Up @@ -18209,6 +18223,13 @@ __metadata:
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487
languageName: node
linkType: hard

"unicode-canonical-property-names-ecmascript@npm:^2.0.0":
version: 2.0.0
resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.0"
Expand Down Expand Up @@ -19110,8 +19131,6 @@ __metadata:
"@nx/js": 16.10.0
"@nx/linter": 16.10.0
"@nx/workspace": 16.10.0
"@nxkit/playwright": ^2.3.0
"@playwright/test": 1.27.1
"@swc/cli": ~0.1.55
"@swc/core": ^1.2.173
"@swc/helpers": ~0.4.11
Expand All @@ -19128,7 +19147,6 @@ __metadata:
jest-environment-node: ^29.4.1
nx: 16.10.0
open-cli: ^7.2.0
playwright-chromium: 1.27.1
prettier: ^2.6.2
serve: ^14.2.0
ts-jest: ^29.0.5
Expand All @@ -19142,7 +19160,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "zui-player@workspace:packages/zui-player"
dependencies:
"@playwright/test": next
fs-extra: ^11.2.0
playwright: next
playwright-chromium: next
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -19202,7 +19223,7 @@ __metadata:
d3: ^6.7.0
date-fns: ^2.16.1
decompress: ^4.2.1
electron: 22.3.25
electron: 28.0.0
electron-builder: ^23.6.0
electron-builder-notarize: ^1.2.0
electron-devtools-assembler: ^1.2.0
Expand Down
Loading