feat(editor): a reference made in the citations draft saves with it
This commit is contained in:
1 parent
8c3fcca0b9
commit
70eb2fcbb4
15 files changed
+671
-162
No files matched your search
@@ -585,17 +585,16 @@ test.describe('references dialog, edit mode', () => {
|
||||
expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b'])
|
||||
})
|
||||
|
||||
test('« Nouvelle référence » is created over the dialog and cited by the save', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
const { seed } = await open(page)
|
||||
await editCitations(page)
|
||||
/** « Nouvelle référence » over the edit mode, typed, then « Ajouter la référence ». */
|
||||
async function createPending(page: Page) {
|
||||
const create = inDialog(page, dict['editor.citations.new_reference'])
|
||||
await create.click()
|
||||
const form = referenceDialog(page)
|
||||
await expect(form).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(3)
|
||||
await expect(
|
||||
form.getByRole('heading', { name: dict['editor.reference.new'] }),
|
||||
).toBeVisible()
|
||||
await form.locator('#reference-form-type').selectOption('manual')
|
||||
await form.locator('#reference-form-citation').fill('Source nouvelle')
|
||||
await form
|
||||
@@ -605,14 +604,54 @@ test.describe('references dialog, edit mode', () => {
|
||||
await expect(create).toBeFocused()
|
||||
await expect(draftRows(page)).toHaveCount(4)
|
||||
await expect(draftRows(page).last()).toContainText('Source nouvelle')
|
||||
await expect(draftRows(page).last()).toContainText(
|
||||
dict['editor.citations.pending'],
|
||||
)
|
||||
await expect(citationsDialog(page).getByRole('status')).toContainText(
|
||||
'Source nouvelle',
|
||||
)
|
||||
}
|
||||
|
||||
test('« Nouvelle référence » then « Abandonner »: the library is unchanged', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await editCitations(page)
|
||||
await createPending(page)
|
||||
await inDialog(page, dict['common.cancel']).click()
|
||||
await inDialog(page, dict['editor.findings.discard']).click()
|
||||
await expect(editButton(page)).toBeFocused()
|
||||
await closeCitations(page, dict)
|
||||
await closeFinding(page, dict)
|
||||
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
)
|
||||
await expect(
|
||||
page.locator('p.sr-only[aria-live="polite"]'),
|
||||
).not.toContainText('sera enregistrée')
|
||||
await openTab(page, dict, 'references')
|
||||
await expect(libraryRoot(page)).toContainText('Source libre')
|
||||
await expect(libraryRoot(page)).not.toContainText('Source nouvelle')
|
||||
})
|
||||
|
||||
test('« Nouvelle référence » then « Enregistrer »: one « Défaire » removes both', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
const { seed } = await open(page)
|
||||
await editCitations(page)
|
||||
await createPending(page)
|
||||
await inDialog(page, dict['editor.findings.save']).click()
|
||||
await expect(editButton(page)).toBeFocused()
|
||||
await closeCitations(page, dict)
|
||||
await closeFinding(page, dict)
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
const saved = await serverDocument<Record<string, unknown>>(seed.draftId)
|
||||
const refs = saved.references as { id: string; citation: string }[]
|
||||
const added = refs.find((ref) => ref.citation === 'Source nouvelle')
|
||||
let saved = await serverDocument<Record<string, unknown>>(seed.draftId)
|
||||
const added = (saved.references as { id: string; citation: string }[]).find(
|
||||
(ref) => ref.citation === 'Source nouvelle',
|
||||
)
|
||||
expect(added).toBeDefined()
|
||||
expect(nodeOf(saved).reference_ids).toEqual([
|
||||
'ref-a',
|
||||
@@ -620,6 +659,16 @@ test.describe('references dialog, edit mode', () => {
|
||||
'ref-c',
|
||||
added!.id,
|
||||
])
|
||||
const undo = historyButton(page, dict, 'undo')
|
||||
await undo.click()
|
||||
await expect(undo).toHaveAttribute('aria-disabled', 'true')
|
||||
await saveDraft(page, dict, seed.revision + 2)
|
||||
saved = await serverDocument<Record<string, unknown>>(seed.draftId)
|
||||
const citations = (saved.references as { citation: string }[]).map(
|
||||
(ref) => ref.citation,
|
||||
)
|
||||
expect(citations).not.toContain('Source nouvelle')
|
||||
expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b', 'ref-c'])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user