Files
faunosteo/apps/app/e2e/support/warm-up.ts
T

53 lines
1.6 KiB
TypeScript

/**
* Global setup of the shell suite (V1-2.6): the Vite dev server discovers some
* dependencies only when a route first loads them and answers with a full page
* reload, which wiped a form a test had begun to fill. One throwaway session
* visits the editor routes and every tab once before the tests start, so the
* reload happens here and not in a test.
*/
import { chromium, type FullConfig } from '@playwright/test'
import { fr } from '@/i18n/fr'
import { stepUpAdmin } from './admin'
import {
draftPath,
editorActor,
secondSession,
seedDraft,
standardShape,
} from './editor'
import { signIn } from './shell'
const TABS = [
'general',
'views',
'annotations',
'findings',
'references',
'vertebrae',
'verification',
] as const
export default async function warmUp(config: FullConfig): Promise<void> {
const baseURL = config.projects[0].use.baseURL ?? ''
const actor = await editorActor('fr')
const seed = await seedDraft(actor, { shape: standardShape })
const browser = await chromium.launch()
const { page } = await secondSession(browser, baseURL, 'fr-FR')
await signIn(page, actor.account, fr)
await page.goto('/app/admin')
await stepUpAdmin(page, fr, actor.secret)
for (const path of ['/app/admin/sheets/new', draftPath(seed.sheetId)]) {
await page.goto(path)
await page.waitForLoadState('networkidle')
}
for (const tab of TABS) {
await page
.getByRole('tab', { name: fr[`editor.tab.${tab}`], exact: true })
.click()
await page.waitForLoadState('networkidle')
}
await page.goto('/app/admin/sheets/new')
await page.waitForLoadState('networkidle')
await browser.close()
}