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
@@ -25,7 +25,7 @@ import { signIn } from '../support/shell'
|
||||
// V1-2.6 access, narrow screens and axe (contract C26, C31; plan « Modes, permissions,
|
||||
// layout »): a reviewer-only account and an editor without the admin role read the draft
|
||||
// without editing it, an account without a capability is refused, the editor is read-only
|
||||
// at 320, 375 and 800 px and edits at 1 024 px, with no sideways scroll, and axe finds no
|
||||
// at 320, 375, 768 and 800 px and edits at 1 024 px, with no sideways scroll, and axe finds no
|
||||
// serious violation on any tab, edit or read-only.
|
||||
|
||||
const dict = fr
|
||||
@@ -126,7 +126,7 @@ test.describe('editor access, narrow screens and axe', () => {
|
||||
})
|
||||
}
|
||||
|
||||
for (const width of [320, 375, 800]) {
|
||||
for (const width of [320, 375, 768, 800]) {
|
||||
test(`read-only at ${width} px, no horizontal scroll`, async ({
|
||||
page,
|
||||
requests,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { expect, expectAccessible, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
DRAWING_SVG,
|
||||
INKSCAPE_EXPORT,
|
||||
editorActor,
|
||||
openEditor,
|
||||
seedDraft,
|
||||
@@ -20,21 +21,11 @@ import {
|
||||
|
||||
const dict = fr
|
||||
|
||||
const INKSCAPE_SVG =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" ' +
|
||||
'xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ' +
|
||||
'xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" ' +
|
||||
'viewBox="0 0 400 300" inkscape:version="1.3">' +
|
||||
'<sodipodi:namedview id="base" inkscape:zoom="0.5"/>' +
|
||||
'<metadata id="m1"><x:xmpmeta xmlns:x="adobe:ns:meta/"/></metadata>' +
|
||||
'<style>.a{fill:#c96}</style>' +
|
||||
'<rect class="a" x="20" y="20" width="360" height="260"/></svg>'
|
||||
|
||||
const HOSTILE_SVG =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300">' +
|
||||
'<script>alert(1)</script><rect x="20" y="20" width="360" height="260"/></svg>'
|
||||
|
||||
const file = (svg: string, name = 'dessin.svg') => ({
|
||||
const file = (svg: string | Buffer, name = 'dessin.svg') => ({
|
||||
name,
|
||||
mimeType: 'image/svg+xml',
|
||||
buffer: Buffer.from(svg),
|
||||
@@ -92,7 +83,9 @@ test.describe('editor drawings (A2)', () => {
|
||||
await openEditor(page, dict, actor, seed.sheetId)
|
||||
await selectTab(page, dict, 'views')
|
||||
|
||||
await mainFile(page).setInputFiles(file(INKSCAPE_SVG, 'inkscape.svg'))
|
||||
await mainFile(page).setInputFiles(
|
||||
file(INKSCAPE_EXPORT, 'inkscape-1.4.3.svg'),
|
||||
)
|
||||
const dialog = page.getByRole('dialog', {
|
||||
name: dict['editor.cleaning.title'],
|
||||
})
|
||||
@@ -100,7 +93,9 @@ test.describe('editor drawings (A2)', () => {
|
||||
await expect(
|
||||
dialog.getByTestId('cleaning-preview').locator('svg'),
|
||||
).toBeVisible()
|
||||
await expect(dialog.getByText(dict['editor.cleaning.style'])).toBeVisible()
|
||||
await expect(
|
||||
dialog.getByText(dict['editor.cleaning.removed']),
|
||||
).toBeVisible()
|
||||
await expectAccessible(page, 'the cleaning box')
|
||||
await dialog
|
||||
.getByRole('button', { name: dict['editor.cleaning.cancel'] })
|
||||
@@ -110,7 +105,9 @@ test.describe('editor drawings (A2)', () => {
|
||||
mainDrawing(page).getByText(dict['editor.views.drawing.none']),
|
||||
).toBeVisible()
|
||||
|
||||
await mainFile(page).setInputFiles(file(INKSCAPE_SVG, 'inkscape.svg'))
|
||||
await mainFile(page).setInputFiles(
|
||||
file(INKSCAPE_EXPORT, 'inkscape-1.4.3.svg'),
|
||||
)
|
||||
await dialog
|
||||
.getByRole('button', { name: dict['editor.cleaning.confirm'] })
|
||||
.click()
|
||||
|
||||
@@ -34,7 +34,6 @@ const REPO = join(__dirname, '../../../..')
|
||||
const BUDGET_MS = 500
|
||||
const SAMPLES = 15
|
||||
|
||||
|
||||
interface Sample {
|
||||
handler: number
|
||||
paint: number
|
||||
|
||||
@@ -132,6 +132,19 @@ test.describe('editor geometry (adversarial)', () => {
|
||||
const shown = await proposed(page)
|
||||
expect(Number(shown.x)).toBeGreaterThan(100)
|
||||
expect(Number(shown.y)).toBeGreaterThan(100)
|
||||
// Cancelled first: nothing is added to the crop's view.
|
||||
await notice(page)
|
||||
.getByRole('button', {
|
||||
name: dict['editor.annotations.correction_cancel'],
|
||||
})
|
||||
.click()
|
||||
await expect(notice(page)).toHaveCount(0)
|
||||
await expect(list(page)).toHaveCount(0)
|
||||
// Then confirmed: the same attempt again inserts the corrected position.
|
||||
await creation(page)
|
||||
.getByRole('button', { name: dict['editor.annotations.create'] })
|
||||
.click()
|
||||
expect(await proposed(page)).toEqual(shown)
|
||||
await notice(page)
|
||||
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
|
||||
.click()
|
||||
|
||||
@@ -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