From 527a87feab702684f3344ba265a0027487ce0dcb Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 24 Sep 2024 14:53:22 +0200 Subject: [PATCH 1/8] Integration test stub --- app/ide-desktop/client/package.json | 4 +++- app/ide-desktop/client/src/fileAssociations.ts | 18 +++++++++--------- app/ide-desktop/client/src/index.ts | 1 + .../client/tests/creatingNewProject.spec.ts | 15 +++++++++++++++ pnpm-lock.yaml | 6 ++++++ 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 app/ide-desktop/client/tests/creatingNewProject.spec.ts diff --git a/app/ide-desktop/client/package.json b/app/ide-desktop/client/package.json index 4b7b05a6697a..acceca373b2c 100644 --- a/app/ide-desktop/client/package.json +++ b/app/ide-desktop/client/package.json @@ -38,6 +38,7 @@ "@types/semver": "^7.5.8", "@types/tar": "^6.1.4", "@types/yargs": "^17.0.30", + "@playwright/test": "^1.45.0", "cross-env": "^7.0.3", "electron": "31.2.0", "electron-builder": "^24.13.3", @@ -50,7 +51,8 @@ "fast-glob": "^3.2.12", "portfinder": "^1.0.32", "tsx": "^4.7.1", - "vite": "^5.3.5" + "vite": "^5.3.5", + "playwright": "^1.45.0" }, "//": [ "vite is required for the watch script", diff --git a/app/ide-desktop/client/src/fileAssociations.ts b/app/ide-desktop/client/src/fileAssociations.ts index 19130d77b7f8..11f17a70aac3 100644 --- a/app/ide-desktop/client/src/fileAssociations.ts +++ b/app/ide-desktop/client/src/fileAssociations.ts @@ -80,15 +80,15 @@ function getClientArguments(args = process.argv): readonly string[] { return args.slice(separatorIndex + 1) } } else { - const noSandbox = args.indexOf('--no-sandbox') - if (noSandbox !== NOT_FOUND) { - let v = [...args] - v.splice(noSandbox, 1) - return v.slice(1) - } else { - // Drop the leading executable name. - return args.slice(1) - } + // Drop the leading executable name and known electron options. + return args + .slice(1) + .filter( + option => + option !== '--no-sandbox' && + !option.startsWith('--inspect') && + !option.startsWith('--remote-debugging-port'), + ) } } diff --git a/app/ide-desktop/client/src/index.ts b/app/ide-desktop/client/src/index.ts index 50dff096f6ef..c45261efb002 100644 --- a/app/ide-desktop/client/src/index.ts +++ b/app/ide-desktop/client/src/index.ts @@ -144,6 +144,7 @@ class App { /** Process the command line arguments. */ processArguments(args = fileAssociations.CLIENT_ARGUMENTS) { + logger.log('ARGS', args) // We parse only "client arguments", so we don't have to worry about the Electron-Dev vs // Electron-Proper distinction. const fileToOpen = fileAssociations.argsDenoteFileOpenAttempt(args) diff --git a/app/ide-desktop/client/tests/creatingNewProject.spec.ts b/app/ide-desktop/client/tests/creatingNewProject.spec.ts new file mode 100644 index 000000000000..8229176f4331 --- /dev/null +++ b/app/ide-desktop/client/tests/creatingNewProject.spec.ts @@ -0,0 +1,15 @@ +import { _electron, expect, test } from '@playwright/test' + +test('Create new project', async () => { + const app = await _electron.launch({ + executablePath: '../../../dist/ide/linux-unpacked/enso', + }) + const page = await app.firstWindow() + + // TODO Login? + + await page.getByRole('button', { name: 'New Project', exact: true }).click() + await expect(page.locator('.GraphNode'), {}).toBeVisible({ timeout: 30000 }) + + await app.close() +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4888a578de27..54ccff39b256 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -634,6 +634,9 @@ importers: '@electron/notarize': specifier: 2.1.0 version: 2.1.0 + '@playwright/test': + specifier: ^1.45.0 + version: 1.45.0 '@types/mime-types': specifier: ^2.1.1 version: 2.1.4 @@ -682,6 +685,9 @@ importers: fast-glob: specifier: ^3.2.12 version: 3.3.2 + playwright: + specifier: ^1.45.0 + version: 1.45.0 portfinder: specifier: ^1.0.32 version: 1.0.32 From 5110167c8e07d7c93ffc8cec1e105b0d5f244eb8 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Wed, 25 Sep 2024 14:19:34 +0200 Subject: [PATCH 2/8] Sandboxing tests and login --- app/ide-desktop/client/src/globals.d.ts | 9 ++++----- app/ide-desktop/client/src/index.ts | 4 +++- app/ide-desktop/client/src/projectManagement.ts | 12 ++++++++---- .../client/tests/creatingNewProject.spec.ts | 16 +++++++++++++++- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/ide-desktop/client/src/globals.d.ts b/app/ide-desktop/client/src/globals.d.ts index 79b2b1b27514..79c42d3caccf 100644 --- a/app/ide-desktop/client/src/globals.d.ts +++ b/app/ide-desktop/client/src/globals.d.ts @@ -188,12 +188,11 @@ declare global { // @ts-expect-error The index signature is intentional to disallow unknown env vars. readonly ENSO_SUPPORTS_VIBRANCY?: string - // === E2E test variables === + // === Integration test variables === - // @ts-expect-error The index signature is intentional to disallow unknown env vars. - readonly IS_IN_PLAYWRIGHT_TEST?: `${boolean}` - // @ts-expect-error The index signature is intentional to disallow unknown env vars. - readonly PWDEBUG?: '1' + readonly ENSO_TEST?: string + readonly ENSO_TEST_USER?: string + readonly ENSO_TEST_USER_PASSWORD?: string // === Electron watch script variables === diff --git a/app/ide-desktop/client/src/index.ts b/app/ide-desktop/client/src/index.ts index c45261efb002..d934490f610c 100644 --- a/app/ide-desktop/client/src/index.ts +++ b/app/ide-desktop/client/src/index.ts @@ -144,7 +144,6 @@ class App { /** Process the command line arguments. */ processArguments(args = fileAssociations.CLIENT_ARGUMENTS) { - logger.log('ARGS', args) // We parse only "client arguments", so we don't have to worry about the Electron-Dev vs // Electron-Proper distinction. const fileToOpen = fileAssociations.argsDenoteFileOpenAttempt(args) @@ -357,6 +356,9 @@ class App { enableBlinkFeatures: argGroups.chrome.options.enableBlinkFeatures.value, disableBlinkFeatures: argGroups.chrome.options.disableBlinkFeatures.value, spellcheck: false, + ...(process.env.ENSO_TEST != null && process.env.ENSO_TEST !== '' ? + { partition: 'test' } + : {}), } const windowPreferences: electron.BrowserWindowConstructorOptions = { webPreferences, diff --git a/app/ide-desktop/client/src/projectManagement.ts b/app/ide-desktop/client/src/projectManagement.ts index 4808b39ef679..d08fe0ef0ae3 100644 --- a/app/ide-desktop/client/src/projectManagement.ts +++ b/app/ide-desktop/client/src/projectManagement.ts @@ -384,11 +384,15 @@ export function getProjectRoot(subtreePath: string): string | null { /** Get the directory that stores Enso projects. */ export function getProjectsDirectory(): string { - const documentsPath = desktopEnvironment.DOCUMENTS - if (documentsPath === undefined) { - return pathModule.join(os.homedir(), 'enso', 'projects') + if (process.env.ENSO_TEST != null && process.env.ENSO_TEST !== '') { + return pathModule.join(os.tmpdir(), 'enso-test-projects', process.env.ENSO_TEST) } else { - return pathModule.join(documentsPath, 'enso-projects') + const documentsPath = desktopEnvironment.DOCUMENTS + if (documentsPath === undefined) { + return pathModule.join(os.homedir(), 'enso', 'projects') + } else { + return pathModule.join(documentsPath, 'enso-projects') + } } } diff --git a/app/ide-desktop/client/tests/creatingNewProject.spec.ts b/app/ide-desktop/client/tests/creatingNewProject.spec.ts index 8229176f4331..ec4e286e897f 100644 --- a/app/ide-desktop/client/tests/creatingNewProject.spec.ts +++ b/app/ide-desktop/client/tests/creatingNewProject.spec.ts @@ -3,11 +3,25 @@ import { _electron, expect, test } from '@playwright/test' test('Create new project', async () => { const app = await _electron.launch({ executablePath: '../../../dist/ide/linux-unpacked/enso', + env: { ...process.env, ['ENSO_TEST']: 'Create new project' }, }) const page = await app.firstWindow() - // TODO Login? + await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible() + await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible() + await page.keyboard.insertText(process.env.ENSO_TEST_USER ?? '') + await page.keyboard.press('Tab') + await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD ?? '') + await page.keyboard.press('Enter') + await expect(page.getByText('I agree')).toHaveCount(2) + await expect(page.getByRole('button')).toHaveCount(1) + for (const checkbox of await page.getByText('I agree').all()) { + await checkbox.click() + } + await page.getByRole('button').click() + + await expect(page.getByRole('button', { name: 'New Project', exact: true })).toBeVisible() await page.getByRole('button', { name: 'New Project', exact: true }).click() await expect(page.locator('.GraphNode'), {}).toBeVisible({ timeout: 30000 }) From 832e4e564b592d1f70997447bf4ff3bb9e789640 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Wed, 25 Sep 2024 15:09:38 +0200 Subject: [PATCH 3/8] Small refactoring --- .../client/tests/creatingNewProject.spec.ts | 26 ++-------------- app/ide-desktop/client/tests/electronTest.ts | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 app/ide-desktop/client/tests/electronTest.ts diff --git a/app/ide-desktop/client/tests/creatingNewProject.spec.ts b/app/ide-desktop/client/tests/creatingNewProject.spec.ts index ec4e286e897f..9297f43ecc57 100644 --- a/app/ide-desktop/client/tests/creatingNewProject.spec.ts +++ b/app/ide-desktop/client/tests/creatingNewProject.spec.ts @@ -1,29 +1,9 @@ import { _electron, expect, test } from '@playwright/test' +import { electronTest, loginAsTestUser } from './electronTest' -test('Create new project', async () => { - const app = await _electron.launch({ - executablePath: '../../../dist/ide/linux-unpacked/enso', - env: { ...process.env, ['ENSO_TEST']: 'Create new project' }, - }) - const page = await app.firstWindow() - - await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible() - await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible() - await page.keyboard.insertText(process.env.ENSO_TEST_USER ?? '') - await page.keyboard.press('Tab') - await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD ?? '') - await page.keyboard.press('Enter') - - await expect(page.getByText('I agree')).toHaveCount(2) - await expect(page.getByRole('button')).toHaveCount(1) - for (const checkbox of await page.getByText('I agree').all()) { - await checkbox.click() - } - await page.getByRole('button').click() - +electronTest('Create new project', async page => { + await loginAsTestUser(page) await expect(page.getByRole('button', { name: 'New Project', exact: true })).toBeVisible() await page.getByRole('button', { name: 'New Project', exact: true }).click() await expect(page.locator('.GraphNode'), {}).toBeVisible({ timeout: 30000 }) - - await app.close() }) diff --git a/app/ide-desktop/client/tests/electronTest.ts b/app/ide-desktop/client/tests/electronTest.ts new file mode 100644 index 000000000000..13a2e127dae1 --- /dev/null +++ b/app/ide-desktop/client/tests/electronTest.ts @@ -0,0 +1,31 @@ +import { _electron, expect, Page, test } from '@playwright/test' + +export function electronTest(name: string, body: (page: Page) => void | Promise) { + test(name, async () => { + const app = await _electron.launch({ + executablePath: '../../../dist/ide/linux-unpacked/enso', + env: { ...process.env, ['ENSO_TEST']: 'Create new project' }, + }) + const page = await app.firstWindow() + await body(page) + await app.close() + }) +} + +export async function loginAsTestUser(page: Page) { + // Login screen + await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible() + await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible() + await page.keyboard.insertText(process.env.ENSO_TEST_USER ?? '') + await page.keyboard.press('Tab') + await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD ?? '') + await page.keyboard.press('Enter') + + // Accept terms screen + await expect(page.getByText('I agree')).toHaveCount(2) + await expect(page.getByRole('button')).toHaveCount(1) + for (const checkbox of await page.getByText('I agree').all()) { + await checkbox.click() + } + await page.getByRole('button').click() +} From 8ff82939ec5fc5c7343716c1d78fc087946a7e5d Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Wed, 25 Sep 2024 17:15:46 +0200 Subject: [PATCH 4/8] Allow other platforms WIP --- app/ide-desktop/client/playwright.config.ts | 19 +++++++++++++++++++ app/ide-desktop/client/src/globals.d.ts | 1 + .../client/tests/creatingNewProject.spec.ts | 6 +++++- app/ide-desktop/client/tests/electronTest.ts | 19 +++++++++++++++---- app/ide-desktop/client/tests/setup.ts | 19 +++++++++++++++++++ 5 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 app/ide-desktop/client/playwright.config.ts create mode 100644 app/ide-desktop/client/tests/setup.ts diff --git a/app/ide-desktop/client/playwright.config.ts b/app/ide-desktop/client/playwright.config.ts new file mode 100644 index 000000000000..9b1ab82d9417 --- /dev/null +++ b/app/ide-desktop/client/playwright.config.ts @@ -0,0 +1,19 @@ +/** @file Playwright browser testing configuration. */ +import { defineConfig } from '@playwright/test' + +/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/strict-boolean-expressions */ + +export default defineConfig({ + testDir: './tests', + forbidOnly: !!process.env.CI, + workers: 1, + timeout: 60000, + globalSetup: './tests/setup.ts', + expect: { + timeout: 5000, + toHaveScreenshot: { threshold: 0 }, + }, + use: { + actionTimeout: 5000, + }, +}) diff --git a/app/ide-desktop/client/src/globals.d.ts b/app/ide-desktop/client/src/globals.d.ts index 79c42d3caccf..70d2756a9c3f 100644 --- a/app/ide-desktop/client/src/globals.d.ts +++ b/app/ide-desktop/client/src/globals.d.ts @@ -193,6 +193,7 @@ declare global { readonly ENSO_TEST?: string readonly ENSO_TEST_USER?: string readonly ENSO_TEST_USER_PASSWORD?: string + ENSO_TEST_EXEC_PATH?: string | undefined // === Electron watch script variables === diff --git a/app/ide-desktop/client/tests/creatingNewProject.spec.ts b/app/ide-desktop/client/tests/creatingNewProject.spec.ts index 9297f43ecc57..abdc5a0aea70 100644 --- a/app/ide-desktop/client/tests/creatingNewProject.spec.ts +++ b/app/ide-desktop/client/tests/creatingNewProject.spec.ts @@ -1,4 +1,8 @@ -import { _electron, expect, test } from '@playwright/test' +/** @file A test for basic flow of the application: open project and see if nodes appear. */ + +/* eslint-disable @typescript-eslint/no-magic-numbers */ + +import { expect } from '@playwright/test' import { electronTest, loginAsTestUser } from './electronTest' electronTest('Create new project', async page => { diff --git a/app/ide-desktop/client/tests/electronTest.ts b/app/ide-desktop/client/tests/electronTest.ts index 13a2e127dae1..ba58a9dd31fa 100644 --- a/app/ide-desktop/client/tests/electronTest.ts +++ b/app/ide-desktop/client/tests/electronTest.ts @@ -1,10 +1,17 @@ -import { _electron, expect, Page, test } from '@playwright/test' +/** @file Commonly used functions for electron tests */ -export function electronTest(name: string, body: (page: Page) => void | Promise) { +import { _electron, expect, type Page, test } from '@playwright/test' + +/** + * Tests run on electron executable. + * + * Similar to playwright's test, but launches electron, and passes Page of the main window. + */ +export function electronTest(name: string, body: (page: Page) => Promise | void) { test(name, async () => { const app = await _electron.launch({ - executablePath: '../../../dist/ide/linux-unpacked/enso', - env: { ...process.env, ['ENSO_TEST']: 'Create new project' }, + executablePath: process.env.ENSO_TEST_EXEC_PATH, + env: { ...process.env, ['ENSO_TEST']: name }, }) const page = await app.firstWindow() await body(page) @@ -12,6 +19,10 @@ export function electronTest(name: string, body: (page: Page) => void | Promise< }) } +/** + * Login as test user. This function asserts that page is the login page, and uses + * credentials from ENSO_TEST_USER and ENSO_TEST_USER_PASSWORD env variables. + */ export async function loginAsTestUser(page: Page) { // Login screen await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible() diff --git a/app/ide-desktop/client/tests/setup.ts b/app/ide-desktop/client/tests/setup.ts new file mode 100644 index 000000000000..7496ea4afc80 --- /dev/null +++ b/app/ide-desktop/client/tests/setup.ts @@ -0,0 +1,19 @@ +import * as fs from 'node:fs' + +const POSSIBLE_EXEC_PATHS = [ + '../../../dist/ide/linux-unpacked/enso', + '../../../dist/ide/win-unpacked/Enso.exe', + '../../../dist/ide/macos-unpacked/enso', +] + +/** Setup for all tests: checks if and where electron exec is */ +export default function setup() { + process.env.ENSO_TEST_EXEC_PATH = POSSIBLE_EXEC_PATHS.find(path => { + try { + fs.accessSync(path, fs.constants.X_OK) + return true + } catch (err) { + return false + } + }) +} From f69562fac4a3ebb74d74c464c58d3ba35d182103 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Thu, 26 Sep 2024 10:43:30 +0200 Subject: [PATCH 5/8] increase threshold for slow tests --- app/ide-desktop/client/playwright.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/ide-desktop/client/playwright.config.ts b/app/ide-desktop/client/playwright.config.ts index 9b1ab82d9417..3e665a14426d 100644 --- a/app/ide-desktop/client/playwright.config.ts +++ b/app/ide-desktop/client/playwright.config.ts @@ -8,6 +8,7 @@ export default defineConfig({ forbidOnly: !!process.env.CI, workers: 1, timeout: 60000, + reportSlowTests: { max: 5, threshold: 60000 }, globalSetup: './tests/setup.ts', expect: { timeout: 5000, From 8745b6ba22a3c6a2aec19a8bcd7a56ff4a9235f6 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Thu, 26 Sep 2024 10:55:14 +0200 Subject: [PATCH 6/8] Is this proper mac path? --- app/ide-desktop/client/tests/setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ide-desktop/client/tests/setup.ts b/app/ide-desktop/client/tests/setup.ts index 7496ea4afc80..eb3ab0442eb5 100644 --- a/app/ide-desktop/client/tests/setup.ts +++ b/app/ide-desktop/client/tests/setup.ts @@ -3,7 +3,7 @@ import * as fs from 'node:fs' const POSSIBLE_EXEC_PATHS = [ '../../../dist/ide/linux-unpacked/enso', '../../../dist/ide/win-unpacked/Enso.exe', - '../../../dist/ide/macos-unpacked/enso', + '../../../dist/ide/mac-arm64/Enso.app/Contents/MacOS/Enso', ] /** Setup for all tests: checks if and where electron exec is */ From 4b781acea1c2d9d591ccd3a2c07c0392ddba2538 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Thu, 26 Sep 2024 13:25:16 +0200 Subject: [PATCH 7/8] fixes --- app/ide-desktop/client/src/globals.d.ts | 2 +- app/ide-desktop/client/tests/electronTest.ts | 11 ++++++++--- app/ide-desktop/client/tests/setup.ts | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/ide-desktop/client/src/globals.d.ts b/app/ide-desktop/client/src/globals.d.ts index 70d2756a9c3f..d6763c8e4a79 100644 --- a/app/ide-desktop/client/src/globals.d.ts +++ b/app/ide-desktop/client/src/globals.d.ts @@ -193,7 +193,7 @@ declare global { readonly ENSO_TEST?: string readonly ENSO_TEST_USER?: string readonly ENSO_TEST_USER_PASSWORD?: string - ENSO_TEST_EXEC_PATH?: string | undefined + ENSO_TEST_EXEC_PATH?: string // === Electron watch script variables === diff --git a/app/ide-desktop/client/tests/electronTest.ts b/app/ide-desktop/client/tests/electronTest.ts index ba58a9dd31fa..85686b662505 100644 --- a/app/ide-desktop/client/tests/electronTest.ts +++ b/app/ide-desktop/client/tests/electronTest.ts @@ -10,7 +10,7 @@ import { _electron, expect, type Page, test } from '@playwright/test' export function electronTest(name: string, body: (page: Page) => Promise | void) { test(name, async () => { const app = await _electron.launch({ - executablePath: process.env.ENSO_TEST_EXEC_PATH, + executablePath: process.env.ENSO_TEST_EXEC_PATH ?? '', env: { ...process.env, ['ENSO_TEST']: name }, }) const page = await app.firstWindow() @@ -27,9 +27,14 @@ export async function loginAsTestUser(page: Page) { // Login screen await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible() await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible() - await page.keyboard.insertText(process.env.ENSO_TEST_USER ?? '') + if (process.env.ENSO_TEST_USER == null || process.env.ENSO_TEST_USER_PASSWORD == null) { + throw Error( + 'Cannot log in; ENSO_TEST_USER and ENSO_TEST_USER_PASSWORD env variables are not provided', + ) + } + await page.keyboard.insertText(process.env.ENSO_TEST_USER) await page.keyboard.press('Tab') - await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD ?? '') + await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD) await page.keyboard.press('Enter') // Accept terms screen diff --git a/app/ide-desktop/client/tests/setup.ts b/app/ide-desktop/client/tests/setup.ts index eb3ab0442eb5..448147692225 100644 --- a/app/ide-desktop/client/tests/setup.ts +++ b/app/ide-desktop/client/tests/setup.ts @@ -1,14 +1,20 @@ +/** @file {@link setup} function for all tests. */ + import * as fs from 'node:fs' const POSSIBLE_EXEC_PATHS = [ '../../../dist/ide/linux-unpacked/enso', '../../../dist/ide/win-unpacked/Enso.exe', + '../../../dist/ide/mac/Enso.app/Contents/MacOS/Enso', '../../../dist/ide/mac-arm64/Enso.app/Contents/MacOS/Enso', ] -/** Setup for all tests: checks if and where electron exec is */ +/** + * Setup for all tests: checks if and where electron exec is. + * @throws when no Enso package could be found. + */ export default function setup() { - process.env.ENSO_TEST_EXEC_PATH = POSSIBLE_EXEC_PATHS.find(path => { + const execPath = POSSIBLE_EXEC_PATHS.find(path => { try { fs.accessSync(path, fs.constants.X_OK) return true @@ -16,4 +22,9 @@ export default function setup() { return false } }) + if (execPath != null) { + process.env.ENSO_TEST_EXEC_PATH = execPath + } else { + throw Error('Cannot find Enso package') + } } From af07d2fe33cdfd89d821bdc893fa6780d0c9ffbe Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Thu, 26 Sep 2024 14:04:41 +0200 Subject: [PATCH 8/8] Review --- app/ide-desktop/client/src/fileAssociations.ts | 14 ++++++-------- ...NewProject.spec.ts => createNewProject.spec.ts} | 0 app/ide-desktop/client/tests/electronTest.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) rename app/ide-desktop/client/tests/{creatingNewProject.spec.ts => createNewProject.spec.ts} (100%) diff --git a/app/ide-desktop/client/src/fileAssociations.ts b/app/ide-desktop/client/src/fileAssociations.ts index 11f17a70aac3..bede7f3061ba 100644 --- a/app/ide-desktop/client/src/fileAssociations.ts +++ b/app/ide-desktop/client/src/fileAssociations.ts @@ -81,14 +81,12 @@ function getClientArguments(args = process.argv): readonly string[] { } } else { // Drop the leading executable name and known electron options. - return args - .slice(1) - .filter( - option => - option !== '--no-sandbox' && - !option.startsWith('--inspect') && - !option.startsWith('--remote-debugging-port'), - ) + return ( + args + .slice(1) + // Omitting $ in --inspect and --remote-debugging-port is intentional. + .filter(option => !/^--no-sandbox$|^--inspect|^--remote-debugging-port/.test(option)) + ) } } diff --git a/app/ide-desktop/client/tests/creatingNewProject.spec.ts b/app/ide-desktop/client/tests/createNewProject.spec.ts similarity index 100% rename from app/ide-desktop/client/tests/creatingNewProject.spec.ts rename to app/ide-desktop/client/tests/createNewProject.spec.ts diff --git a/app/ide-desktop/client/tests/electronTest.ts b/app/ide-desktop/client/tests/electronTest.ts index 85686b662505..396218f9fb6a 100644 --- a/app/ide-desktop/client/tests/electronTest.ts +++ b/app/ide-desktop/client/tests/electronTest.ts @@ -29,7 +29,7 @@ export async function loginAsTestUser(page: Page) { await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible() if (process.env.ENSO_TEST_USER == null || process.env.ENSO_TEST_USER_PASSWORD == null) { throw Error( - 'Cannot log in; ENSO_TEST_USER and ENSO_TEST_USER_PASSWORD env variables are not provided', + 'Cannot log in; `ENSO_TEST_USER` and `ENSO_TEST_USER_PASSWORD` env variables are not provided', ) } await page.keyboard.insertText(process.env.ENSO_TEST_USER)