Files
faunosteo/apps/app/tests/unit/e2e-save-line-text.test.ts
T
bchanot 0467885527 fix(editor): final review fixes (touch undo guard, focus, save line)
Important 1: a touch press fires pointer leave between up and click; only a
mouse leave (or a pointer cancel) forgets the refused field, so Annuler no
longer undoes an unrelated change. Important 2: the LAN spec reads the
revision before the attach, through shownRevision, which throws instead of NaN
(spec stays not run). Minor 1: refocusIfHidden refocuses a still shown element
the commit blurred (references search on a 1 024 px crossing). Minor 2:
discardChanges keeps lastSave (reload path still drops it). Minor 3: the
overview filter term lives in UiState / the read-only twin, not the card.
Minor 4: categories section drops its inner h3 and the unused
editor.general.categories keys. AC8: badge test.

Assertions rewritten or added (R-24):
- editor-tabs-general « Général no longer holds the categories editor »:
  queryByText of the deleted heading (now vacuous) -> queryByLabelText of the
  category name fields.
- editor-focus-request « Annotations: selects the annotation »: findAllByText
  /anno-b|Sélection/ -> the properties panel holds Centre x = 20 (anno-b) and
  owns the focused heading.
- editor-shell-layout panel walk: added after.at(-1) === 'side'.
- editor-recovery title « Annuler les modifications » -> « Abandonner ».
- new: touch/cancel/mouse press, references search crossing, discard keeps
  lastSave, filter kept, one categories heading, badge 1/2/0, shownRevision.
2026-11-09 12:19:32 +01:00

40 lines
1.3 KiB
TypeScript

/** The LAN spec's revision reading, run on the strings the save line really shows. */
import { describe, expect, it } from 'vitest'
import { fr } from '@/i18n/fr'
import { shownRevision } from '../../e2e/support/saveLineText'
const line = (key: keyof typeof fr, values: Record<string, string> = {}) =>
Object.entries(values).reduce(
(text, [name, value]) => text.replace(`{${name}}`, value),
fr[key],
)
describe('shownRevision', () => {
it('reads the revision of the « Révision n » line', () => {
expect(
shownRevision(line('editor.draft.status.revision', { revision: '7' })),
).toBe(7)
})
it('reads it from both saved forms', () => {
const saved = line('editor.draft.status.saved', { revision: '8' })
const savedAt = line('editor.draft.status.saved_at', {
revision: '12',
time: '14:02',
})
expect([shownRevision(saved), shownRevision(savedAt)]).toEqual([8, 12])
})
it('throws on the forms that carry none, never answers NaN', () => {
const texts = [
fr['editor.draft.status.unsaved'],
line('editor.draft.status.unsaved_count_one', { count: '1' }),
fr['editor.draft.status.saving'],
'',
]
for (const text of texts) {
expect(() => shownRevision(text)).toThrow('shows no revision')
}
})
})