fix(editor): free paths never reshaped on attach, category zone chosen explicitly
This commit is contained in:
1 parent
f1175bb3a1
commit
a69eba569b
13 files changed
+333
-117
No files matched your search
@@ -314,6 +314,77 @@ test.describe('editor geometry (adversarial)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('a free path outside the new frame blocks the attach, is never reshaped and survives a save', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
const seededPath =
|
||||
'M 300 300 l 40 0 C 350 320 380 360 400 400 q 20 -30 -40 -50 ' +
|
||||
'A 30 20 0 0 1 320 330 H 310 V 305 Z'
|
||||
const path = {
|
||||
...pointOf('out-path', 'main', { cx: 0, cy: 0, r: 1 }, 'Tracé libre'),
|
||||
kind: 'zone',
|
||||
geometry: { type: 'path', d: seededPath },
|
||||
}
|
||||
const point = pointOf(
|
||||
'out-point',
|
||||
'main',
|
||||
{ cx: 500, cy: 400, r: 20 },
|
||||
'Point hors cadre',
|
||||
)
|
||||
const actor = await editorActor('fr')
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
const seed = await seedDraft(actor, {
|
||||
drawing: null,
|
||||
shape: (document) => {
|
||||
standardShape(document)
|
||||
const views = document.views as { id: string }[]
|
||||
document.views = views.filter((view) => view.id === 'main')
|
||||
document.annotations = [point, path]
|
||||
},
|
||||
})
|
||||
await openEditor(page, dict, actor, seed.sheetId)
|
||||
await selectTab(page, dict, 'views')
|
||||
await page.getByTestId('view-main-file').setInputFiles({
|
||||
name: 'petit.svg',
|
||||
mimeType: 'image/svg+xml',
|
||||
buffer: Buffer.from(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">' +
|
||||
'<rect x="2" y="2" width="96" height="96" fill="#eee"/></svg>',
|
||||
),
|
||||
})
|
||||
const dialog = page.getByRole('dialog', {
|
||||
name: dict['editor.views.repair.title'],
|
||||
})
|
||||
await expect(dialog).toBeVisible()
|
||||
const row = dialog.getByTestId('repair-out-path')
|
||||
await expect(
|
||||
row.getByText(dict['editor.views.repair.path_blocked']),
|
||||
).toBeVisible()
|
||||
await expect(row.getByRole('button')).toHaveCount(0)
|
||||
await expect(
|
||||
dialog.getByRole('button', { name: dict['editor.views.repair.apply'] }),
|
||||
).toBeDisabled()
|
||||
await dialog
|
||||
.getByRole('button', { name: dict['editor.views.repair.cancel'] })
|
||||
.click()
|
||||
await expect(dialog).toBeHidden()
|
||||
|
||||
// An unrelated change is saved: the path is still the seeded one, byte for byte.
|
||||
await selectTab(page, dict, 'general')
|
||||
const nameFr = page.getByLabel(dict['editor.general.name_fr'], {
|
||||
exact: true,
|
||||
})
|
||||
await nameFr.fill('Fiche sans toucher au tracé')
|
||||
await nameFr.press('Tab')
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
const saved = await serverDocument<{
|
||||
annotations: { id: string; geometry: Record<string, unknown> }[]
|
||||
}>(seed.draftId)
|
||||
const kept = saved.annotations.find((a) => a.id === 'out-path')
|
||||
expect(kept?.geometry).toEqual({ type: 'path', d: seededPath })
|
||||
})
|
||||
|
||||
test('an unmeasured view: drawing tools and add buttons disabled, the hint shown', async ({
|
||||
page,
|
||||
requests,
|
||||
|
||||
@@ -119,6 +119,7 @@ async function createFindings(page: Page) {
|
||||
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()
|
||||
|
||||
@@ -153,6 +153,7 @@ test.describe('editor structures (A4)', () => {
|
||||
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')
|
||||
|
||||
Reference in new issue
Block a user