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.
This commit is contained in:
1 parent
942d52a835
commit
0467885527
22 files changed
+327
-38
No files matched your search
@@ -252,6 +252,52 @@ describe('typed text and the press', () => {
|
||||
expect(geometry()).toMatchObject({ cx: 40 })
|
||||
})
|
||||
|
||||
async function refusedField() {
|
||||
const user = userEvent.setup()
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
const field = await selectAnnotation(user)
|
||||
await user.clear(field)
|
||||
return field
|
||||
}
|
||||
|
||||
/** A press as a touch sends it: down, up, the leave it fires, then the click. */
|
||||
function touchPress() {
|
||||
const init = { pointerType: 'touch' }
|
||||
fireEvent.pointerDown(undoButton(), init)
|
||||
fireEvent.pointerUp(undoButton(), init)
|
||||
fireEvent.pointerLeave(undoButton(), init)
|
||||
fireEvent.click(undoButton())
|
||||
}
|
||||
|
||||
it('a touch press keeps the refused field across pointer leave and click', async () => {
|
||||
const field = await refusedField()
|
||||
touchPress()
|
||||
expect(field).toHaveAttribute('aria-invalid', 'true')
|
||||
expect(field).toHaveFocus()
|
||||
expect(geometry()).toMatchObject({ cx: 40 })
|
||||
expect(store.getState().undo).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('a touch press cancelled by the browser forgets the field', async () => {
|
||||
const field = await refusedField()
|
||||
fireEvent.pointerDown(undoButton(), { pointerType: 'touch' })
|
||||
fireEvent.pointerCancel(undoButton(), { pointerType: 'touch' })
|
||||
fireEvent.click(undoButton())
|
||||
expect(field).not.toHaveFocus()
|
||||
expect(geometry()).toMatchObject({ cx: 50 })
|
||||
})
|
||||
|
||||
it('a mouse leaving the button forgets the field', async () => {
|
||||
const field = await refusedField()
|
||||
fireEvent.pointerDown(undoButton(), { pointerType: 'mouse' })
|
||||
fireEvent.pointerLeave(undoButton(), { pointerType: 'mouse' })
|
||||
fireEvent.click(undoButton())
|
||||
expect(field).not.toHaveFocus()
|
||||
expect(geometry()).toMatchObject({ cx: 50 })
|
||||
})
|
||||
|
||||
it('a keyboard activation after a refused blur commit skips the undo too', async () => {
|
||||
const user = userEvent.setup()
|
||||
mountDraft()
|
||||
@@ -443,6 +489,29 @@ describe('« Abandonner les modifications »', () => {
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the session\'s save in the save line, and the save line says it', async () => {
|
||||
const user = userEvent.setup()
|
||||
sb.saveSheetDraft.mockResolvedValue({ revision: 4 } as never)
|
||||
sb.getOfficialSheetAdmin.mockRejectedValue(new Error('offline'))
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
await user.click(screen.getByRole('button', { name: 'Enregistrer' }))
|
||||
const line = screen.getByTestId('save-line')
|
||||
await waitFor(() =>
|
||||
expect(line).toHaveTextContent(/^Enregistré · révision 4$/),
|
||||
)
|
||||
act(() => void commitMove(41))
|
||||
expect(line).toHaveTextContent(/^1 modification non enregistrée$/)
|
||||
const dialog = await open(user)
|
||||
await user.click(
|
||||
dialog.getByRole('button', { name: fr['editor.draft.discard_confirm'] }),
|
||||
)
|
||||
expect(store.getState().unsaved).toBe(false)
|
||||
expect(geometry()).toMatchObject({ cx: 40 })
|
||||
expect(line).toHaveTextContent(/^Enregistré · révision 4$/)
|
||||
})
|
||||
|
||||
it('does not mention a copy when none is stored', async () => {
|
||||
const user = userEvent.setup()
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
|
||||
Reference in new issue
Block a user