* 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>
128 lines
3.8 KiB
TypeScript
128 lines
3.8 KiB
TypeScript
import type { Page, Locator } from '@playwright/test'
|
|
import { expect } from '@playwright/test'
|
|
|
|
interface ProjectCardState {
|
|
title: string
|
|
fileCount: number
|
|
}
|
|
|
|
interface HomePageState {
|
|
projectCards: ProjectCardState[]
|
|
sortBy: 'last-modified-desc' | 'last-modified-asc' | 'name-asc' | 'name-desc'
|
|
}
|
|
|
|
export class HomePageFixture {
|
|
public page: Page
|
|
|
|
projectSection!: Locator
|
|
projectCard!: Locator
|
|
projectCardTitle!: Locator
|
|
projectCardFile!: Locator
|
|
projectCardFolder!: Locator
|
|
projectButtonNew!: Locator
|
|
projectButtonContinue!: Locator
|
|
projectTextName!: Locator
|
|
sortByDateBtn!: Locator
|
|
sortByNameBtn!: Locator
|
|
|
|
constructor(page: Page) {
|
|
this.page = page
|
|
this.reConstruct(page)
|
|
}
|
|
reConstruct = (page: Page) => {
|
|
this.page = page
|
|
|
|
this.projectSection = this.page.getByTestId('home-section')
|
|
|
|
this.projectCard = this.page.getByTestId('project-link')
|
|
this.projectCardTitle = this.page.getByTestId('project-title')
|
|
this.projectCardFile = this.page.getByTestId('project-file-count')
|
|
this.projectCardFolder = this.page.getByTestId('project-folder-count')
|
|
|
|
this.projectButtonNew = this.page.getByTestId('home-new-file')
|
|
this.projectTextName = this.page.getByTestId('cmd-bar-arg-value')
|
|
this.projectButtonContinue = this.page.getByRole('button', {
|
|
name: 'Continue',
|
|
})
|
|
|
|
this.sortByDateBtn = this.page.getByTestId('home-sort-by-modified')
|
|
this.sortByNameBtn = this.page.getByTestId('home-sort-by-name')
|
|
}
|
|
|
|
private _serialiseSortBy = async (): Promise<
|
|
HomePageState['sortBy'] | null
|
|
> => {
|
|
const [dateBtnDesc, dateBtnAsc, nameBtnDesc, nameBtnAsc] =
|
|
await Promise.all([
|
|
this.sortByDateBtn.getByLabel('arrow down').isVisible(),
|
|
this.sortByDateBtn.getByLabel('arrow up').isVisible(),
|
|
this.sortByNameBtn.getByLabel('arrow down').isVisible(),
|
|
this.sortByNameBtn.getByLabel('arrow up').isVisible(),
|
|
])
|
|
if (dateBtnDesc) return 'last-modified-desc'
|
|
if (dateBtnAsc) return 'last-modified-asc'
|
|
if (nameBtnDesc) return 'name-desc'
|
|
if (nameBtnAsc) return 'name-asc'
|
|
return null
|
|
}
|
|
|
|
private _serialiseProjectCards = async (): Promise<
|
|
Array<ProjectCardState>
|
|
> => {
|
|
const projectCards = await this.projectCard.all()
|
|
const projectCardStates: Array<ProjectCardState> = []
|
|
for (const projectCard of projectCards) {
|
|
const [title, fileCount] = await Promise.all([
|
|
(await projectCard.locator(this.projectCardTitle).textContent()) || '',
|
|
Number(await projectCard.locator(this.projectCardFile).textContent()),
|
|
])
|
|
projectCardStates.push({
|
|
title: title,
|
|
fileCount,
|
|
})
|
|
}
|
|
return projectCardStates
|
|
}
|
|
|
|
/**
|
|
* Date is excluded from expectState, since it changes
|
|
* Maybe there a good sanity check we can do each time?
|
|
*/
|
|
expectState = async (expectedState: HomePageState) => {
|
|
await expect
|
|
.poll(async () => {
|
|
const [projectCards, sortBy] = await Promise.all([
|
|
this._serialiseProjectCards(),
|
|
this._serialiseSortBy(),
|
|
])
|
|
return {
|
|
projectCards,
|
|
sortBy,
|
|
}
|
|
})
|
|
.toEqual(expectedState)
|
|
}
|
|
|
|
createAndGoToProject = async (projectTitle: string) => {
|
|
await expect(this.projectSection).not.toHaveText('Loading your Projects...')
|
|
await this.projectButtonNew.click()
|
|
await this.projectTextName.click()
|
|
await this.projectTextName.fill(projectTitle)
|
|
await this.projectButtonContinue.click()
|
|
}
|
|
|
|
openProject = async (projectTitle: string) => {
|
|
const projectCard = this.projectCard.locator(
|
|
this.page.getByText(projectTitle)
|
|
)
|
|
await projectCard.click()
|
|
}
|
|
|
|
goToModelingScene = async (name: string = 'testDefault') => {
|
|
// On web this is a no-op. There is no project view.
|
|
if (process.env.PLATFORM === 'web') return
|
|
|
|
await this.createAndGoToProject(name)
|
|
}
|
|
}
|