2025-03-13 10:54:00 -04:00
|
|
|
/* eslint-disable react-hooks/rules-of-hooks */
|
2024-10-01 07:56:04 +10:00
|
|
|
import type {
|
|
|
|
BrowserContext,
|
|
|
|
ElectronApplication,
|
2025-04-01 15:31:19 -07:00
|
|
|
Page,
|
2025-04-01 23:54:26 -07:00
|
|
|
TestInfo,
|
2024-10-01 07:56:04 +10:00
|
|
|
} from '@playwright/test'
|
2025-04-01 15:31:19 -07:00
|
|
|
import { _electron as electron } from '@playwright/test'
|
2025-04-01 14:20:42 -07:00
|
|
|
|
2025-04-16 00:11:25 +10:00
|
|
|
import fs from 'node:fs'
|
|
|
|
import path from 'path'
|
2025-04-01 23:54:26 -07:00
|
|
|
import { SETTINGS_FILE_NAME } from '@src/lib/constants'
|
|
|
|
import type { DeepPartial } from '@src/lib/types'
|
2025-04-01 15:31:19 -07:00
|
|
|
import fsp from 'fs/promises'
|
2025-04-01 23:54:26 -07:00
|
|
|
|
|
|
|
import type { Settings } from '@rust/kcl-lib/bindings/Settings'
|
|
|
|
|
|
|
|
import { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
|
|
|
|
import { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
|
|
|
|
import { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
|
2025-04-23 11:12:33 -04:00
|
|
|
import { SignInPageFixture } from '@e2e/playwright/fixtures/signInPageFixture'
|
2025-04-01 23:54:26 -07:00
|
|
|
import { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
|
|
|
|
import { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
|
|
|
|
|
|
|
|
import { TEST_SETTINGS } from '@e2e/playwright/storageStates'
|
|
|
|
import { getUtils, settingsToToml, setup } from '@e2e/playwright/test-utils'
|
2024-10-01 07:56:04 +10:00
|
|
|
|
|
|
|
export class AuthenticatedApp {
|
|
|
|
public readonly page: Page
|
|
|
|
public readonly context: BrowserContext
|
|
|
|
public readonly testInfo: TestInfo
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
public readonly viewPortSize = { width: 1200, height: 500 }
|
|
|
|
public electronApp: undefined | ElectronApplication
|
2025-03-13 10:54:00 -04:00
|
|
|
public projectDirName: string = ''
|
2024-10-01 07:56:04 +10:00
|
|
|
|
|
|
|
constructor(context: BrowserContext, page: Page, testInfo: TestInfo) {
|
|
|
|
this.context = context
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
this.page = page
|
2024-10-01 07:56:04 +10:00
|
|
|
this.testInfo = testInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
async initialise(code = '') {
|
2025-04-07 07:08:31 -04:00
|
|
|
const testDir = this.testInfo.outputPath('electron-test-projects-dir')
|
|
|
|
await setup(this.context, this.page, testDir, this.testInfo)
|
2024-10-01 07:56:04 +10:00
|
|
|
const u = await getUtils(this.page)
|
|
|
|
|
|
|
|
await this.page.addInitScript(async (code) => {
|
|
|
|
localStorage.setItem('persistCode', code)
|
|
|
|
;(window as any).playwrightSkipFilePicker = true
|
|
|
|
}, code)
|
|
|
|
|
2024-10-31 07:04:38 -07:00
|
|
|
await this.page.setViewportSize(this.viewPortSize)
|
2024-10-01 07:56:04 +10:00
|
|
|
|
|
|
|
await u.waitForAuthSkipAppStart()
|
|
|
|
}
|
|
|
|
getInputFile = (fileName: string) => {
|
|
|
|
return fsp.readFile(
|
2025-03-13 10:54:00 -04:00
|
|
|
path.join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName),
|
2024-10-01 07:56:04 +10:00
|
|
|
'utf-8'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
export interface Fixtures {
|
2024-10-01 07:56:04 +10:00
|
|
|
cmdBar: CmdBarFixture
|
|
|
|
editor: EditorFixture
|
|
|
|
toolbar: ToolbarFixture
|
|
|
|
scene: SceneFixture
|
|
|
|
homePage: HomePageFixture
|
2025-04-23 11:12:33 -04:00
|
|
|
signInPage: SignInPageFixture
|
2024-10-01 07:56:04 +10:00
|
|
|
}
|
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
export class ElectronZoo {
|
|
|
|
public available: boolean = true
|
|
|
|
public electron!: ElectronApplication
|
|
|
|
public firstUrl = ''
|
|
|
|
public viewPortSize = { width: 1200, height: 500 }
|
|
|
|
public projectDirName = ''
|
|
|
|
|
|
|
|
public page!: Page
|
|
|
|
public context!: BrowserContext
|
|
|
|
|
|
|
|
constructor() {}
|
|
|
|
|
2025-03-14 06:19:58 -04:00
|
|
|
// Help remote end by signaling we're done with the connection.
|
|
|
|
// If it takes longer than 10s to stop, just resolve.
|
2025-03-13 10:54:00 -04:00
|
|
|
async makeAvailableAgain() {
|
|
|
|
await this.page.evaluate(async () => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
if (!window.engineCommandManager.engineConnection?.state?.type) {
|
|
|
|
return resolve(undefined)
|
|
|
|
}
|
|
|
|
|
|
|
|
window.engineCommandManager.tearDown()
|
2025-03-14 06:19:58 -04:00
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
// Keep polling (per js event tick) until state is Disconnected.
|
2025-03-14 06:19:58 -04:00
|
|
|
const timeA = Date.now()
|
2025-03-13 10:54:00 -04:00
|
|
|
const checkDisconnected = () => {
|
|
|
|
// It's possible we never even created an engineConnection
|
|
|
|
// e.g. never left Projects view.
|
|
|
|
if (
|
|
|
|
window.engineCommandManager?.engineConnection?.state.type ===
|
|
|
|
'disconnected'
|
|
|
|
) {
|
|
|
|
return resolve(undefined)
|
|
|
|
}
|
2025-03-14 06:19:58 -04:00
|
|
|
|
2025-04-07 07:08:31 -04:00
|
|
|
if (Date.now() - timeA > 3000) {
|
2025-03-14 06:19:58 -04:00
|
|
|
return resolve(undefined)
|
|
|
|
}
|
|
|
|
|
2025-04-07 07:08:31 -04:00
|
|
|
setTimeout(checkDisconnected, 1)
|
2025-03-13 10:54:00 -04:00
|
|
|
}
|
|
|
|
checkDisconnected()
|
|
|
|
})
|
2024-10-01 07:56:04 +10:00
|
|
|
})
|
2025-02-24 13:09:39 -05:00
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
await this.context.tracing.stopChunk({ path: 'trace.zip' })
|
|
|
|
|
|
|
|
// Only after cleanup we're ready.
|
|
|
|
this.available = true
|
|
|
|
}
|
2025-02-24 13:09:39 -05:00
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
async createInstanceIfMissing(testInfo: TestInfo) {
|
|
|
|
// Create or otherwise clear the folder.
|
|
|
|
this.projectDirName = testInfo.outputPath('electron-test-projects-dir')
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
// We need to expose this in order for some tests that require folder
|
|
|
|
// creation and some code below.
|
2025-04-01 13:21:31 -04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
2025-03-13 10:54:00 -04:00
|
|
|
const that = this
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
const options = {
|
|
|
|
args: ['.', '--no-sandbox'],
|
|
|
|
env: {
|
|
|
|
...process.env,
|
|
|
|
IS_PLAYWRIGHT: 'true',
|
|
|
|
},
|
|
|
|
...(process.env.ELECTRON_OVERRIDE_DIST_PATH
|
|
|
|
? {
|
|
|
|
executablePath:
|
|
|
|
process.env.ELECTRON_OVERRIDE_DIST_PATH + 'electron',
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
...(process.env.PLAYWRIGHT_RECORD_VIDEO
|
|
|
|
? {
|
|
|
|
recordVideo: {
|
|
|
|
dir: testInfo.snapshotPath(),
|
|
|
|
size: this.viewPortSize,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do this once and then reuse window on subsequent calls.
|
|
|
|
if (!this.electron) {
|
|
|
|
this.electron = await electron.launch(options)
|
2025-03-14 06:19:58 -04:00
|
|
|
|
|
|
|
// Mac takes quite a long time to create the first window in CI.
|
|
|
|
// Turns out we can't trust firstWindow() either. So loop.
|
|
|
|
let timeoutId: ReturnType<typeof setTimeout>
|
|
|
|
const tryToGetWindowPage = () =>
|
|
|
|
new Promise((resolve) => {
|
|
|
|
const fn = () => {
|
|
|
|
this.page = this.electron.windows()[0]
|
|
|
|
timeoutId = setTimeout(() => {
|
|
|
|
if (this.page) {
|
|
|
|
clearTimeout(timeoutId)
|
|
|
|
return resolve(undefined)
|
|
|
|
}
|
|
|
|
fn()
|
|
|
|
}, 0)
|
|
|
|
}
|
|
|
|
fn()
|
|
|
|
})
|
|
|
|
|
|
|
|
await tryToGetWindowPage()
|
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
this.context = this.electron.context()
|
|
|
|
await this.context.tracing.start({ screenshots: true, snapshots: true })
|
2025-04-03 22:36:51 -05:00
|
|
|
|
|
|
|
// We need to patch this because addInitScript will bind too late in our
|
|
|
|
// electron tests, never running. We need to call reload() after each call
|
|
|
|
// to guarantee it runs.
|
|
|
|
const oldContextAddInitScript = this.context.addInitScript
|
|
|
|
this.context.addInitScript = async function (a, b) {
|
|
|
|
// @ts-ignore pretty sure way out of tsc's type checking capabilities.
|
|
|
|
// This code works perfectly fine.
|
|
|
|
await oldContextAddInitScript.apply(this, [a, b])
|
|
|
|
await that.page.reload()
|
|
|
|
}
|
|
|
|
|
|
|
|
const oldPageAddInitScript = this.page.addInitScript
|
|
|
|
this.page.addInitScript = async function (a: any, b: any) {
|
|
|
|
// @ts-ignore pretty sure way out of tsc's type checking capabilities.
|
|
|
|
// This code works perfectly fine.
|
|
|
|
await oldPageAddInitScript.apply(this, [a, b])
|
|
|
|
await that.page.reload()
|
|
|
|
}
|
2025-03-13 10:54:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
await this.context.tracing.startChunk()
|
|
|
|
|
2025-04-07 07:08:31 -04:00
|
|
|
// THIS IS ABSOLUTELY NECESSARY TO CHANGE THE PROJECT DIRECTORY BETWEEN
|
|
|
|
// TESTS BECAUSE OF THE ELECTRON INSTANCE REUSE.
|
|
|
|
await this.electron?.evaluate(({ app }, projectDirName) => {
|
|
|
|
// @ts-ignore can't declaration merge see main.ts
|
|
|
|
app.testProperty['TEST_SETTINGS_FILE_KEY'] = projectDirName
|
|
|
|
}, this.projectDirName)
|
|
|
|
|
|
|
|
await setup(this.context, this.page, this.projectDirName, testInfo)
|
2025-03-13 10:54:00 -04:00
|
|
|
|
|
|
|
await this.cleanProjectDir()
|
|
|
|
|
|
|
|
// Create a consistent way to resize the page across electron and web.
|
|
|
|
// (lee) I had to do everything in the book to make electron change its
|
|
|
|
// damn window size. I succeeded in making it consistently and reliably
|
|
|
|
// do it after a whole afternoon.
|
|
|
|
this.page.setBodyDimensions = async function (dims: {
|
|
|
|
width: number
|
|
|
|
height: number
|
|
|
|
}) {
|
|
|
|
await this.setViewportSize(dims)
|
|
|
|
|
|
|
|
await that.electron?.evaluateHandle(async ({ app }, dims) => {
|
|
|
|
// @ts-ignore sorry jon but see comment in main.ts why this is ignored
|
|
|
|
await app.resizeWindow(dims.width, dims.height)
|
|
|
|
}, dims)
|
|
|
|
|
|
|
|
return this.evaluate(async (dims: { width: number; height: number }) => {
|
|
|
|
await window.electron.resizeWindow(dims.width, dims.height)
|
|
|
|
window.document.body.style.width = dims.width + 'px'
|
|
|
|
window.document.body.style.height = dims.height + 'px'
|
|
|
|
window.document.documentElement.style.width = dims.width + 'px'
|
|
|
|
window.document.documentElement.style.height = dims.height + 'px'
|
|
|
|
}, dims)
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.page.setBodyDimensions(this.viewPortSize)
|
|
|
|
|
|
|
|
this.context.folderSetupFn = async function (fn) {
|
|
|
|
return fn(that.projectDirName)
|
|
|
|
.then(() => that.page.reload())
|
|
|
|
.then(() => ({
|
|
|
|
dir: that.projectDirName,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.firstUrl) {
|
Rework home layout to have a sidebar (#6423)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Rework home layout to have a sidebar
fmt I think
* Add two links to the bottom of the sidebar
Mostly to visually anchor it
* Tweak some style things
* update test util whose locator needs to change
* tsc and fmt
* Stupid heading change broke the dang E2E tests
* Make that heading locator a part of the home page fixture
* pierremtb/new-snaps-for-frank (#6516)
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
---------
Co-authored-by: Kevin Nadro <kevin@zoo.dev>
Co-authored-by: Kevin Nadro <nadr0@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
2025-04-26 11:55:01 -04:00
|
|
|
await this.page.getByRole('heading', { name: 'Projects' }).count()
|
2025-03-13 10:54:00 -04:00
|
|
|
this.firstUrl = this.page.url()
|
2024-10-01 07:56:04 +10:00
|
|
|
}
|
2025-03-13 10:54:00 -04:00
|
|
|
|
|
|
|
// Due to the app controlling its own window context we need to inject new
|
|
|
|
// options and context here.
|
|
|
|
// NOTE TO LEE: Seems to destroy page context when calling an electron loadURL.
|
|
|
|
// await tronApp.electronApp.evaluate(({ app }) => {
|
|
|
|
// return app.reuseWindowForTest();
|
|
|
|
// });
|
|
|
|
|
|
|
|
// Always start at the root view
|
|
|
|
await this.page.goto(this.firstUrl)
|
|
|
|
|
|
|
|
// Force a hard reload, destroying the stream and other state
|
|
|
|
await this.page.reload()
|
2024-10-01 07:56:04 +10:00
|
|
|
}
|
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
async cleanProjectDir(appSettings?: DeepPartial<Settings>) {
|
|
|
|
try {
|
|
|
|
if (fs.existsSync(this.projectDirName)) {
|
|
|
|
await fsp.rm(this.projectDirName, { recursive: true })
|
|
|
|
}
|
2025-03-19 03:52:10 +11:00
|
|
|
} catch (_e) {
|
|
|
|
console.error(_e)
|
2025-03-13 10:54:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await fsp.mkdir(this.projectDirName)
|
2025-03-19 03:52:10 +11:00
|
|
|
} catch (error: unknown) {
|
|
|
|
void error
|
2025-03-13 10:54:00 -04:00
|
|
|
// Not a problem if it already exists.
|
|
|
|
}
|
|
|
|
|
2025-04-07 07:08:31 -04:00
|
|
|
const tempSettingsFilePath = path.resolve(
|
2025-03-13 10:54:00 -04:00
|
|
|
this.projectDirName,
|
2025-04-07 07:08:31 -04:00
|
|
|
'..',
|
2025-03-13 10:54:00 -04:00
|
|
|
SETTINGS_FILE_NAME
|
|
|
|
)
|
|
|
|
|
|
|
|
let settingsOverridesToml = ''
|
|
|
|
|
|
|
|
if (appSettings) {
|
2025-04-01 20:39:55 -07:00
|
|
|
settingsOverridesToml = settingsToToml({
|
2025-03-13 10:54:00 -04:00
|
|
|
settings: {
|
|
|
|
...TEST_SETTINGS,
|
|
|
|
...appSettings,
|
|
|
|
app: {
|
|
|
|
...TEST_SETTINGS.app,
|
|
|
|
...appSettings.app,
|
|
|
|
},
|
2025-04-01 20:39:55 -07:00
|
|
|
project: {
|
|
|
|
...TEST_SETTINGS.project,
|
|
|
|
directory: this.projectDirName,
|
|
|
|
},
|
2025-03-13 10:54:00 -04:00
|
|
|
},
|
|
|
|
})
|
|
|
|
} else {
|
2025-04-01 20:39:55 -07:00
|
|
|
settingsOverridesToml = settingsToToml({
|
2025-03-13 10:54:00 -04:00
|
|
|
settings: {
|
|
|
|
...TEST_SETTINGS,
|
|
|
|
app: {
|
|
|
|
...TEST_SETTINGS.app,
|
2025-04-01 20:39:55 -07:00
|
|
|
},
|
|
|
|
project: {
|
|
|
|
...TEST_SETTINGS.project,
|
|
|
|
directory: this.projectDirName,
|
2025-03-13 10:54:00 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
await fsp.writeFile(tempSettingsFilePath, settingsOverridesToml)
|
2024-10-01 07:56:04 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
// If yee encounter this, please try to type it.
|
|
|
|
type FnUse = any
|
|
|
|
|
|
|
|
const fixturesForElectron = {
|
|
|
|
page: async (
|
|
|
|
{ tronApp }: { tronApp: ElectronZoo },
|
|
|
|
use: FnUse,
|
|
|
|
testInfo: TestInfo
|
|
|
|
) => {
|
|
|
|
await use(tronApp.page)
|
|
|
|
},
|
|
|
|
context: async (
|
|
|
|
{ tronApp }: { tronApp: ElectronZoo },
|
|
|
|
use: FnUse,
|
|
|
|
testInfo: TestInfo
|
|
|
|
) => {
|
|
|
|
await use(tronApp.context)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const fixturesForWeb = {
|
|
|
|
page: async (
|
|
|
|
{ page, context }: { page: Page; context: BrowserContext },
|
|
|
|
use: FnUse,
|
|
|
|
testInfo: TestInfo
|
|
|
|
) => {
|
|
|
|
page.setBodyDimensions = page.setViewportSize
|
|
|
|
|
|
|
|
// We do the same thing in ElectronZoo. addInitScript simply doesn't fire
|
|
|
|
// at the correct time, so we reload the page and it fires appropriately.
|
|
|
|
const oldPageAddInitScript = page.addInitScript
|
|
|
|
page.addInitScript = async function (...args) {
|
|
|
|
// @ts-expect-error
|
|
|
|
await oldPageAddInitScript.apply(this, args)
|
|
|
|
await page.reload()
|
|
|
|
}
|
|
|
|
|
|
|
|
const oldContextAddInitScript = context.addInitScript
|
|
|
|
context.addInitScript = async function (...args) {
|
|
|
|
// @ts-expect-error
|
|
|
|
await oldContextAddInitScript.apply(this, args)
|
|
|
|
await page.reload()
|
|
|
|
}
|
|
|
|
|
|
|
|
const webApp = new AuthenticatedApp(context, page, testInfo)
|
|
|
|
await webApp.initialise()
|
|
|
|
|
|
|
|
await use(page)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const fixturesBasedOnProcessEnvPlatform = {
|
|
|
|
cmdBar: async ({ page }: { page: Page }, use: FnUse) => {
|
2024-10-01 07:56:04 +10:00
|
|
|
await use(new CmdBarFixture(page))
|
|
|
|
},
|
2025-03-13 10:54:00 -04:00
|
|
|
editor: async ({ page }: { page: Page }, use: FnUse) => {
|
2024-10-01 07:56:04 +10:00
|
|
|
await use(new EditorFixture(page))
|
|
|
|
},
|
2025-03-13 10:54:00 -04:00
|
|
|
toolbar: async ({ page }: { page: Page }, use: FnUse) => {
|
2024-10-01 07:56:04 +10:00
|
|
|
await use(new ToolbarFixture(page))
|
|
|
|
},
|
2025-03-13 10:54:00 -04:00
|
|
|
scene: async ({ page }: { page: Page }, use: FnUse) => {
|
2024-10-01 07:56:04 +10:00
|
|
|
await use(new SceneFixture(page))
|
|
|
|
},
|
2025-03-13 10:54:00 -04:00
|
|
|
homePage: async ({ page }: { page: Page }, use: FnUse) => {
|
2024-10-01 07:56:04 +10:00
|
|
|
await use(new HomePageFixture(page))
|
|
|
|
},
|
2025-04-23 11:12:33 -04:00
|
|
|
signInPage: async ({ page }: { page: Page }, use: FnUse) => {
|
|
|
|
await use(new SignInPageFixture(page))
|
|
|
|
},
|
Move all tests over to electron (#4484)
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* One last try with window-16-cores
* Trigger CI
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Skip more win tests, add back all three oses
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* Add two more fixmes
* 2 more fixmes
* skip segment overlays on win32
* Another fixme
* Trigger CI
* Trigger CI
* Quick clean up
* Move all tests over to electron
* Pass the correct param to playwright-electron.sh
* Add shebang to script and add macos-14-large as a target
* Get sketch-tests.spec.ts passing in electron
* Try out 4 workers
* Got testing-segment-overlays passing
* Pass testing-selections.spec.ts
* Go back to fix up sketch-tests test
* Pass various.spec.ts, by far the hardest one
* Pass can-sketch-on-all-planes... with ease
* Pass command bar tests
* fmt
* Completely fix code mirror text navigating for tests
* Pass debug pane tests
* Pass desktop export tests
* Pass editor tests
* Pass file tree tests
* Pass onboarding tests
* Corrected a fixme in file-tree.spec!
* Painfully fix hardcoded coordinates in point-click.spec
* Pass machine.spec tests
* Pass projects, fought hard with filechooser
* Pass regresion-tests.spec tests
* Pass network and connection tests
* Pass camera-movement.spec tests
* Extreme time eaten by gizmo test fixes. All passing now.
* Merge main (tests changed x_x) and pass all constraints.spec tests (pain)
* Pass another painful spec suite: testing-settings
* Pass perspective-toggle, interesting note
* Pass samples loading tests
* Pass app header tests
* Pass text-to-cad tests
* Pass segment-overlays (minor ache) and ability to switch to web if needed :)
* Fix a ton of syntax changes and deflake 2 more tests (pain)
* Correct all tsc errors
* Remove to-electron script
* Add an f-ton of shit because playwright doesnt want S P R E A D
* Try CI again
* Stop snapshots of exports (already test in e2e)
* Fix flake in double click editor
* Hopefully help CI flake
* Fixmes, fixmes everywhere
* One more fixme to settings
* Skip another code pane flake
* Port jess's projects.spec tests
* fixup
* Reuse electron window; difficult task
* Rebased and refixed
* Remove duplicate cases
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* Reduce the workers to something CI can handle
* Lower it further, we need to think about the others
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Update package.json
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
* Fix the last tests and tsc errors
* Timeout to 120 and windows-2022-16core
* Fix windows runner detection, enable concurrency temporarily
* Hopefully this time fix windows runner detection
* Comment out Vector, add back removed camera test code
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Fix camera tests again
* Massively deflake a whole class of tests
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: macos-14-large)
* Try new CI and fix small onboarding test
* Derp
* No github tuning
* Try mac
* Add back all the OS
* Lord, hallow be thy name
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Try AWS Windows runner
* Passing on windows locally with a few skips
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* fmt, tsc, lint
* Enable two fixmes again
* Fix lint, codespell, fmt
* Fix lint
* Don't run e2e on draft, add back concurrency, clean up
* One last windows skip
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
2024-12-18 17:58:03 -05:00
|
|
|
}
|
2025-03-13 10:54:00 -04:00
|
|
|
|
|
|
|
if (process.env.PLATFORM === 'web') {
|
|
|
|
Object.assign(fixturesBasedOnProcessEnvPlatform, fixturesForWeb)
|
|
|
|
} else {
|
|
|
|
Object.assign(fixturesBasedOnProcessEnvPlatform, fixturesForElectron)
|
|
|
|
}
|
|
|
|
|
|
|
|
export { fixturesBasedOnProcessEnvPlatform }
|