@playwright/test 1.64.1 and @axe-core/playwright 4.14.0, dev only and pinned. pnpm e2e:ui runs a Vite server of its own on 127.0.0.1:5191 with no backend: the Dialog contract on a dev-only test page and the local tool's dialogs, desktop and 375 px, FR and EN, axe at zero serious violation outside one listed pre-existing finding. Requests outside the allowlist are aborted and fail the test.
105 lines
3.8 KiB
TypeScript
105 lines
3.8 KiB
TypeScript
import { en } from '@/i18n/en'
|
|
import { fr } from '@/i18n/fr'
|
|
import {
|
|
expect,
|
|
expectAccessible,
|
|
expectNoHorizontalOverflow,
|
|
focusOwner,
|
|
focusedName,
|
|
test,
|
|
} from '../support/browser'
|
|
import type { Page } from '@playwright/test'
|
|
import type { Dict } from '@/i18n/types'
|
|
|
|
// The shared Dialog where the local tool uses it, on the real routes with no
|
|
// backend: the sheet disclaimer, the edit dialog and the replace confirmation.
|
|
// Fictitious names only.
|
|
|
|
const ANIMAL = 'Fictif Alezan'
|
|
|
|
/** Required label text without the trailing « * » marker. */
|
|
const label = (dict: Dict, key: string) => dict[key].replace(/\s*\*$/, '')
|
|
|
|
async function startReport(page: Page, dict: Dict) {
|
|
await page
|
|
.getByLabel(label(dict, 'form.practitioner.name'))
|
|
.fill('Praticien Fictif')
|
|
await page.getByLabel(label(dict, 'form.animal.name')).fill(ANIMAL)
|
|
await page
|
|
.getByLabel(label(dict, 'form.owner.name'))
|
|
.fill('Propriétaire Fictif')
|
|
await page.getByRole('button', { name: dict['new_report.submit'] }).click()
|
|
}
|
|
|
|
for (const [locale, dict] of [
|
|
['fr-FR', fr],
|
|
['en-GB', en],
|
|
] as const) {
|
|
test.describe(`local tool (${locale})`, () => {
|
|
test.use({ locale, forbiddenInUrls: [ANIMAL, 'Fictif'] })
|
|
|
|
test('editor dialogs: disclaimer, edit, replace confirmation', async ({
|
|
page,
|
|
}) => {
|
|
await page.goto('/')
|
|
// Scanned once the sheet is loaded: the import button fades in from disabled.
|
|
await expect(
|
|
page.getByRole('button', { name: dict['home.import.cta'] }),
|
|
).toBeEnabled()
|
|
await expectAccessible(page, 'home')
|
|
await page
|
|
.getByRole('button', { name: dict['home.new_report.cta'] })
|
|
.click()
|
|
await expect(page).toHaveURL(/\/new$/)
|
|
await expectNoHorizontalOverflow(page, 'new report')
|
|
await startReport(page, dict)
|
|
|
|
await expect(page).toHaveURL(/\/editor$/)
|
|
const disclaimer = page.getByRole('dialog', {
|
|
name: dict['editor.disclaimer_title'],
|
|
})
|
|
await expect(disclaimer).toBeVisible()
|
|
expect(await disclaimer.getAttribute('aria-describedby')).toBeTruthy()
|
|
expect(await focusOwner(page)).toBe('dialog')
|
|
expect(await focusedName(page)).toBe(dict['common.close'])
|
|
await page.keyboard.press('Tab')
|
|
expect(await focusedName(page)).toBe(dict['common.understood'])
|
|
await expectAccessible(page, 'editor with the disclaimer')
|
|
await expectNoHorizontalOverflow(page, 'editor with the disclaimer')
|
|
await page.keyboard.press('Escape')
|
|
await expect(disclaimer).toBeHidden()
|
|
|
|
const edit = page.getByRole('button', { name: dict['editor.edit_infos'] })
|
|
await edit.focus()
|
|
await page.keyboard.press('Enter')
|
|
const editDialog = page.getByRole('dialog', {
|
|
name: dict['editor.edit_dialog_title'],
|
|
})
|
|
await expect(editDialog).toBeVisible()
|
|
expect(await focusOwner(page)).toBe('dialog')
|
|
await expectNoHorizontalOverflow(page, 'edit dialog')
|
|
await page.keyboard.press('Escape')
|
|
await expect(editDialog).toBeHidden()
|
|
await expect(edit).toBeFocused()
|
|
|
|
// A reload: the bilan stays in the tab, not yet in the store (the « unloaded » message).
|
|
await page.goto('/new')
|
|
await startReport(page, dict)
|
|
const replace = page.getByRole('dialog', {
|
|
name: dict['session.replace.title'],
|
|
})
|
|
await expect(replace).toBeVisible()
|
|
await expect(replace).toHaveAccessibleDescription(
|
|
dict['session.replace.body_unloaded'],
|
|
)
|
|
await expectAccessible(page, 'replace confirmation')
|
|
await page.keyboard.press('Escape')
|
|
await expect(replace).toBeHidden()
|
|
await expect(page).toHaveURL(/\/new$/)
|
|
await expect(
|
|
page.getByRole('button', { name: dict['new_report.submit'] }),
|
|
).toBeFocused()
|
|
})
|
|
})
|
|
}
|