* 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>
		
			
				
	
	
		
			139 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			139 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import type {
 | 
						|
  BrowserContext,
 | 
						|
  ElectronApplication,
 | 
						|
  TestInfo,
 | 
						|
  Page,
 | 
						|
} from '@playwright/test'
 | 
						|
 | 
						|
import { getUtils, setup, setupElectron } from '../test-utils'
 | 
						|
import fsp from 'fs/promises'
 | 
						|
import { join } from 'path'
 | 
						|
import { CmdBarFixture } from './cmdBarFixture'
 | 
						|
import { EditorFixture } from './editorFixture'
 | 
						|
import { ToolbarFixture } from './toolbarFixture'
 | 
						|
import { SceneFixture } from './sceneFixture'
 | 
						|
import { SaveSettingsPayload } from 'lib/settings/settingsTypes'
 | 
						|
import { HomePageFixture } from './homePageFixture'
 | 
						|
import { unsafeTypedKeys } from 'lib/utils'
 | 
						|
 | 
						|
export class AuthenticatedApp {
 | 
						|
  public readonly page: Page
 | 
						|
  public readonly context: BrowserContext
 | 
						|
  public readonly testInfo: TestInfo
 | 
						|
  public readonly viewPortSize = { width: 1200, height: 500 }
 | 
						|
  public electronApp: undefined | ElectronApplication
 | 
						|
  public dir: string = ''
 | 
						|
 | 
						|
  constructor(context: BrowserContext, page: Page, testInfo: TestInfo) {
 | 
						|
    this.context = context
 | 
						|
    this.page = page
 | 
						|
    this.testInfo = testInfo
 | 
						|
  }
 | 
						|
 | 
						|
  async initialise(code = '') {
 | 
						|
    await setup(this.context, this.page, this.testInfo)
 | 
						|
    const u = await getUtils(this.page)
 | 
						|
 | 
						|
    await this.page.addInitScript(async (code) => {
 | 
						|
      localStorage.setItem('persistCode', code)
 | 
						|
      ;(window as any).playwrightSkipFilePicker = true
 | 
						|
    }, code)
 | 
						|
 | 
						|
    await this.page.setViewportSize(this.viewPortSize)
 | 
						|
 | 
						|
    await u.waitForAuthSkipAppStart()
 | 
						|
  }
 | 
						|
  getInputFile = (fileName: string) => {
 | 
						|
    return fsp.readFile(
 | 
						|
      join('src', 'wasm-lib', 'tests', 'executor', 'inputs', fileName),
 | 
						|
      'utf-8'
 | 
						|
    )
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
export interface Fixtures {
 | 
						|
  cmdBar: CmdBarFixture
 | 
						|
  editor: EditorFixture
 | 
						|
  toolbar: ToolbarFixture
 | 
						|
  scene: SceneFixture
 | 
						|
  homePage: HomePageFixture
 | 
						|
}
 | 
						|
export class AuthenticatedTronApp {
 | 
						|
  public readonly _page: Page
 | 
						|
  public page: Page
 | 
						|
  public context: BrowserContext
 | 
						|
  public readonly testInfo: TestInfo
 | 
						|
  public electronApp: ElectronApplication | undefined
 | 
						|
  public readonly viewPortSize = { width: 1200, height: 500 }
 | 
						|
  public dir: string = ''
 | 
						|
 | 
						|
  constructor(context: BrowserContext, page: Page, testInfo: TestInfo) {
 | 
						|
    this._page = page
 | 
						|
    this.page = page
 | 
						|
    this.context = context
 | 
						|
    this.testInfo = testInfo
 | 
						|
  }
 | 
						|
  async initialise(
 | 
						|
    arg: {
 | 
						|
      fixtures: Partial<Fixtures>
 | 
						|
      folderSetupFn?: (projectDirName: string) => Promise<void>
 | 
						|
      cleanProjectDir?: boolean
 | 
						|
      appSettings?: Partial<SaveSettingsPayload>
 | 
						|
    } = { fixtures: {} }
 | 
						|
  ) {
 | 
						|
    const { electronApp, page, context, dir } = await setupElectron({
 | 
						|
      testInfo: this.testInfo,
 | 
						|
      folderSetupFn: arg.folderSetupFn,
 | 
						|
      cleanProjectDir: arg.cleanProjectDir,
 | 
						|
      appSettings: arg.appSettings,
 | 
						|
    })
 | 
						|
    this.page = page
 | 
						|
    this.context = context
 | 
						|
    this.electronApp = electronApp
 | 
						|
    this.dir = dir
 | 
						|
 | 
						|
    // Easier to access throughout utils
 | 
						|
    this.page.dir = dir
 | 
						|
 | 
						|
    // Setup localStorage, addCookies, reload
 | 
						|
    await setup(this.context, this.page, this.testInfo)
 | 
						|
 | 
						|
    for (const key of unsafeTypedKeys(arg.fixtures)) {
 | 
						|
      const fixture = arg.fixtures[key]
 | 
						|
      if (
 | 
						|
        !fixture ||
 | 
						|
        fixture instanceof AuthenticatedApp ||
 | 
						|
        fixture instanceof AuthenticatedTronApp
 | 
						|
      )
 | 
						|
        continue
 | 
						|
      fixture.reConstruct(page)
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  close = async () => {
 | 
						|
    await this.electronApp?.close?.()
 | 
						|
  }
 | 
						|
  debugPause = () =>
 | 
						|
    new Promise(() => {
 | 
						|
      console.log('UN-RESOLVING PROMISE')
 | 
						|
    })
 | 
						|
}
 | 
						|
 | 
						|
export const fixtures = {
 | 
						|
  cmdBar: async ({ page }: { page: Page }, use: any) => {
 | 
						|
    await use(new CmdBarFixture(page))
 | 
						|
  },
 | 
						|
  editor: async ({ page }: { page: Page }, use: any) => {
 | 
						|
    await use(new EditorFixture(page))
 | 
						|
  },
 | 
						|
  toolbar: async ({ page }: { page: Page }, use: any) => {
 | 
						|
    await use(new ToolbarFixture(page))
 | 
						|
  },
 | 
						|
  scene: async ({ page }: { page: Page }, use: any) => {
 | 
						|
    await use(new SceneFixture(page))
 | 
						|
  },
 | 
						|
  homePage: async ({ page }: { page: Page }, use: any) => {
 | 
						|
    await use(new HomePageFixture(page))
 | 
						|
  },
 | 
						|
}
 |