test(editor): reference dialog, filter and the owner journey, specs follow the dialog
This commit is contained in:
1 parent
7a64daf251
commit
8b42816270
20 files changed
+1546
-1171
No files matched your search
@@ -9,22 +9,27 @@ import {
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
editorActor,
|
||||
expectNoDialog,
|
||||
historyButton,
|
||||
libraryRoot,
|
||||
openEditor,
|
||||
openTab,
|
||||
place,
|
||||
referenceDialog,
|
||||
referenceSettled,
|
||||
saveDraft,
|
||||
seedDraft,
|
||||
serverDocument,
|
||||
serverRevision,
|
||||
standardShape,
|
||||
startReference,
|
||||
} from '../support/editor'
|
||||
|
||||
// V1-2.6 R2.2: the collapsible reference tiles of the Références tab (boards 23, 24, 27):
|
||||
// closed, open and edit states with axe on each, the keyboard walk through the tile
|
||||
// headers, the leave guard of the edit view, and the read-only twin at 375 px. The spec
|
||||
// seeds its own sheet and never touches another.
|
||||
// V1-2.6 R2.2 and R2F-5: the collapsible reference tiles of the Références tab (boards 23,
|
||||
// 24, 27): closed and open states with axe on each, the reference dialog (« Modifier »,
|
||||
// « Ajouter ») with axe, the keyboard walk through the tile headers, the dialog's draft
|
||||
// and its read-only flip, and the read-only twin at 375 px. The spec seeds its own sheet
|
||||
// and never touches another.
|
||||
|
||||
const dict = fr
|
||||
|
||||
@@ -79,7 +84,7 @@ const REF_DOI = 1
|
||||
const REF_A = 0
|
||||
const REF_FREE = 2
|
||||
|
||||
test.describe('reference tiles, edit mode', () => {
|
||||
test.describe('reference tiles and the reference dialog', () => {
|
||||
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||||
test.beforeEach(async ({ context }, info) => {
|
||||
test.skip(
|
||||
@@ -92,7 +97,7 @@ test.describe('reference tiles, edit mode', () => {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test('closed, open and edit tiles, accessible in each state', async ({
|
||||
test('closed and open tiles, then the reference dialog, accessible in each state', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -139,23 +144,30 @@ test.describe('reference tiles, edit mode', () => {
|
||||
).toBeVisible()
|
||||
await expectAccessible(page, 'the open reference tiles')
|
||||
|
||||
// Edit: the title, the focused citation, « Terminer » only.
|
||||
await cited
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
// « Modifier » opens the dialog: named, over the page, accessible; the tile has no field.
|
||||
const modify = cited.getByRole('button', {
|
||||
name: dict['editor.references.edit'],
|
||||
})
|
||||
await modify.click()
|
||||
const form = referenceDialog(page)
|
||||
await expect(form).toBeVisible()
|
||||
await expect(
|
||||
cited.getByText(dict['editor.references.edit_title']),
|
||||
form.getByRole('heading', { name: dict['editor.references.edit_title'] }),
|
||||
).toBeVisible()
|
||||
await expect(form.locator(':focus')).toHaveCount(1)
|
||||
await expect(
|
||||
cited.getByLabel(dict['editor.reference.citation']),
|
||||
).toBeFocused()
|
||||
await expect(
|
||||
cited.getByRole('button', { name: dict['editor.action.move_up'] }),
|
||||
).toHaveCount(0)
|
||||
await expectAccessible(page, 'a reference tile in edit')
|
||||
await expectAccessible(page, 'the reference dialog')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.cancel'] })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
await referenceSettled(page)
|
||||
await expect(modify).toBeFocused()
|
||||
})
|
||||
|
||||
test('« Terminer » keeps the edit view while a field is refused', async ({
|
||||
test('« Enregistrer » refuses a bad address on its field, then saves one command', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000)
|
||||
@@ -166,29 +178,26 @@ test.describe('reference tiles, edit mode', () => {
|
||||
await tile
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
const url = tile.getByLabel(dict['editor.reference.url'])
|
||||
const form = referenceDialog(page)
|
||||
const url = form.getByLabel(dict['editor.reference.url'])
|
||||
await url.fill('exemple.org')
|
||||
await tile
|
||||
.getByRole('button', {
|
||||
name: dict['editor.references.done'],
|
||||
exact: true,
|
||||
})
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.save'] })
|
||||
.click()
|
||||
await expect(url).toBeFocused()
|
||||
await expect(
|
||||
tile.getByRole('button', {
|
||||
name: dict['editor.references.done'],
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible()
|
||||
await expect(url).toHaveAccessibleDescription(
|
||||
dict['editor.reference.url_invalid'],
|
||||
)
|
||||
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
)
|
||||
await url.fill('https://exemple.org/page')
|
||||
await tile
|
||||
.getByRole('button', {
|
||||
name: dict['editor.references.done'],
|
||||
exact: true,
|
||||
})
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.save'] })
|
||||
.click()
|
||||
await expect(tile.getByLabel(dict['editor.reference.url'])).toHaveCount(0)
|
||||
await expectNoDialog(page)
|
||||
await referenceSettled(page)
|
||||
await expect(
|
||||
tile.getByRole('link', { name: /exemple\.org/ }),
|
||||
).toHaveAttribute('href', 'https://exemple.org/page')
|
||||
@@ -363,7 +372,7 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
expect(await serverRevision(seed.draftId)).toBe(revision)
|
||||
})
|
||||
|
||||
test('add a reference, save it, then delete an uncited one', async ({
|
||||
test('add a reference: the list stays, a notice offers « Afficher »; then delete an uncited one', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -374,28 +383,36 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
const bar = toolbar(page)
|
||||
await bar.sort.selectOption('count')
|
||||
await bar.search.fill('alpha')
|
||||
await libraryRoot(page)
|
||||
.getByRole('button', { name: dict['editor.references.add'] })
|
||||
.click()
|
||||
await expect(bar.search).toHaveValue('')
|
||||
await expect(bar.sort).toHaveValue('sheet')
|
||||
const citation = libraryRoot(page).getByLabel(
|
||||
dict['editor.reference.citation'],
|
||||
)
|
||||
await expect(citation).toBeFocused()
|
||||
// The focus scrolled the toolbar under the sticky header: axe judges what is covered.
|
||||
await libraryRoot(page).getByRole('searchbox').scrollIntoViewIfNeeded()
|
||||
await expectAccessible(page, 'the draft tile')
|
||||
await libraryRoot(page)
|
||||
.getByLabel(dict['editor.reference.type'])
|
||||
.selectOption('manual')
|
||||
await citation.fill('Nouvelle source')
|
||||
await libraryRoot(page)
|
||||
await startReference(page, dict)
|
||||
// The dialog is a layer over the page: the search and the sort are untouched.
|
||||
await expect(bar.search).toHaveValue('alpha')
|
||||
await expect(bar.sort).toHaveValue('count')
|
||||
const form = referenceDialog(page)
|
||||
await expectAccessible(page, 'the creation dialog')
|
||||
await form.locator('#reference-form-type').selectOption('manual')
|
||||
await form.locator('#reference-form-citation').fill('Nouvelle source')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.reference.add'] })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
await referenceSettled(page)
|
||||
await expect(headers(page)).toHaveCount(1)
|
||||
const notice = libraryRoot(page).getByText(
|
||||
dict['editor.references.added'].replace('{citation}', 'Nouvelle source'),
|
||||
)
|
||||
await expect(notice).toBeVisible()
|
||||
await expect(
|
||||
libraryRoot(page).getByRole('button', {
|
||||
name: dict['editor.references.add'],
|
||||
}),
|
||||
).toBeFocused()
|
||||
await libraryRoot(page)
|
||||
.getByRole('button', { name: dict['editor.references.added_show'] })
|
||||
.click()
|
||||
await expect(notice).toHaveCount(0)
|
||||
await expect(bar.search).toHaveValue('')
|
||||
await expect(headers(page)).toHaveCount(5)
|
||||
const added = headers(page).last()
|
||||
await expect(added).toContainText('Nouvelle source')
|
||||
const added = headers(page).filter({ hasText: 'Nouvelle source' })
|
||||
await expect(added).toHaveAttribute('aria-expanded', 'true')
|
||||
await expect(added).toBeFocused()
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
@@ -408,6 +425,7 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
])
|
||||
|
||||
// Delete an uncited reference (Étude): the dialog confirms, the tile goes.
|
||||
await bar.sort.selectOption('sheet')
|
||||
await headers(page).nth(3).click()
|
||||
await tileAt(page, 3)
|
||||
.getByRole('button', { name: dict['editor.action.delete'] })
|
||||
@@ -420,7 +438,7 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
await expect(libraryRoot(page).getByText('Étude')).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("« Annuler l'ajout » and Escape drop the draft and write nothing", async ({
|
||||
test('« Annuler » and Escape ask before they drop a typed draft, and write nothing', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -434,61 +452,41 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
})
|
||||
const count = await headers(page).count()
|
||||
const states = async () => [
|
||||
await historyButton(page, dict, 'undo').isEnabled(),
|
||||
await historyButton(page, dict, 'redo').isEnabled(),
|
||||
await historyButton(page, dict, 'undo').getAttribute('aria-disabled'),
|
||||
await historyButton(page, dict, 'redo').getAttribute('aria-disabled'),
|
||||
]
|
||||
const before = await states()
|
||||
const draft = root.getByRole('region', {
|
||||
name: dict['editor.reference.new'],
|
||||
})
|
||||
const type = root.getByLabel(dict['editor.reference.type'])
|
||||
await add.click()
|
||||
await type.selectOption('manual')
|
||||
await root.getByLabel(dict['editor.reference.citation']).fill('Brouillon')
|
||||
await root
|
||||
.getByRole('button', { name: dict['editor.references.add_cancel'] })
|
||||
await startReference(page, dict)
|
||||
const form = referenceDialog(page)
|
||||
await form.locator('#reference-form-type').selectOption('manual')
|
||||
await form.locator('#reference-form-citation').fill('Brouillon')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.cancel'] })
|
||||
.click()
|
||||
await expect(draft).toHaveCount(0)
|
||||
await expect(headers(page)).toHaveCount(count)
|
||||
await expect(add).toBeFocused()
|
||||
expect(await states()).toEqual(before)
|
||||
// A typed draft, then Escape on the type select (not a text target): it cancels.
|
||||
await add.click()
|
||||
await root.getByLabel(dict['editor.reference.citation']).fill('Brouillon')
|
||||
await type.focus()
|
||||
await expect(
|
||||
form.getByText(dict['editor.findings.discard_ask']),
|
||||
).toBeVisible()
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.keep_typing'] })
|
||||
.click()
|
||||
await expect(form.locator('#reference-form-citation')).toHaveValue(
|
||||
'Brouillon',
|
||||
)
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(draft).toHaveCount(0)
|
||||
await expect(
|
||||
form.getByText(dict['editor.findings.discard_ask']),
|
||||
).toBeVisible()
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.discard'] })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
await referenceSettled(page)
|
||||
await expect(headers(page)).toHaveCount(count)
|
||||
await expect(add).toBeFocused()
|
||||
expect(await states()).toEqual(before)
|
||||
})
|
||||
|
||||
test('a tile in edit keeps its place under a sort and under a search', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
const { actor } = await open(page, sortShape)
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
await openTab(page, dict, 'references')
|
||||
const bar = toolbar(page)
|
||||
await bar.sort.selectOption('citation')
|
||||
await headers(page).nth(3).click()
|
||||
await tileAt(page, 3)
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
await bar.sort.selectOption('count')
|
||||
await expect(
|
||||
tileAt(page, 3).getByLabel(dict['editor.reference.citation']),
|
||||
).toBeVisible()
|
||||
await bar.search.fill('alpha')
|
||||
await expect(headers(page)).toHaveCount(2)
|
||||
await expect(
|
||||
libraryRoot(page).getByLabel(dict['editor.reference.citation']),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('a tile edited out of the search stays after « Terminer », with its line, until the next search', async ({
|
||||
test('a tile edited out of the search stays after « Enregistrer », with its line, until the next search', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -505,14 +503,12 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
await tile
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
const citation = tile.getByLabel(dict['editor.reference.citation'])
|
||||
await citation.fill('Autre titre')
|
||||
await tile
|
||||
.getByRole('button', {
|
||||
name: dict['editor.references.done'],
|
||||
exact: true,
|
||||
})
|
||||
const form = referenceDialog(page)
|
||||
await form.getByLabel(dict['editor.reference.citation']).fill('Autre titre')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.save'] })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
await expect(
|
||||
tile.getByText(dict['editor.references.outside_search']),
|
||||
).toBeVisible()
|
||||
@@ -523,42 +519,45 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
await expect(headers(page)).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('a refused draft is never dropped silently by a read-only flip', async ({
|
||||
test('a draft is never dropped by a read-only flip: the dialog keeps it, read-only, with its notice', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openTab(page, dict, 'references')
|
||||
const bar = toolbar(page)
|
||||
await headers(page).nth(REF_DOI).click()
|
||||
const tile = libraryRoot(page)
|
||||
.locator('button[id$="-ref-doi-header"]')
|
||||
.locator('xpath=ancestor::li[1]')
|
||||
await tile
|
||||
await tileAt(page, REF_DOI)
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
await bar.search.fill('libre')
|
||||
const url = tile.getByLabel(dict['editor.reference.url'])
|
||||
const form = referenceDialog(page)
|
||||
const url = form.getByLabel(dict['editor.reference.url'])
|
||||
await url.fill('exemple.org')
|
||||
const note = dict['editor.references.draft_dropped'].replace(
|
||||
'{field}',
|
||||
dict['editor.reference.url'],
|
||||
)
|
||||
const size = page.viewportSize() ?? { width: 1280, height: 900 }
|
||||
await page.setViewportSize({ width: 800, height: size.height })
|
||||
await expect(tile.getByText(note)).toBeVisible()
|
||||
await expect(page.locator('p.sr-only[aria-live="polite"]')).toHaveText(note)
|
||||
await expect(url).toHaveCount(0)
|
||||
await expect(form).toBeVisible()
|
||||
await expect(url).toHaveAttribute('readonly', '')
|
||||
await expect(url).toHaveValue('exemple.org')
|
||||
await expect(
|
||||
form.getByText(dict['editor.findings.flip_narrow']),
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
form.getByRole('button', { name: dict['editor.findings.save'] }),
|
||||
).toBeDisabled()
|
||||
await page.setViewportSize(size)
|
||||
await expect(tile.getByText(note)).toBeVisible()
|
||||
await expect(url).toHaveValue(`https://doi.org/${DOI}`)
|
||||
await tile
|
||||
.getByRole('button', {
|
||||
name: dict['editor.references.done'],
|
||||
exact: true,
|
||||
})
|
||||
await expect(url).not.toHaveAttribute('readonly', '')
|
||||
await expect(url).toHaveValue('exemple.org')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.cancel'] })
|
||||
.click()
|
||||
await expect(tile.getByText(note)).toHaveCount(0)
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.discard'] })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
await expect(
|
||||
tileAt(page, REF_DOI)
|
||||
.getByRole('link', { name: new RegExp(DOI) })
|
||||
.first(),
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user