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.
319 lines
12 KiB
TypeScript
319 lines
12 KiB
TypeScript
import { fr } from '@/i18n/fr'
|
|
import type { Locator, Page, TestInfo } from '@playwright/test'
|
|
import { expect, expectAccessible, test } from '../support/browser'
|
|
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
|
import {
|
|
bareShape,
|
|
closeReferences,
|
|
editorActor,
|
|
openEditor,
|
|
openReferences,
|
|
openSection,
|
|
pointOf,
|
|
saveDraft,
|
|
seedDraft,
|
|
selectTab,
|
|
serverDocument,
|
|
serverRevision,
|
|
shapeWith,
|
|
showDrawing,
|
|
} from '../support/editor'
|
|
|
|
// V1-2.6 A4 (contract C9 to C12, C19): the structures around the drawing. Annotation
|
|
// categories, references, vertebral regions, then the findings tree (zones, categories,
|
|
// nodes): add, edit, reorder, mark reviewed, delete with and without dependents.
|
|
|
|
const dict = fr
|
|
|
|
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
|
const dialog = (page: Page) => page.getByRole('dialog')
|
|
const button = (page: Page, name: string) =>
|
|
page.getByRole('button', { name, exact: true })
|
|
|
|
async function open(page: Page, ...annotations: unknown[]) {
|
|
const actor = await editorActor('fr')
|
|
const seed = await seedDraft(actor, { shape: shapeWith(...annotations) })
|
|
await openEditor(page, dict, actor, seed.sheetId)
|
|
return { actor, seed }
|
|
}
|
|
|
|
async function commitText(field: Locator, value: string) {
|
|
await field.fill(value)
|
|
await field.press('Enter')
|
|
}
|
|
|
|
test.describe('editor structures (A4)', () => {
|
|
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('categories, references and regions: add, edit, reorder, delete', async ({
|
|
page,
|
|
requests,
|
|
}) => {
|
|
const { actor, seed } = await open(page)
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
|
|
// A category added, then renamed in place.
|
|
await openSection(page, dict, 'categories')
|
|
await page.locator('#category-new-fr').fill('Catégorie B')
|
|
await page.locator('#category-new-en').fill('Category B')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.general.category_add'] })
|
|
.click()
|
|
const names = page.locator('[id^="category-"][id$="-name-fr"]')
|
|
await expect(page.locator('#category-new-fr')).toHaveValue('')
|
|
await expect(names).toHaveCount(2)
|
|
await commitText(names.nth(1), 'Catégorie B bis')
|
|
await expect(names.nth(1)).toHaveValue('Catégorie B bis')
|
|
await expectAccessible(page, 'the categories section')
|
|
|
|
// Two references, the second moved up.
|
|
await openReferences(page, dict)
|
|
for (const citation of ['Première référence', 'Seconde référence']) {
|
|
await page.locator('#reference-new-type').selectOption('book')
|
|
await page.locator('#reference-new-citation').fill(citation)
|
|
await page
|
|
.getByRole('button', { name: dict['editor.reference.add'] })
|
|
.click()
|
|
await expect(page.getByText(citation)).toBeVisible()
|
|
}
|
|
const citations = page.locator(
|
|
'[id^="reference-"][id$="-citation"]:not(#reference-new-citation)',
|
|
)
|
|
await expect(citations).toHaveCount(2)
|
|
await page
|
|
.getByRole('listitem')
|
|
.filter({ hasText: 'Seconde référence' })
|
|
.getByRole('button', { name: dict['editor.action.move_up'] })
|
|
.click()
|
|
await expect(citations.first()).toHaveValue('Seconde référence')
|
|
await page
|
|
.getByRole('listitem')
|
|
.filter({ hasText: 'Première référence' })
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await dialog(page)
|
|
.getByRole('button', { name: dict['editor.delete.confirm'] })
|
|
.click()
|
|
await expect(citations).toHaveCount(1)
|
|
|
|
// A region with its count.
|
|
await closeReferences(page, dict)
|
|
await openSection(page, dict, 'regions')
|
|
await page.locator('#region-new-code').fill('T')
|
|
await page.locator('#region-new-fr').fill('Thoracique')
|
|
await page.locator('#region-new-en').fill('Thoracic')
|
|
await page.locator('#region-new-count').fill('18')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.vertebra.add'] })
|
|
.click()
|
|
await commitText(page.locator('#region-T-count'), '17')
|
|
await expect(page.locator('#region-T-count')).toHaveValue('17')
|
|
|
|
await saveDraft(page, dict, seed.revision + 1)
|
|
const saved = await serverDocument<{
|
|
categories: { name: { fr: string } }[]
|
|
references: { citation: string }[]
|
|
vertebral_config: { regions: { code: string; count: number }[] }
|
|
}>(seed.draftId)
|
|
expect(saved.categories.map((c) => c.name.fr)).toEqual([
|
|
'Catégorie A',
|
|
'Catégorie B bis',
|
|
])
|
|
expect(saved.references.map((r) => r.citation)).toEqual([
|
|
'Seconde référence',
|
|
])
|
|
expect(saved.vertebral_config.regions).toEqual([
|
|
expect.objectContaining({ code: 'T', count: 17 }),
|
|
])
|
|
})
|
|
|
|
test('the findings tree: add zone, category and node, review, reorder', async ({
|
|
page,
|
|
requests,
|
|
}) => {
|
|
const { actor, seed } = await open(page)
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
await selectTab(page, dict, 'findings')
|
|
const items = page.getByTestId('finding-item')
|
|
// The seeded zone is open: the zone and its category show, the node is folded.
|
|
await expect(items).toHaveCount(2)
|
|
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.add_zone'] })
|
|
.click()
|
|
await page.locator('#finding-new-name-fr').fill('Zone B')
|
|
await page.locator('#finding-new-name-en').fill('Zone B en')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.create'] })
|
|
.click()
|
|
await expect(items.filter({ hasText: 'Zone B' })).toBeVisible()
|
|
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.add_category'] })
|
|
.click()
|
|
await page.locator('#finding-new-zone').selectOption({ label: 'Zone B' })
|
|
await page.locator('#finding-new-kind').selectOption('anamnesis')
|
|
await page.locator('#finding-new-name-fr').fill('Anamnèse B')
|
|
await page.locator('#finding-new-name-en').fill('History B')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.create'] })
|
|
.click()
|
|
const category = items.filter({ hasText: 'Anamnèse B' })
|
|
await expect(category).toBeVisible()
|
|
await expect(
|
|
category.getByText(dict['editor.findings.status.to_confirm']),
|
|
).toBeVisible()
|
|
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.add_node'] })
|
|
.click()
|
|
await page.locator('#finding-new-name-fr').fill('Constat B1')
|
|
await page.locator('#finding-new-name-en').fill('Finding B1')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.create'] })
|
|
.click()
|
|
const node = items.filter({ hasText: 'Constat B1' })
|
|
await expect(node).toBeVisible()
|
|
|
|
// Marked reviewed: the badge of the row follows.
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.mark_reviewed'] })
|
|
.click()
|
|
await expect(
|
|
node.getByText(dict['editor.findings.status.reviewed']),
|
|
).toBeVisible()
|
|
await expectAccessible(page, 'the findings tree')
|
|
|
|
// Reorder: the new zone moves above the seeded one.
|
|
await items.filter({ hasText: 'Zone B' }).first().click()
|
|
await page
|
|
.getByRole('button', { name: dict['editor.action.move_up'] })
|
|
.click()
|
|
await expect(items.first()).toContainText('Zone B')
|
|
|
|
await saveDraft(page, dict, seed.revision + 1)
|
|
const saved = await serverDocument<{
|
|
finding_zones: { name: { fr: string } }[]
|
|
}>(seed.draftId)
|
|
expect(saved.finding_zones.map((z) => z.name.fr)).toEqual([
|
|
'Zone B',
|
|
'Zone A',
|
|
])
|
|
})
|
|
|
|
test('a draft stored with bare nodes loads filled: rename, save, reload clean', async ({
|
|
page,
|
|
requests,
|
|
}) => {
|
|
const actor = await editorActor('fr')
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
const seed = await seedDraft(actor, { shape: bareShape })
|
|
await openEditor(page, dict, actor, seed.sheetId)
|
|
await selectTab(page, dict, 'findings')
|
|
const items = page.getByTestId('finding-item')
|
|
await items.filter({ hasText: 'Catégorie nue' }).click()
|
|
await commitText(page.locator('#finding-name-fr'), 'Catégorie renommée')
|
|
await saveDraft(page, dict, seed.revision + 1)
|
|
|
|
const saved = await serverDocument<{
|
|
finding_zones: { categories: { reference_ids: string[] }[] }[]
|
|
}>(seed.draftId)
|
|
expect(saved.finding_zones[0].categories[0].reference_ids).toEqual([])
|
|
expect(await serverRevision(seed.draftId)).toBe(seed.revision + 1)
|
|
|
|
await page.reload()
|
|
await selectTab(page, dict, 'findings')
|
|
await expect(items.filter({ hasText: 'Catégorie renommée' })).toBeVisible()
|
|
await expect(
|
|
page.getByText(dict['editor.draft.status.unsaved'], { exact: false }),
|
|
).toHaveCount(0)
|
|
await expect(
|
|
button(page, dict['editor.draft.recovery.restore']),
|
|
).toHaveCount(0)
|
|
})
|
|
|
|
test('delete with dependents: refused with the list; without, descendants named', async ({
|
|
page,
|
|
requests,
|
|
}) => {
|
|
const { actor } = await open(
|
|
page,
|
|
pointOf('p1', 'main', { cx: 500, cy: 400, r: 40 }, 'Point lié'),
|
|
)
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
|
|
// The category is used by the point: the dialog lists it and offers no deletion.
|
|
await openSection(page, dict, 'categories')
|
|
await page
|
|
.getByRole('listitem')
|
|
.filter({ has: page.locator('#category-cat-a-name-fr') })
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await expect(
|
|
dialog(page).getByText(
|
|
dict['editor.delete.blocked'].replace('{name}', 'Catégorie A'),
|
|
),
|
|
).toBeVisible()
|
|
await expect(dialog(page).getByText('Point lié')).toBeVisible()
|
|
await expect(
|
|
dialog(page).getByRole('button', { name: dict['editor.delete.confirm'] }),
|
|
).toHaveCount(0)
|
|
await dialog(page)
|
|
.getByRole('button', { name: dict['editor.delete.close'], exact: true })
|
|
.last()
|
|
.click()
|
|
|
|
// The zone is linked by the point as well: refused.
|
|
await selectTab(page, dict, 'findings')
|
|
const zone = page.getByTestId('finding-item').filter({ hasText: 'Zone A' })
|
|
await zone.first().click()
|
|
await page
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await expect(
|
|
dialog(page).getByText(
|
|
dict['editor.delete.blocked'].replace('{name}', 'Zone A'),
|
|
),
|
|
).toBeVisible()
|
|
await dialog(page)
|
|
.getByRole('button', { name: dict['editor.delete.close'], exact: true })
|
|
.last()
|
|
.click()
|
|
|
|
// The point goes first; the zone then deletes with its descendants named.
|
|
await showDrawing(page, dict)
|
|
await page
|
|
.getByRole('list', { name: dict['editor.annotations.list'] })
|
|
.getByRole('button', { name: /Point lié/ })
|
|
.click()
|
|
await page
|
|
.getByTestId('annotation-properties')
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await dialog(page)
|
|
.getByRole('button', { name: dict['editor.delete.confirm'] })
|
|
.click()
|
|
await selectTab(page, dict, 'findings')
|
|
await zone.first().click()
|
|
await page
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await expect(
|
|
dialog(page).getByText(dict['editor.delete.descendants']),
|
|
).toBeVisible()
|
|
await expect(dialog(page).getByText('Dysfonction A')).toBeVisible()
|
|
await dialog(page)
|
|
.getByRole('button', { name: dict['editor.delete.confirm'] })
|
|
.click()
|
|
await expect(page.getByTestId('finding-item')).toHaveCount(0)
|
|
await expect(page.getByText(dict['editor.findings.empty'])).toBeVisible()
|
|
})
|
|
})
|