Search (citation, DOI, URL) with « Effacer la recherche » and Escape;
« Trier par » sheet order, citation (locale collator), citation count,
type (business order); every sort stable on stored order, display only:
document, stored order, ids and history unchanged (unit + e2e). Count
« {n} références » / « {n} sur {total} » counts matching references
only. « Monter » / « Descendre » only in sheet order without search
(A1). « Ajouter une référence » resets search and sort and appends a
draft tile in edit; a tile in edit stays pinned while sorted or
searched; tile state pruned of absent ids. Reset path ready for « Tout
afficher » (R2.4).
Gates: typecheck, lint, test:run (app 1452), build, e2e:ui 251;
e2e:shell 16 specs on db:sandbox (editor-equine never listed): 115
passed / 102 skipped / 2 failed: editor-structures (test-side, fixed,
rerun with editor-references 12 passed / 11 skipped) and admin.spec A0
« Target crashed » during axe on the rights screen (not R2: that
screen renders every grant, 1 282 accumulated e2e fixtures; reported as
an open risk); full-row guard: no pre-existing row changed in any table.
## R-24 (removed or rewritten assertions)
| file | old | new |
|---|---|---|
| editor-references-tab.test.tsx | `#tab-reference-new-citation` present on load | null until « Ajouter une référence » |
| same | no match text « Aucune référence ne correspond. » | notice « Aucune référence ne contient « zzz ». » |
| same | add: form always visible, add clears the search, `getByText('Nouvelle source')` | click « Ajouter une référence » first; new tile header open, focused, search empty, 4 tiles |
| same | « a refused add keeps the search » | REMOVED (P24: add resets the search at once); replaced by « draft opens with citation focused, refused add keeps the draft, no write » |
| editor-tabs-lists.test.tsx | add form directly | click « Ajouter une référence » before the form assertions (same assertions after) |
| editor-keep-alive.test.tsx | form survives tab round trip | same, after opening the draft |
| editor-no-loss.test.tsx | reference form keeps typed text | same, after opening the draft |
| e2e editor-shell.spec (2), editor-shell-crossing.spec, editor-structures.spec | fill `#tab-reference-new-*` directly; `getByText(citation)` visible | open the draft first; structures asserts the new header is focused |
| e2e editor-references.spec keyboard walk | focus search, Tab reaches header 0 | focus « Ajouter une référence » (search, sort, add precede the headers) |
Other readers of `editor.reference.add`/new ids: grep of src, tests, e2e incl. editor-equine found none left unlisted. editor-equine is not affected ("updated, not run": nothing to update).
## i18n (fr / en)
Added: `editor.references.add` Ajouter une référence / Add a reference; `add_help` Type et citation obligatoires. / Type and citation required.; `clear_search` Effacer la recherche / Clear the search; `sort_by` Trier par / Sort by; `sort.sheet|citation|count|type` Ordre de la fiche, Citation (A → Z), Nombre de citations, Type / Sheet order, Citation (A → Z), Number of citations, Type; `count_one|other` {count} référence(s) / reference(s); `count_of_one|other` {count} référence(s) sur {total} / {count} reference(s) of {total}; `reorder_hint` Pour réorganiser, affichez l'ordre de la fiche sans recherche. / To reorder, show the sheet order without a search.; `no_result` Aucune référence ne contient « {q} ». / No reference contains “{q}”.; `no_result_scope` La recherche porte sur la citation, le DOI et l'URL. / The search covers the citation, the DOI and the URL. (REVUE sentence split in two keys so the first half is bold).
Changed: none. Removed: none (`editor.references.no_match` kept, the panel's EmptyLine still uses it).
366 lines
12 KiB
TypeScript
366 lines
12 KiB
TypeScript
import { fr } from '@/i18n/fr'
|
|
import type { Locator, Page, TestInfo } from '@playwright/test'
|
|
import { expect, test } from '../support/browser'
|
|
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
|
import {
|
|
clientOf,
|
|
closeCitations,
|
|
copyKeyOf,
|
|
editorActor,
|
|
geometryField,
|
|
historyButton,
|
|
libraryRoot,
|
|
openEditor,
|
|
openCitations,
|
|
openTab,
|
|
openSection,
|
|
pickAnnotation,
|
|
place,
|
|
pointOf,
|
|
saveLine,
|
|
seedDraft,
|
|
selectTab,
|
|
shapeWith,
|
|
standardShape,
|
|
storedCopy,
|
|
UNSAVED_LINE,
|
|
} from '../support/editor'
|
|
|
|
// V1-2.6 U1 H (AC11, AC21): a width change across 1 024 px in a real browser. Every
|
|
// edit-only part keeps what was typed, nothing is editable or focused below the threshold,
|
|
// the unsaved work stays, dialogs that confirm an edit close, a drag in flight commits
|
|
// nothing. Queries go to the visible place or by role; hidden parts stay in the DOM.
|
|
|
|
const dict = fr
|
|
|
|
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
|
const active = (page: Page) => page.locator(':focus')
|
|
const dialogs = (page: Page) => page.locator('dialog[open]')
|
|
const NARROW = { width: 800, height: 900 }
|
|
const WIDE = { width: 1280, height: 900 }
|
|
|
|
const spareCategory = (document: Record<string, unknown>) => {
|
|
standardShape(document)
|
|
;(document.categories as unknown[]).push({
|
|
id: 'cat-spare',
|
|
name: { fr: 'Libre', en: 'Free' },
|
|
color: null,
|
|
})
|
|
}
|
|
|
|
async function open(page: Page, shape = shapeWith()) {
|
|
const actor = await editorActor('fr')
|
|
const seed = await seedDraft(actor, { shape })
|
|
await openEditor(page, dict, actor, seed.sheetId)
|
|
return { ...seed, actor }
|
|
}
|
|
|
|
async function commitName(page: Page, value: string) {
|
|
await selectTab(page, dict, 'general')
|
|
await page.locator('#general-name-fr').fill(value)
|
|
await page.locator('#general-name-fr').press('Enter')
|
|
}
|
|
|
|
/** The editor is read-only in this page: no save, no text field, no edit toolbar. */
|
|
async function expectReadOnly(page: Page) {
|
|
await expect(
|
|
page.getByRole('button', { name: dict['common.save'], exact: true }),
|
|
).toHaveCount(0)
|
|
await expect(page.getByRole('textbox')).toHaveCount(0)
|
|
await expect(
|
|
page.getByRole('toolbar', { name: dict['editor.annotations.tools'] }),
|
|
).toHaveCount(0)
|
|
for (const kind of ['undo', 'redo'] as const) {
|
|
await expect(historyButton(page, dict, kind)).toHaveAttribute(
|
|
'aria-disabled',
|
|
'true',
|
|
)
|
|
}
|
|
}
|
|
|
|
/** A real crossing: the dialogs are gone and nothing is left to animate before the checks. */
|
|
async function cross(page: Page, size: { width: number; height: number }) {
|
|
await page.setViewportSize(size)
|
|
await expect(dialogs(page)).toHaveCount(0)
|
|
}
|
|
|
|
/**
|
|
* Types in `field` with no blur, crosses below 1 024 px, checks the part left the page and
|
|
* the focus sits on a named tab, widens, and checks the typed value is back untouched.
|
|
*/
|
|
async function keepsTypedValue(
|
|
page: Page,
|
|
field: Locator,
|
|
addButton: string,
|
|
tab: string,
|
|
) {
|
|
await field.fill('Saisie')
|
|
await cross(page, NARROW)
|
|
await expect(field).toBeHidden()
|
|
await expect(
|
|
page.getByRole('button', { name: addButton, exact: true }),
|
|
).toHaveCount(0)
|
|
await expectReadOnly(page)
|
|
await expect(active(page)).toHaveAttribute('id', `editor-tab-${tab}`)
|
|
await cross(page, WIDE)
|
|
await expect(field).toBeVisible()
|
|
await expect(field).toHaveValue('Saisie')
|
|
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
|
|
}
|
|
|
|
test.describe('editor shell, width crossing (H)', () => {
|
|
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
|
test.beforeEach(async ({ context }, info) => {
|
|
test.skip(isPhone(info), 'the widths are set by the tests themselves') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
|
|
await routeToSandbox(context)
|
|
})
|
|
test.afterEach(async ({ context }) => {
|
|
await dropLateReplays(context)
|
|
})
|
|
|
|
test('the category, region and detail view forms keep their typed text', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await openSection(page, dict, 'categories')
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#category-new-fr'),
|
|
dict['editor.general.category_add'],
|
|
'annotations',
|
|
)
|
|
await openSection(page, dict, 'regions')
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#region-new-code'),
|
|
dict['editor.vertebra.add'],
|
|
'annotations',
|
|
)
|
|
await openSection(page, dict, 'views')
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#view-new-fr'),
|
|
dict['editor.views.add'],
|
|
'annotations',
|
|
)
|
|
})
|
|
|
|
test('the crop group editor keeps its typed numbers, its read-only twin has its own ids', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await openSection(page, dict, 'views')
|
|
await place(page, 'annotations.views')
|
|
.getByRole('button', { name: dict['editor.views.crop.toggle'] })
|
|
.first()
|
|
.click()
|
|
const field = page.locator('#view-detail-a-crop-min_x')
|
|
await field.fill('7x')
|
|
await cross(page, NARROW)
|
|
await expect(field).toBeHidden()
|
|
await expect(page.locator('#ro-view-detail-a-crop-min_x')).toBeVisible()
|
|
await cross(page, WIDE)
|
|
await expect(field).toHaveValue('7x')
|
|
const ids = await page.evaluate(() => {
|
|
const all = [...document.querySelectorAll('[id]')].map((e) => e.id)
|
|
return all.filter((id, i) => all.indexOf(id) !== i)
|
|
})
|
|
expect(ids).toEqual([])
|
|
})
|
|
|
|
test('the findings creation form and the submission note keep their typed text', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await selectTab(page, dict, 'findings')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.findings.add_zone'] })
|
|
.click()
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#finding-new-name-fr'),
|
|
dict['editor.findings.add_zone'],
|
|
'findings',
|
|
)
|
|
await selectTab(page, dict, 'verification')
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#verification-note'),
|
|
dict['editor.verification.submit'],
|
|
'verification',
|
|
)
|
|
})
|
|
|
|
test('the references form keeps its typed text, in the Références tab', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await openTab(page, dict, 'references')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.references.add'] })
|
|
.click()
|
|
await keepsTypedValue(
|
|
page,
|
|
page.locator('#tab-reference-new-citation'),
|
|
dict['editor.reference.add'],
|
|
'references',
|
|
)
|
|
await expect(libraryRoot(page).getByRole('searchbox')).toBeVisible()
|
|
})
|
|
|
|
test('the annotation edit body keeps its tool and its pending creation', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await selectTab(page, dict, 'annotations')
|
|
const zone = page.getByRole('button', {
|
|
name: dict['editor.annotations.tool.zone'],
|
|
exact: true,
|
|
})
|
|
await expect(zone).toBeEnabled()
|
|
await zone.click()
|
|
await page
|
|
.getByRole('button', { name: dict['editor.annotations.add.point'] })
|
|
.click()
|
|
const name = page.getByLabel(dict['editor.annotations.name_fr'])
|
|
await name.fill('Futur point')
|
|
await cross(page, NARROW)
|
|
await expect(name).toBeHidden()
|
|
await expect(zone).toHaveCount(0)
|
|
await expect(active(page)).toHaveAttribute('id', 'editor-tab-annotations')
|
|
await cross(page, WIDE)
|
|
await expect(name).toHaveValue('Futur point')
|
|
await expect(zone).toHaveAttribute('aria-pressed', 'true')
|
|
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
|
|
})
|
|
|
|
test('a section open: read-only below the threshold, unsaved work kept, edit back on widening', async ({
|
|
page,
|
|
}) => {
|
|
const { actor, draftId } = await open(page)
|
|
await commitName(page, 'Nom conservé')
|
|
await openSection(page, dict, 'categories')
|
|
await page.locator('#category-new-fr').fill('Brouillon')
|
|
await cross(page, NARROW)
|
|
await expectReadOnly(page)
|
|
await expect(place(page, 'annotations.categories')).toBeVisible()
|
|
await expect(saveLine(page)).toHaveText(
|
|
dict['editor.draft.status.unsaved_count_one'].replace('{count}', '1'),
|
|
)
|
|
expect(
|
|
await storedCopy(page, copyKeyOf(actor.account.id, draftId)),
|
|
).not.toBeNull()
|
|
await cross(page, WIDE)
|
|
await expect(
|
|
page.getByRole('button', { name: dict['common.save'], exact: true }),
|
|
).toBeEnabled()
|
|
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
|
|
'aria-disabled',
|
|
'false',
|
|
)
|
|
await expect(page.locator('#category-new-fr')).toHaveValue('Brouillon')
|
|
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
|
})
|
|
|
|
test('the citations panel open: read-only below the threshold, unsaved work kept, edit back on widening', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await commitName(page, 'Nom conservé')
|
|
await openCitations(page, dict, 'Constat A')
|
|
await cross(page, NARROW)
|
|
await expectReadOnly(page)
|
|
await expect(place(page, 'citations')).toBeVisible()
|
|
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
|
await cross(page, WIDE)
|
|
await expect(
|
|
page.getByRole('button', { name: dict['common.save'], exact: true }),
|
|
).toBeEnabled()
|
|
await closeCitations(page, dict)
|
|
})
|
|
|
|
test('text typed without a blur is unsaved after the crossing and the copy is written', async ({
|
|
page,
|
|
}) => {
|
|
const { actor, draftId } = await open(page)
|
|
await selectTab(page, dict, 'general')
|
|
await page.locator('#general-name-fr').fill('Sans quitter le champ')
|
|
await cross(page, NARROW)
|
|
await expect(saveLine(page)).toHaveText(
|
|
dict['editor.draft.status.unsaved_count_one'].replace('{count}', '1'),
|
|
)
|
|
await expect
|
|
.poll(() => storedCopy(page, copyKeyOf(actor.account.id, draftId)))
|
|
.not.toBeNull()
|
|
})
|
|
|
|
test('a focused drawing tool hands its focus to the shown tab on a crossing', async ({
|
|
page,
|
|
}) => {
|
|
await open(page)
|
|
await selectTab(page, dict, 'annotations')
|
|
const zone = page.getByRole('button', {
|
|
name: dict['editor.annotations.tool.zone'],
|
|
exact: true,
|
|
})
|
|
await expect(zone).toBeEnabled()
|
|
await zone.focus()
|
|
await cross(page, NARROW)
|
|
await expect(active(page)).toHaveAttribute('id', 'editor-tab-annotations')
|
|
})
|
|
|
|
test('a drag across the crossing commits nothing', async ({ page }) => {
|
|
await open(
|
|
page,
|
|
shapeWith(
|
|
pointOf('anno-free', 'main', { cx: 120, cy: 120, r: 6 }, 'Point libre'),
|
|
),
|
|
)
|
|
await selectTab(page, dict, 'annotations')
|
|
await pickAnnotation(page, dict, 'Point libre')
|
|
const cx = geometryField(page, dict, 'cx')
|
|
const before = await cx.inputValue()
|
|
const from = await clientOf(page, 120, 120)
|
|
const to = await clientOf(page, 200, 160)
|
|
await page.mouse.move(from.x, from.y)
|
|
await page.mouse.down()
|
|
await page.mouse.move(to.x, to.y, { steps: 6 })
|
|
await cross(page, NARROW)
|
|
await page.mouse.up()
|
|
await cross(page, WIDE)
|
|
await expect(geometryField(page, dict, 'cx')).toHaveValue(before)
|
|
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
|
|
await expect(historyButton(page, dict, 'undo')).toHaveAttribute(
|
|
'aria-disabled',
|
|
'true',
|
|
)
|
|
})
|
|
|
|
test('a delete confirmation and the discard confirmation close when the editor turns read-only', async ({
|
|
page,
|
|
}) => {
|
|
await open(page, spareCategory)
|
|
await openSection(page, dict, 'categories')
|
|
await page
|
|
.getByRole('listitem')
|
|
.filter({ has: page.locator('#category-cat-spare-name-fr') })
|
|
.getByRole('button', { name: dict['editor.action.delete'] })
|
|
.click()
|
|
await expect(dialogs(page)).toHaveCount(1)
|
|
await cross(page, NARROW)
|
|
await cross(page, WIDE)
|
|
await expect(dialogs(page)).toHaveCount(0)
|
|
await expect(page.locator('#category-cat-spare-name-fr')).toHaveCount(1)
|
|
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
|
|
|
|
await commitName(page, 'Nom à abandonner')
|
|
await page
|
|
.getByRole('button', { name: dict['editor.draft.discard'], exact: true })
|
|
.click()
|
|
await expect(dialogs(page)).toHaveCount(1)
|
|
await cross(page, NARROW)
|
|
await cross(page, WIDE)
|
|
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
|
})
|
|
})
|