fix(editor): repair dialog limits, pending drafts block apply, dialog wording

This commit is contained in:
bchanot committed 2026-11-04 20:17:51 +01:00
1 parent 3776a33b79
commit 9c21fd3f86
8 files changed
+197 -52

No files matched your search

@@ -391,3 +391,54 @@ describe('the repair dialog', () => {
expect(annotation('anno-p').geometry).toMatchObject({ type: 'polygon' })
})
})
describe('the repair dialog (fix round 1)', () => {
it('disables « Attacher et appliquer » while a group holds an unapplied draft', async () => {
const { user, dialog } = await pickAndOpenDialog()
const apply = within(dialog).getByRole('button', {
name: t('editor.views.repair.apply'),
})
expect(apply).toBeEnabled()
const cx = within(
within(dialog).getByTestId('repair-anno-a'),
).getByLabelText('Centre x')
await user.clear(cx)
await user.keyboard('{Enter}')
expect(apply).toBeDisabled()
await user.type(cx, '60{Enter}')
expect(apply).toBeEnabled()
})
it('headings sit under the dialog title as h3', async () => {
const { dialog } = await pickAndOpenDialog()
expect(within(dialog).getAllByRole('heading', { level: 3 }).length).toBe(2)
})
it('words a refusal for the dialog, never the locked Annotations tab', async () => {
await openReady({ text: unmeasuredText() })
await holdNewDrawing()
const step = attachToView('view-main', NEW_ASSET)
if (step.ok || step.error.code !== 'repair') throw new Error('no offer')
const { offer } = step.error
const context = { t, locale: 'fr' as const }
const refused = (reason: string) => ({
ok: false as const,
reason: 'refused' as const,
refusal: { ...offer.refusal, reason: reason as never },
})
const { refusedResult } = await import('@/editor/repair')
const words = [
'newly_invalid',
'view_unmeasured',
'changed_unmeasured',
].map((reason) => {
const result = refusedResult(refused(reason), context)
return result.ok ? '' : (result.general ?? '')
})
for (const word of words) {
expect(word).not.toBe('')
expect(word).not.toMatch(/onglet|Annotations|Vues/)
}
expect(words[0]).toMatch(/anno-a|N/)
})
})