Files
modeling-app/e2e/playwright/fixtureSetup.ts
Kurt Hutten 579151a9bb Sketch on chamfer UI (#3918)
* sketch on chamfer start

* working

* step app from getting in weird state when selection face to sketch on

* sketch on chamfer tests

* clean up

* fix test

* fix click selections for chamfers, add tests

* fixture setup (#3964)

* initial break up

* rename main fixture file

* add more expect state pattern

* add fixture comment

* add comments to chamfer function

* typos

* works without pipeExpr
2024-09-26 18:25:05 +10:00

71 lines
1.8 KiB
TypeScript

import type { Page } from '@playwright/test'
import { test as base } from '@playwright/test'
import { getUtils, setup, tearDown } 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'
export class AuthenticatedApp {
public readonly page: Page
constructor(page: Page) {
this.page = page
}
async initialise(code = '') {
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({ width: 1000, height: 500 })
await u.waitForAuthSkipAppStart()
}
getInputFile = (fileName: string) => {
return fsp.readFile(
join('src', 'wasm-lib', 'tests', 'executor', 'inputs', fileName),
'utf-8'
)
}
}
export const test = base.extend<{
app: AuthenticatedApp
cmdBar: CmdBarFixture
editor: EditorFixture
toolbar: ToolbarFixture
scene: SceneFixture
}>({
app: async ({ page }, use) => {
await use(new AuthenticatedApp(page))
},
cmdBar: async ({ page }, use) => {
await use(new CmdBarFixture(page))
},
editor: async ({ page }, use) => {
await use(new EditorFixture(page))
},
toolbar: async ({ page }, use) => {
await use(new ToolbarFixture(page))
},
scene: async ({ page }, use) => {
await use(new SceneFixture(page))
},
})
test.beforeEach(async ({ context, page }, testInfo) => {
await setup(context, page, testInfo)
})
test.afterEach(async ({ page }, testInfo) => {
await tearDown(page, testInfo)
})
export { expect } from '@playwright/test'