Board 23 / 24 / 27 tiles: closed (citation on two lines, type, « Citée
{n} fois » / « Non citée »), open (Type, DOI, URL as safe links, the
citers with « famille » badge and « Aller à »), edit (« Terminer » with a
leave guard re-committing every changed field; a refusal keeps edit
and focuses the field). A cited reference shows the deletion hint, an
uncited one keeps « Supprimer ». Read-only keeps DOI, URL, « Aller à ».
« Terminer » keeps focus in the field on press, so a refusal message
can no longer move the button under the pointer.
Gates: typecheck, lint, test:run (app 1419), build, e2e:ui 251;
e2e:shell 16 specs on db:sandbox (editor-equine never listed): 111
passed / 99 skipped / 3 failed in the new editor-references.spec (two
test bugs, one app bug), fixed and rerun: 5 passed / 4 skipped; full-row
guard: no pre-existing row changed in any table.
## R-24 (removed or rewritten assertions)
| file | old | new |
|---|---|---|
| editor-citations.test.ts | `citationCounts` counts 2/1/0, memoised, empty | `citersOf`: ordered citers (Cat, Node), family flag, trail from zone, key, memoised, empty |
| editor-references-tab.test.tsx | cards say « citée N fois » (ref-a 1, ref-c 0) | « Citée 2 fois » (fixture gains a node citing ref-a), « Citée 1 fois », « Non citée » |
| same | ids `#tab-reference-ref-a-citation` exist when closed | header id `#tab-reference-0-ref-a-header`; field ids only inside an open edit tile |
| same | ↑/↓ on every card | in open tiles only, absent under a search |
| same | Ctrl+Z on an always-visible field | open tile, Modifier, then same assertion on `#tab-reference-0-ref-a-citation` |
| same | « Aller à » focuses the card (`listitem` count 3, focus key) | tile opened (aria-expanded true), header focused, 3 tiles |
| same | add: `getByText('Nouvelle source')` | tile header named « Nouvelle source » |
| same | read-only: no Supprimer / add | same after opening every tile |
| editor-tabs-lists.test.tsx | edit on blur and arrows on always-open cards | open tile, Modifier, blur applies, Terminer, Monter on opened tile |
| same | cited reference deletion refused in a dialog listing citers | REMOVED: no Supprimer on a cited tile (hint asserted, citer listed); uncited delete kept. The dialog's blocked path stays covered by `DeleteDialog`'s own tests |
| same | read-only: no button at all | read-only: facts shown, no Modifier / Supprimer / Citation textbox (header buttons exist now) |
| editor-keep-alive.test.tsx:~330 | tab-click commit of `#tab-reference-ref-1-citation` | opens tile + Modifier first, id `#tab-reference-0-ref-1-citation` |
| editor-keep-alive.test.tsx:~350,367 | `#panel-reference-ref-1-citation` | `#panel-reference-0-ref-1-citation` |
| editor-references-panel.test.tsx | « citée 2 fois / 1 fois » | « Citée 2 fois / 1 fois » |
| same | `#panel-reference-ref-a-citation`; no `#tab-reference-ref-a-citation` | `#panel-reference-0-ref-a-citation`; no `[id^="tab-reference-"]` while the tab tiles are closed |
| same | ids unique, tab and panel field ids present | tab tile opened in edit first; `tab-reference-0-ref-a-citation` and `panel-reference-0-ref-a-citation` unique |
| e2e editor-structures.spec.ts:~88-110 | citation inputs count 3/1/2, « citée 0 fois » x2, « citée 1 fois », move via row buttons | tile headers count, « Non citée » x2, « Citée 1 fois », tile opened before Monter/Supprimer, `tiles.nth(1)` contains the moved text (saved-list assertion unchanged) |
## i18n (fr / en)
Changed (in place, P18): `editor.references.cited_one|other`: « citée {count} fois » -> « Citée {count} fois »; « cited {count} time(s) » -> « Cited {count} time(s) ».
Added: `editor.references.uncited` Non citée / Not cited; `citers_one|other` « Citée {count} fois, par : » / « Cited {count} time(s), by: »; `no_citers` « Aucun constat ni aucune famille ne cite cette référence. » / « No finding or family cites this reference. »; `family` famille / family; `go_to` Aller à / Go to; `edit` Modifier / Edit; `done` Terminer / Done; `edit_title` Modifier la référence / Edit the reference; `url_label` URL / URL; `none_doi` Aucun / None; `none_url` Aucune / None; `new_tab` (nouvel onglet) / (new tab) (sr-only); `delete_hint` (REVUE wording, fr and en).
Removed: none. R10 grep (src, tests, e2e incl. editor-equine) found no reader of the old lowercase wording left.
270 lines
9.2 KiB
TypeScript
270 lines
9.2 KiB
TypeScript
import { fr } from '@/i18n/fr'
|
|
import type { Locator, Page, TestInfo } from '@playwright/test'
|
|
import {
|
|
expect,
|
|
expectAccessible,
|
|
expectNoHorizontalOverflow,
|
|
test,
|
|
} from '../support/browser'
|
|
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
|
import {
|
|
editorActor,
|
|
libraryRoot,
|
|
openEditor,
|
|
openTab,
|
|
place,
|
|
seedDraft,
|
|
standardShape,
|
|
} 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.
|
|
|
|
const dict = fr
|
|
|
|
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
|
const DOI = '10.3389/fvets.2022.898096'
|
|
|
|
/** « Référence A » (cited by « Constat A ») plus one cited by a family and one uncited. */
|
|
function shape(document: Record<string, unknown>) {
|
|
standardShape(document)
|
|
document.references = [
|
|
{
|
|
id: 'ref-a',
|
|
type: 'book',
|
|
citation: 'Référence A',
|
|
url: null,
|
|
doi: null,
|
|
},
|
|
{
|
|
id: 'ref-doi',
|
|
type: 'journal',
|
|
citation:
|
|
'Long-term outcome of horses undergoing surgery, Front Vet Sci 2022',
|
|
url: `https://doi.org/${DOI}`,
|
|
doi: DOI,
|
|
},
|
|
{
|
|
id: 'ref-free',
|
|
type: 'web',
|
|
citation: 'Source libre',
|
|
url: null,
|
|
doi: null,
|
|
},
|
|
]
|
|
const zone = (document.finding_zones as { categories: unknown[] }[])[0]
|
|
const family = zone.categories[0] as { reference_ids: string[] }
|
|
family.reference_ids = ['ref-doi']
|
|
}
|
|
|
|
async function open(page: Page) {
|
|
const actor = await editorActor('fr')
|
|
const seed = await seedDraft(actor, { shape: shape })
|
|
await openEditor(page, dict, actor, seed.sheetId)
|
|
return { actor, seed }
|
|
}
|
|
|
|
const headers = (page: Page) =>
|
|
libraryRoot(page).locator('button[aria-controls][id$="-header"]')
|
|
/** The tile at a position of the seeded list (header ids stay put while it is in edit). */
|
|
const tileAt = (page: Page, position: number): Locator =>
|
|
headers(page).nth(position).locator('xpath=ancestor::li[1]')
|
|
const REF_DOI = 1
|
|
const REF_A = 0
|
|
const REF_FREE = 2
|
|
|
|
test.describe('reference tiles, edit mode', () => {
|
|
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
|
test.beforeEach(async ({ context }, info) => {
|
|
test.skip(
|
|
isPhone(info),
|
|
'editing needs >= 1 024 px; the phone twin is below',
|
|
) // floor-guard: allow C16 editing needs >= 1024 px; read-only twin in this file
|
|
await routeToSandbox(context)
|
|
})
|
|
test.afterEach(async ({ context }) => {
|
|
await dropLateReplays(context)
|
|
})
|
|
|
|
test('closed, open and edit tiles, accessible in each state', async ({
|
|
page,
|
|
requests,
|
|
}) => {
|
|
test.setTimeout(120_000)
|
|
const { actor } = await open(page)
|
|
requests.forbid(actor.account.email, actor.account.password)
|
|
await openTab(page, dict, 'references')
|
|
await expect(headers(page)).toHaveCount(3)
|
|
await expect(headers(page).first()).toHaveAttribute(
|
|
'aria-expanded',
|
|
'false',
|
|
)
|
|
await expect(
|
|
libraryRoot(page).getByText(dict['editor.references.uncited']),
|
|
).toHaveCount(1)
|
|
await expectNoHorizontalOverflow(page, 'the closed tiles')
|
|
await expectAccessible(page, 'the closed reference tiles')
|
|
|
|
// Open: facts as safe links, the citers, the hint on a cited reference.
|
|
await headers(page).nth(1).click()
|
|
const cited = tileAt(page, REF_DOI)
|
|
await expect(headers(page).nth(1)).toHaveAttribute('aria-expanded', 'true')
|
|
const doi = cited
|
|
.getByRole('link', { name: new RegExp(DOI.replace('.', '\\.')) })
|
|
.first()
|
|
await expect(doi).toHaveAttribute('href', `https://doi.org/${DOI}`)
|
|
await expect(doi).toHaveAttribute('target', '_blank')
|
|
await expect(doi).toHaveAttribute('rel', 'noopener noreferrer')
|
|
await expect(cited.getByText('Dysfonction A')).toBeVisible()
|
|
await expect(
|
|
cited.getByText(dict['editor.references.family'], { exact: true }),
|
|
).toBeVisible()
|
|
await expect(
|
|
cited.getByRole('button', { name: dict['editor.action.delete'] }),
|
|
).toHaveCount(0)
|
|
await expect(
|
|
cited.getByText(dict['editor.references.delete_hint']),
|
|
).toBeVisible()
|
|
await headers(page).nth(2).click()
|
|
await expect(
|
|
tileAt(page, REF_FREE).getByRole('button', {
|
|
name: dict['editor.action.delete'],
|
|
}),
|
|
).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()
|
|
await expect(
|
|
cited.getByText(dict['editor.references.edit_title']),
|
|
).toBeVisible()
|
|
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')
|
|
})
|
|
|
|
test('« Terminer » keeps the edit view while a field is refused', async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(120_000)
|
|
await open(page)
|
|
await openTab(page, dict, 'references')
|
|
await headers(page).nth(2).click()
|
|
const tile = tileAt(page, REF_FREE)
|
|
await tile
|
|
.getByRole('button', { name: dict['editor.references.edit'] })
|
|
.click()
|
|
const url = tile.getByLabel(dict['editor.reference.url'])
|
|
await url.fill('exemple.org')
|
|
await tile
|
|
.getByRole('button', { name: dict['editor.references.done'] })
|
|
.click()
|
|
await expect(url).toBeFocused()
|
|
await expect(
|
|
tile.getByRole('button', { name: dict['editor.references.done'] }),
|
|
).toBeVisible()
|
|
await url.fill('https://exemple.org/page')
|
|
await tile
|
|
.getByRole('button', { name: dict['editor.references.done'] })
|
|
.click()
|
|
await expect(tile.getByLabel(dict['editor.reference.url'])).toHaveCount(0)
|
|
await expect(
|
|
tile.getByRole('link', { name: /exemple\.org/ }),
|
|
).toHaveAttribute('href', 'https://exemple.org/page')
|
|
})
|
|
|
|
test('the tile headers are a keyboard walk: Tab between them, Enter and Space open', async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(120_000)
|
|
await open(page)
|
|
await openTab(page, dict, 'references')
|
|
await page
|
|
.getByRole('searchbox', { name: dict['editor.references.search'] })
|
|
.focus()
|
|
for (let at = 0; at < 3; at++) {
|
|
await page.keyboard.press('Tab')
|
|
await expect(headers(page).nth(at)).toBeFocused()
|
|
}
|
|
// Focus is on the third header: one Shift+Tab back reaches the second.
|
|
await page.keyboard.press('Shift+Tab')
|
|
await expect(headers(page).nth(1)).toBeFocused()
|
|
await page.keyboard.press('Enter')
|
|
await expect(headers(page).nth(1)).toHaveAttribute('aria-expanded', 'true')
|
|
// Open, the tile's own content is the next tab stop: its DOI link, then back.
|
|
await page.keyboard.press('Tab')
|
|
await expect(tileAt(page, REF_DOI).getByRole('link').first()).toBeFocused()
|
|
await page.keyboard.press('Shift+Tab')
|
|
await expect(headers(page).nth(1)).toBeFocused()
|
|
await page.keyboard.press('Space')
|
|
await expect(headers(page).nth(1)).toHaveAttribute('aria-expanded', 'false')
|
|
})
|
|
|
|
test('« Aller à » on a citer opens the Constats tab on it', async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(120_000)
|
|
await open(page)
|
|
await openTab(page, dict, 'references')
|
|
await headers(page).nth(0).click()
|
|
await tileAt(page, REF_A)
|
|
.getByRole('button', { name: dict['editor.references.go_to'] })
|
|
.click()
|
|
await expect(place(page, 'findings')).toBeVisible()
|
|
await expect(place(page, 'findings').locator(':focus')).toHaveCount(1)
|
|
})
|
|
})
|
|
|
|
test.describe('reference tiles, read-only at 375 px', () => {
|
|
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
|
test.beforeEach(async ({ context }, info) => {
|
|
test.skip(!isPhone(info), 'the read-only twin runs at 375 px only')
|
|
await routeToSandbox(context)
|
|
})
|
|
test.afterEach(async ({ context }) => {
|
|
await dropLateReplays(context)
|
|
})
|
|
|
|
test('« Plus » lists Références; tiles keep DOI, URL and « Aller à », no edit control @phone', async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(120_000)
|
|
await open(page)
|
|
await openTab(page, dict, 'references')
|
|
await expect(headers(page)).toHaveCount(3)
|
|
const box = await headers(page).first().boundingBox()
|
|
expect(box?.height ?? 0).toBeGreaterThanOrEqual(44)
|
|
await expectNoHorizontalOverflow(page, 'the closed tiles at 375 px')
|
|
await expectAccessible(page, 'the closed tiles at 375 px')
|
|
await headers(page).nth(1).click()
|
|
const cited = tileAt(page, REF_DOI)
|
|
await expect(cited.getByRole('link').first()).toHaveAttribute(
|
|
'target',
|
|
'_blank',
|
|
)
|
|
const goTo = cited.getByRole('button', {
|
|
name: dict['editor.references.go_to'],
|
|
})
|
|
expect((await goTo.boundingBox())?.height ?? 0).toBeGreaterThanOrEqual(44)
|
|
for (const name of [
|
|
dict['editor.references.edit'],
|
|
dict['editor.action.delete'],
|
|
dict['editor.action.move_up'],
|
|
]) {
|
|
await expect(libraryRoot(page).getByRole('button', { name })).toHaveCount(
|
|
0,
|
|
)
|
|
}
|
|
await expectNoHorizontalOverflow(page, 'an open tile at 375 px')
|
|
await expectAccessible(page, 'an open tile at 375 px')
|
|
})
|
|
})
|