fix(editor): verifier gaps: ratified wordings, copy messages, real SVG journeys
This commit is contained in:
1 parent
9ba6d2b66c
commit
d10ba5d5dd
18 files changed
+227
-97
No files matched your search
@@ -9,11 +9,12 @@ import {
|
||||
clickDrawing,
|
||||
createFromPanel,
|
||||
creationPanel,
|
||||
DRAWING_SVG,
|
||||
INKSCAPE_EXPORT,
|
||||
editorActor,
|
||||
fillCreation,
|
||||
geometryField,
|
||||
saveDraft,
|
||||
serverDocument,
|
||||
secondSession,
|
||||
selectTab,
|
||||
toolButton,
|
||||
@@ -79,17 +80,26 @@ async function createSheetFromAdmin(page: Page, tag: string): Promise<string> {
|
||||
|
||||
async function importDrawing(page: Page) {
|
||||
await selectTab(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: 'valide.svg',
|
||||
name: 'inkscape-1.4.3.svg',
|
||||
mimeType: 'image/svg+xml',
|
||||
buffer: Buffer.from(DRAWING_SVG),
|
||||
buffer: INKSCAPE_EXPORT,
|
||||
})
|
||||
await clickButton(page, dict['editor.cleaning.confirm'])
|
||||
await expect(page.getByText(dict['editor.upload.done'])).toBeVisible()
|
||||
await page.locator('#view-new-fr').fill('Détail essai')
|
||||
await page.locator('#view-new-en').fill('Trial detail')
|
||||
const crop = { min_x: '100', min_y: '100', width: '300', height: '240' }
|
||||
for (const [key, value] of Object.entries(crop))
|
||||
await page.locator(`#view-new-crop-${key}`).fill(value)
|
||||
// The new-view form can be reset once while the attached drawing settles: fill until
|
||||
// the values hold.
|
||||
await expect(async () => {
|
||||
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 page.waitForTimeout(400)
|
||||
await expect(page.locator('#view-new-fr')).toHaveValue('Détail essai')
|
||||
await expect(page.locator('#view-new-crop-min_x')).toHaveValue('20')
|
||||
}).toPass()
|
||||
await clickButton(page, dict['editor.views.add'])
|
||||
await expect(
|
||||
page.getByRole('listitem', { name: 'Détail essai' }),
|
||||
@@ -129,7 +139,7 @@ async function createAnnotations(page: Page) {
|
||||
await clickButton(page, dict['editor.annotations.trace_close'])
|
||||
}
|
||||
await toolButton(page, dict, 'point').click()
|
||||
await clickDrawing(page, 300, 300)
|
||||
await clickDrawing(page, 60, 56)
|
||||
await fillCreation(page, dict, { fr: 'Point essai', en: 'Trial point' })
|
||||
await creationPanel(page)
|
||||
.getByLabel(dict['editor.annotations.zone'])
|
||||
@@ -137,9 +147,9 @@ async function createAnnotations(page: Page) {
|
||||
await createFromPanel(page, dict)
|
||||
await toolButton(page, dict, 'zone').click()
|
||||
await trace([
|
||||
[600, 200],
|
||||
[800, 200],
|
||||
[700, 400],
|
||||
[120, 38],
|
||||
[160, 38],
|
||||
[140, 75],
|
||||
])
|
||||
await fillCreation(page, dict, { fr: 'Zone dessinée', en: 'Drawn zone' })
|
||||
await creationPanel(page)
|
||||
@@ -148,9 +158,9 @@ async function createAnnotations(page: Page) {
|
||||
await createFromPanel(page, dict)
|
||||
await toolButton(page, dict, 'link').click()
|
||||
await trace([
|
||||
[150, 500],
|
||||
[350, 500],
|
||||
[250, 700],
|
||||
[30, 94],
|
||||
[70, 94],
|
||||
[50, 131],
|
||||
])
|
||||
await fillCreation(page, dict, { fr: 'Accès essai', en: 'Trial access' })
|
||||
await creationPanel(page)
|
||||
@@ -159,19 +169,39 @@ async function createAnnotations(page: Page) {
|
||||
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()
|
||||
await clickDrawing(page, 3, 3)
|
||||
// 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 creationPanel(page)
|
||||
.getByRole('button', { name: dict['editor.annotations.create'] })
|
||||
.click()
|
||||
const correction = page.getByTestId('correction-notice')
|
||||
await expect(correction).toBeVisible()
|
||||
await correction
|
||||
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
|
||||
.click()
|
||||
await createFromPanel(page, dict)
|
||||
await expect(
|
||||
annotationList(page, dict).getByText('Point de bord'),
|
||||
).toBeVisible()
|
||||
@@ -254,8 +284,26 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
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')
|
||||
@@ -368,9 +416,6 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
await expect(
|
||||
page.getByText('vérification en cours', { exact: false }),
|
||||
).toBeVisible()
|
||||
const draftId = await sql(
|
||||
`select id from public.anatomical_sheet_versions where sheet_id = '${sheetId}' and status = 'draft'`,
|
||||
)
|
||||
expect(
|
||||
await sql(
|
||||
`select status from public.anatomical_sheet_reviews where version_id = '${draftId}'`,
|
||||
|
||||
Reference in new issue
Block a user