U1 Lot B1. Four tabs (Général, Annotations, Constats, Vérification); views,
categories and regions become full-width Annotations sections opened from the
overview panel; references move to a header-toggled panel (minimal, Lot D
completes it); « Aller à » goes through EditorTarget and the navigation hook.
EditorWorkspace owns the navigation; DraftHeader split in HeaderActions and
SaveLine; EditorTabs split in TabList and MoreTabs.
R-24, assertions removed or rewritten (file: old -> new):
unit
- editor-route.test: seven tab names -> four; « Plus » at 800 px with
Références clicked -> no « Plus »; below 640 px five others -> Général,
Constats, and Constats opens the findings tab; + references panel cases
- editor-route-recovery.test: tab Références + editor-tab-references label ->
header button + editor-references-panel labelled by its heading
- editor-mode.test: small tier `more` of five -> [general, findings]
- editor-focus-request.test: {key,serial} -> {target,serial}; ReferencesTab and
VertebraeTab -> ReferencesPanel and RegionsSection; issueTarget tab/key ->
target place/section/key (vertebrae tab -> annotations/regions); consumed
context (serial) -> (serial, outcome); annotation case adds heading focus
- editor-verification.test: onGoTo('annotations', key) -> navigate(targetOfKey
(key), opener); props onSelectTab/onGoTo -> navigate
- editor-annotations-tab.test: props onSelectTab -> navigate + section props;
no_category text « (onglet Général) » -> « (Annotations, section
Catégories) »
- editor-tabs-general.test: categories cases render GeneralTab ->
CategoriesSection(doc); + Général holds no categories editor
- editor-tabs-lists.test: tab imports -> panel and section; read-only
references « no button » -> only « Fermer les références »
- editor-tabs-views, editor-drawing-upload, editor-repair.test: ViewsTab ->
ViewsSection import, assertions kept; editor-findings.test: navigate prop
e2e
- support/editor selectTab: exact name -> pattern (error badge in the name);
+ place, openSection, showDrawing, backToDrawing, openReferences, TABS
- support/warm-up: seven tabs -> four + sections + references panel
- editor-access: seven-tab axe loops -> four tabs + three sections + panel
(edit and read-only); narrow widths add panel overflow and axe
- editor-drawings: tab Vues -> openSection views; tab Annotations ->
showDrawing
- editor-structures: tab Général (categories) -> openSection categories, axe
label « general tab » -> « categories section »; tab Références ->
openReferences/closeReferences; tab Vertèbres -> openSection regions; tab
Annotations -> showDrawing
- editor-geometry: three tab Vues -> openSection views
- editor-equine: tab Général (categories add) -> openSection categories; five
tabs loop -> two tabs + sections + panel; tab Annotations -> showDrawing
- editor-journey: tab Vues, tab Général (category), tab Annotations ->
openSection views/categories, showDrawing; frozen axe scrolls to the header
- lan/trial-lan (not run): tab Vues -> Annotations tab + views entry
Verified: typecheck, lint, vitest 107 files / 1125 tests, whole shell suite on
the sandbox 151 passed, 49 skipped, 0 failed.
433 lines
16 KiB
TypeScript
433 lines
16 KiB
TypeScript
import { fr } from '@/i18n/fr'
|
|
import type { Locator, Page, TestInfo } from '@playwright/test'
|
|
import { sql } from '../../../../packages/supabase/tests/sandbox/stack'
|
|
import { stepUpAdmin } from '../support/admin'
|
|
import { expect, expectAccessible, test } from '../support/browser'
|
|
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
|
import {
|
|
annotationList,
|
|
clickDrawing,
|
|
createFromPanel,
|
|
creationPanel,
|
|
editorActor,
|
|
fillCreation,
|
|
geometryField,
|
|
INKSCAPE_EXPORT,
|
|
openDraft,
|
|
openSection,
|
|
saveDraft,
|
|
secondSession,
|
|
selectTab,
|
|
serverDocument,
|
|
showDrawing,
|
|
toolButton,
|
|
} from '../support/editor'
|
|
import { signIn } from '../support/shell'
|
|
|
|
// V1-2.6 journey (contract C26 to C30; the steps of docs/development/V1-2-6_OWNER_TRIAL.md
|
|
// §4, with two editor accounts): a non-equine sheet created from the administration,
|
|
// a drawing, a detail view, findings, categories, points, zones and a link, the save,
|
|
// a reload with the beforeunload dialog and the recovery offer, a conflict with the
|
|
// other account, the submission and the round read back in SQL.
|
|
|
|
const dict = fr
|
|
|
|
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
|
const main = (page: Page) => page.getByRole('main')
|
|
|
|
async function commitText(field: Locator, value: string) {
|
|
await field.fill(value)
|
|
await field.press('Enter')
|
|
}
|
|
|
|
const clickDialog = (dialog: Locator, name: string) =>
|
|
dialog.getByRole('button', { name, exact: true }).click()
|
|
|
|
const clickButton = (page: Page, name: string) =>
|
|
page.getByRole('button', { name, exact: true }).click()
|
|
|
|
async function createSheetFromAdmin(page: Page, tag: string): Promise<string> {
|
|
await page
|
|
.locator('section[aria-labelledby="admin-sheets-title"]')
|
|
.getByRole('link', { name: dict['admin.home.all_sheets'] })
|
|
.click()
|
|
await main(page).getByRole('link', { name: dict['admin.sheets.new'] }).click()
|
|
// The list page has a species filter with the same label: wait for the form's heading.
|
|
await expect(
|
|
main(page).getByRole('heading', {
|
|
level: 1,
|
|
name: dict['admin.sheets.new'],
|
|
}),
|
|
).toBeVisible()
|
|
const species = page.getByLabel(dict['admin.sheet_form.species'], {
|
|
exact: true,
|
|
})
|
|
await expect(species.locator('option[value="canine"]')).toHaveCount(1)
|
|
await species.selectOption('canine')
|
|
await expect(species).toHaveValue('canine')
|
|
await page.getByLabel(dict['admin.sheet_form.name_fr']).fill(`Chien ${tag}`)
|
|
await page.getByLabel(dict['admin.sheet_form.name_en']).fill(`Dog ${tag}`)
|
|
await page
|
|
.getByRole('button', { name: dict['admin.sheet_form.submit'] })
|
|
.click()
|
|
// The creation opens the new draft in the editor directly (the guide's 4.1 says the
|
|
// sheet « apparaît » and is « ouvrable dans l'éditeur »: no overview step).
|
|
await expect(page).toHaveURL(/\/app\/admin\/sheets\/[0-9a-f-]{36}\/draft$/)
|
|
const id = new URL(page.url()).pathname.split('/')[4] ?? ''
|
|
await expect(
|
|
page.getByRole('heading', { level: 1, name: 'Brouillon, version 1' }),
|
|
).toBeVisible()
|
|
return id
|
|
}
|
|
|
|
async function importDrawing(page: Page) {
|
|
await openSection(page, dict, 'views')
|
|
// The real Inkscape 1.4.3 export, cleaned by the core in the page (viewBox 0 0 200 150).
|
|
await page.getByTestId('view-view-main-file').setInputFiles({
|
|
name: 'inkscape-1.4.3.svg',
|
|
mimeType: 'image/svg+xml',
|
|
buffer: INKSCAPE_EXPORT,
|
|
})
|
|
await clickButton(page, dict['editor.cleaning.confirm'])
|
|
await expect(page.getByText(dict['editor.upload.done'])).toBeVisible()
|
|
// The closing modal keeps the page inert until its exit animation ends: text typed
|
|
// before that is dropped (the first fields of the new-view form stayed empty).
|
|
await expect(
|
|
page.getByRole('dialog', { name: dict['editor.cleaning.title'] }),
|
|
).toHaveCount(0)
|
|
await page.locator('#view-new-fr').fill('Détail essai')
|
|
await page.locator('#view-new-en').fill('Trial detail')
|
|
const crop = { min_x: '20', min_y: '20', width: '60', height: '45' }
|
|
for (const [key, value] of Object.entries(crop))
|
|
await page.locator(`#view-new-crop-${key}`).fill(value)
|
|
await clickButton(page, dict['editor.views.add'])
|
|
await expect(
|
|
page.getByRole('listitem', { name: 'Détail essai' }),
|
|
).toBeVisible()
|
|
}
|
|
|
|
async function createFindings(page: Page) {
|
|
await openSection(page, dict, 'categories')
|
|
await page.locator('#category-new-fr').fill('Catégorie essai')
|
|
await page.locator('#category-new-en').fill('Trial category')
|
|
await clickButton(page, dict['editor.general.category_add'])
|
|
await selectTab(page, dict, 'findings')
|
|
const create = () => clickButton(page, dict['editor.findings.create'])
|
|
const names = async (frName: string, enName: string) => {
|
|
await page.locator('#finding-new-name-fr').fill(frName)
|
|
await page.locator('#finding-new-name-en').fill(enName)
|
|
}
|
|
await clickButton(page, dict['editor.findings.add_zone'])
|
|
await names('Zone essai', 'Trial zone')
|
|
await create()
|
|
await clickButton(page, dict['editor.findings.add_category'])
|
|
await page.locator('#finding-new-zone').selectOption({ label: 'Zone essai' })
|
|
await page.locator('#finding-new-kind').selectOption('dysfunction')
|
|
await names('Dysfonction essai', 'Trial dysfunction')
|
|
await create()
|
|
await clickButton(page, dict['editor.findings.add_node'])
|
|
await names('Constat essai', 'Trial finding')
|
|
await create()
|
|
await expect(
|
|
page.getByTestId('finding-item').filter({ hasText: 'Constat essai' }),
|
|
).toBeVisible()
|
|
}
|
|
|
|
async function createAnnotations(page: Page) {
|
|
await showDrawing(page, dict)
|
|
const trace = async (points: number[][]) => {
|
|
for (const [x, y] of points) await clickDrawing(page, x, y)
|
|
await clickButton(page, dict['editor.annotations.trace_close'])
|
|
}
|
|
await toolButton(page, dict, 'point').click()
|
|
await clickDrawing(page, 60, 56)
|
|
await fillCreation(page, dict, { fr: 'Point essai', en: 'Trial point' })
|
|
await creationPanel(page)
|
|
.getByLabel(dict['editor.annotations.zone'])
|
|
.selectOption({ label: 'Zone essai' })
|
|
await createFromPanel(page, dict)
|
|
await toolButton(page, dict, 'zone').click()
|
|
await trace([
|
|
[120, 38],
|
|
[160, 38],
|
|
[140, 75],
|
|
])
|
|
await fillCreation(page, dict, { fr: 'Zone dessinée', en: 'Drawn zone' })
|
|
await creationPanel(page)
|
|
.getByLabel(dict['editor.annotations.zone'])
|
|
.selectOption({ label: 'Zone essai' })
|
|
await createFromPanel(page, dict)
|
|
await toolButton(page, dict, 'link').click()
|
|
await trace([
|
|
[30, 94],
|
|
[70, 94],
|
|
[50, 131],
|
|
])
|
|
await fillCreation(page, dict, { fr: 'Accès essai', en: 'Trial access' })
|
|
await creationPanel(page)
|
|
.getByLabel(dict['editor.annotations.opens'])
|
|
.selectOption({ label: 'Détail essai' })
|
|
await createFromPanel(page, dict)
|
|
}
|
|
|
|
const MODIFIED = { point: 3, vertex: 4 }
|
|
|
|
/** Applies (not only refuses) changes to a point, a zone and a link; read back at the save. */
|
|
async function modifyAnnotations(page: Page) {
|
|
const list = annotationList(page, dict)
|
|
await list.getByRole('button', { name: /Point essai/ }).click()
|
|
const cx = geometryField(page, dict, 'cx')
|
|
const before = Number(await cx.inputValue())
|
|
await commitText(cx, String(before + MODIFIED.point))
|
|
await expect(cx).toHaveValue(String(before + MODIFIED.point))
|
|
await list.getByRole('button', { name: /Zone dessinée/ }).click()
|
|
const vertex = page.getByLabel(
|
|
dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'),
|
|
)
|
|
const start = Number(await vertex.inputValue())
|
|
await commitText(vertex, String(start + MODIFIED.vertex))
|
|
await expect(vertex).toHaveValue(String(start + MODIFIED.vertex))
|
|
await list.getByRole('button', { name: /Accès essai/ }).click()
|
|
await commitText(page.locator('#annotation-name-fr'), 'Accès modifié')
|
|
await page.locator('#annotation-laterality').selectOption('bilateral')
|
|
await expect(page.locator('#annotation-name-fr')).toHaveValue('Accès modifié')
|
|
return { point: before + MODIFIED.point, vertex: start + MODIFIED.vertex }
|
|
}
|
|
|
|
/** Guide 4.4: a click near the edge proposes a position; a far value is refused. */
|
|
async function repairGeometry(page: Page) {
|
|
await toolButton(page, dict, 'point').click()
|
|
// On this 200 x 150 drawing the core keeps a shrunk marker at 1 unit from the edge: the
|
|
// proposal of a corrected position needs a click on the edge itself (editor-geometry
|
|
// covers it on a 1 000-unit drawing). Here the click is placed at once.
|
|
await clickDrawing(page, 1, 1)
|
|
await fillCreation(page, dict, { fr: 'Point de bord', en: 'Edge point' })
|
|
await createFromPanel(page, dict)
|
|
await expect(
|
|
annotationList(page, dict).getByText('Point de bord'),
|
|
).toBeVisible()
|
|
const cx = geometryField(page, dict, 'cx')
|
|
await cx.fill('9999')
|
|
await cx.press('Enter')
|
|
await expect(
|
|
page.getByText(dict['editor.annotations.geometry.unapplied']),
|
|
).toBeVisible()
|
|
await clickButton(page, dict['editor.annotations.geometry.revert'])
|
|
await expect(
|
|
page.getByText(dict['editor.annotations.geometry.unapplied']),
|
|
).toHaveCount(0)
|
|
}
|
|
|
|
/** Guide 4.5: an unsaved change, a reload (beforeunload accepted), the offer, a restore. */
|
|
async function reloadAndRestore(page: Page, sheetId: string) {
|
|
const kinds: string[] = []
|
|
page.on('dialog', (dialog) => {
|
|
kinds.push(dialog.type())
|
|
void dialog.accept()
|
|
})
|
|
await page.reload()
|
|
expect(kinds).toContain('beforeunload')
|
|
await expect(
|
|
page.getByText(dict['editor.draft.recovery.restore'], { exact: true }),
|
|
).toBeVisible()
|
|
await expect(
|
|
page.getByText('Une copie locale temporaire de ce brouillon existe', {
|
|
exact: false,
|
|
}),
|
|
).toBeVisible()
|
|
expect(page.url()).toContain(sheetId)
|
|
await clickButton(page, dict['editor.draft.recovery.restore'])
|
|
await expect(
|
|
page.getByText(dict['editor.draft.status.unsaved'], { exact: false }),
|
|
).toBeVisible()
|
|
}
|
|
|
|
test.describe('editor journey (owner trial steps)', () => {
|
|
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
|
test.beforeEach(async ({ context }, info) => {
|
|
test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
|
|
await routeToSandbox(context)
|
|
})
|
|
test.afterEach(async ({ context }) => {
|
|
await dropLateReplays(context)
|
|
})
|
|
|
|
test('creation to submission with two editor accounts', async ({
|
|
page,
|
|
browser,
|
|
baseURL,
|
|
requests,
|
|
}) => {
|
|
test.setTimeout(240_000)
|
|
const [a, b] = [await editorActor('fr'), await editorActor('fr')]
|
|
for (const actor of [a, b])
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
const tag = a.account.id.slice(0, 8)
|
|
await signIn(page, a.account, dict)
|
|
await page.goto('/app/admin')
|
|
await stepUpAdmin(page, dict, a.secret)
|
|
|
|
const sheetId = await createSheetFromAdmin(page, tag)
|
|
await importDrawing(page)
|
|
await createFindings(page)
|
|
await createAnnotations(page)
|
|
await repairGeometry(page)
|
|
// Undo and redo the numeric repair path's last creation.
|
|
await page
|
|
.getByRole('button', {
|
|
name: dict['editor.annotations.undo'],
|
|
exact: true,
|
|
})
|
|
.click()
|
|
await page
|
|
.getByRole('button', {
|
|
name: dict['editor.annotations.redo'],
|
|
exact: true,
|
|
})
|
|
.click()
|
|
const modified = await modifyAnnotations(page)
|
|
await expectAccessible(page, 'the editor with annotations')
|
|
await saveDraft(page, dict, 1)
|
|
const draftId = await sql(
|
|
`select id from public.anatomical_sheet_versions where sheet_id = '${sheetId}' and status = 'draft'`,
|
|
)
|
|
const saved = await serverDocument<{
|
|
annotations: {
|
|
name?: { fr: string }
|
|
laterality?: string
|
|
geometry: { type: string; cx?: number; points?: number[][] }
|
|
}[]
|
|
}>(draftId)
|
|
const byName = (fr: string) =>
|
|
saved.annotations.find((a) => a.name?.fr === fr)
|
|
expect(byName('Point essai')?.geometry.cx).toBe(modified.point)
|
|
expect(byName('Zone dessinée')?.geometry.points?.[0][0]).toBe(
|
|
modified.vertex,
|
|
)
|
|
expect(byName('Accès modifié')?.laterality).toBe('bilateral')
|
|
|
|
// 4.5: a rename left unsaved survives a reload through the recovery copy.
|
|
await selectTab(page, dict, 'general')
|
|
const name = page.getByLabel(dict['editor.general.name_fr'], {
|
|
exact: true,
|
|
})
|
|
await commitText(name, `Chien révisé ${tag}`)
|
|
await reloadAndRestore(page, sheetId)
|
|
await saveDraft(page, dict, 2)
|
|
|
|
// 4.6: the other account saves first; the conflict names its revision.
|
|
const second = await secondSession(browser, baseURL ?? '', 'fr-FR')
|
|
await signIn(second.page, b.account, dict)
|
|
await second.page.goto('/app/admin')
|
|
await stepUpAdmin(second.page, dict, b.secret)
|
|
await openDraft(second.page, dict, sheetId)
|
|
await selectTab(second.page, dict, 'general')
|
|
await commitText(
|
|
second.page.getByLabel(dict['editor.general.name_en'], { exact: true }),
|
|
`Dog by B ${tag}`,
|
|
)
|
|
await saveDraft(second.page, dict, 3)
|
|
await selectTab(page, dict, 'general')
|
|
await commitText(
|
|
page.getByLabel(dict['editor.general.name_en'], { exact: true }),
|
|
`Dog by A ${tag}`,
|
|
)
|
|
await clickButton(page, dict['common.save'])
|
|
const conflict = page.getByRole('dialog', {
|
|
name: dict['editor.draft.conflict.known'].replace('{revision}', '3'),
|
|
})
|
|
await expect(conflict).toBeVisible()
|
|
await expectAccessible(page, 'the conflict dialog')
|
|
await clickDialog(conflict, dict['editor.draft.conflict.reload'])
|
|
await expect(conflict).toContainText('révision 3')
|
|
await clickDialog(conflict, dict['editor.draft.conflict.reload'])
|
|
await expect(conflict).toBeHidden()
|
|
await expect(
|
|
page.getByText(
|
|
dict['editor.draft.status.revision'].replace('{revision}', '3'),
|
|
{
|
|
exact: true,
|
|
},
|
|
),
|
|
).toBeVisible()
|
|
|
|
// The conflict again, resolved by keeping this version after the confirmation.
|
|
await commitText(
|
|
second.page.getByLabel(dict['editor.general.name_en'], { exact: true }),
|
|
`Dog by B again ${tag}`,
|
|
)
|
|
await saveDraft(second.page, dict, 4)
|
|
await commitText(
|
|
page.getByLabel(dict['editor.general.name_en'], { exact: true }),
|
|
`Dog by A ${tag}`,
|
|
)
|
|
await clickButton(page, dict['common.save'])
|
|
const again = page.getByRole('dialog', {
|
|
name: dict['editor.draft.conflict.known'].replace('{revision}', '4'),
|
|
})
|
|
await clickDialog(again, dict['editor.draft.conflict.keep'])
|
|
await expect(again).toContainText('Remplacer la révision 4')
|
|
await clickDialog(again, dict['editor.draft.conflict.keep'])
|
|
await expect(again).toBeHidden()
|
|
await expect(
|
|
page.getByText(
|
|
dict['editor.draft.status.revision'].replace('{revision}', '5'),
|
|
{
|
|
exact: true,
|
|
},
|
|
),
|
|
).toBeVisible()
|
|
await second.context.close()
|
|
|
|
await selectTab(page, dict, 'verification')
|
|
|
|
// 4.7: elements to confirm are information, never an error; « Aller à » selects.
|
|
const verification = page.getByTestId('editor-tab-verification')
|
|
await expect(
|
|
verification.getByText(
|
|
dict['editor.verification.errors_one'].replace('{count}', '0'),
|
|
),
|
|
).toBeVisible()
|
|
await expect(
|
|
verification.getByText(dict['editor.verification.to_confirm_info']),
|
|
).toBeVisible()
|
|
await expect(
|
|
page.getByRole('tab', { name: dict['editor.tab.verification'] }),
|
|
).not.toContainText(/\d/)
|
|
await expectAccessible(page, 'the verification tab')
|
|
await verification
|
|
.getByRole('button', {
|
|
name: dict['editor.verification.goto'].replace(
|
|
'{tab}',
|
|
'Point de bord',
|
|
),
|
|
})
|
|
.click()
|
|
await expect(page.getByTestId('annotation-selection-tag')).toContainText(
|
|
'Point de bord',
|
|
)
|
|
await selectTab(page, dict, 'verification')
|
|
await page
|
|
.getByLabel(dict['editor.verification.note'])
|
|
.fill('Premier jet complet, éléments à confirmer.')
|
|
await clickButton(page, dict['editor.verification.submit'])
|
|
await expect(
|
|
page.getByText(dict['editor.draft.read_only'], { exact: true }),
|
|
).toBeVisible()
|
|
await expect(
|
|
page.getByText('vérification en cours', { exact: false }),
|
|
).toBeVisible()
|
|
expect(
|
|
await sql(
|
|
`select status from public.anatomical_sheet_reviews where version_id = '${draftId}'`,
|
|
),
|
|
).toBe('verifying')
|
|
// The submit button sits at the page's end: back at the header, whose « Références »
|
|
// button the sticky top bar covers while the page is scrolled.
|
|
await page
|
|
.getByRole('heading', { level: 1, name: 'Brouillon, version 1' })
|
|
.evaluate((heading) => heading.scrollIntoView({ block: 'center' }))
|
|
await expectAccessible(page, 'the frozen draft')
|
|
})
|
|
})
|