fix(editor): message line lifecycle, own row, sound no-shift check
Task 3 review, fix round 1. - The gesture message closes for good on any document or history change (store subscription): undo then redo no longer revives it. - Hover and focus hold only the message they were taken on: after « Défaire » the next message expires. - An accepted drop clears the strip's refusal hint again. - Controller ruling: the message has its own fixed row under the add buttons, column width; a refused gesture's full text also shows in the strip notice (red, aria-hidden copy of the row's alert). - expectNoShift: native requestAnimationFrame kept before page.clock (keepNativeFrames), every part box asserted non-null, message row measured; the e2e checks the message is not truncated. No assertion removed; the refused-drop unit test gains the strip copy.
This commit is contained in:
1 parent
1deb037fac
commit
7a45f1d885
9 files changed
+198
-49
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
cleanup,
|
||||
fireEvent,
|
||||
render,
|
||||
renderHook,
|
||||
screen,
|
||||
waitFor,
|
||||
within,
|
||||
@@ -14,6 +15,8 @@ import type { Annotation } from '@faunosteo/core-wasm/types'
|
||||
import AnnotationsTab from '@/components/editor/tabs/AnnotationsTab'
|
||||
import EditStrip from '@/components/editor/annotations/EditStrip'
|
||||
import { selectionLead } from '@/editor/annotations/stripLead'
|
||||
import { initialUi } from '@/editor/annotations/uiState'
|
||||
import { usePlacement } from '@/editor/annotations/usePlacement'
|
||||
import { fr } from '@/i18n/fr'
|
||||
import { AnnounceContext } from '@/editor/focusRequest'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
@@ -1822,6 +1825,73 @@ describe('the strip', () => {
|
||||
expect(alert).toHaveTextContent(/^Déplacement refusé : /)
|
||||
expect(alert.className).toContain('danger')
|
||||
expect(within(line()).queryByRole('button', { name: /Défaire/ })).toBeNull()
|
||||
// Its full text in the strip too (A6), shown but not announced a second time.
|
||||
const copy = within(notice())
|
||||
.getByText(/^Déplacement refusé : /)
|
||||
.closest('p')!
|
||||
expect(copy).toHaveAttribute('aria-hidden', 'true')
|
||||
expect(copy).not.toHaveAttribute('role')
|
||||
expect(copy.className).toContain('danger')
|
||||
})
|
||||
|
||||
it('the message sits on its own row under the add buttons, always mounted', async () => {
|
||||
await mount()
|
||||
const add = screen.getByRole('button', { name: 'Ajouter un point' })
|
||||
expect(line()).not.toContainElement(add)
|
||||
expect(line()).toHaveClass('h-11', 'overflow-hidden')
|
||||
expect(line()).toHaveAttribute('role', 'status')
|
||||
})
|
||||
|
||||
it('an undo then a redo never brings the message back', async () => {
|
||||
await mount()
|
||||
await selectFromList()
|
||||
drag(marker('anno-a'), [60, 40])
|
||||
expect(line()).toHaveTextContent('Point déplacé')
|
||||
act(() => void store.getState().undoStep())
|
||||
act(() => void store.getState().redoStep())
|
||||
expect(line()).not.toHaveTextContent('Point déplacé')
|
||||
})
|
||||
|
||||
it('a hold ends with its message: after « Défaire » the next message still expires', async () => {
|
||||
vi.useFakeTimers({ shouldAdvanceTime: true })
|
||||
try {
|
||||
await mount()
|
||||
await selectFromList()
|
||||
drag(marker('anno-a'), [60, 40])
|
||||
const message = within(line()).getByTestId('gesture-message')
|
||||
const undo = within(message).getByRole('button')
|
||||
fireEvent.pointerEnter(message, { pointerType: 'mouse' })
|
||||
act(() => undo.focus())
|
||||
fireEvent.click(undo)
|
||||
expect(line()).not.toHaveTextContent('Point déplacé')
|
||||
drag(marker('anno-a'), [70, 40])
|
||||
expect(line()).toHaveTextContent('Point déplacé')
|
||||
act(() => void vi.advanceTimersByTime(6_100))
|
||||
expect(line()).not.toHaveTextContent('Point déplacé')
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('a kept drop clears a refusal the strip still shows', async () => {
|
||||
await mount()
|
||||
const doc = store.getState().previewState!.document
|
||||
const dispatch = vi.fn()
|
||||
const { result } = renderHook(() =>
|
||||
usePlacement({
|
||||
ui: { ...initialUi, hint: 'Refusé' },
|
||||
dispatch,
|
||||
frame: null,
|
||||
doc,
|
||||
context: { t: (key) => key, locale: 'fr' },
|
||||
message: { show: vi.fn() },
|
||||
}),
|
||||
)
|
||||
act(() =>
|
||||
result.current.onDrop('anno-a', { type: 'circle', cx: 60, cy: 40, r: 5 }),
|
||||
)
|
||||
expect(geometryOf('anno-a')).toMatchObject({ cx: 60, cy: 40 })
|
||||
expect(dispatch).toHaveBeenCalledWith({ type: 'hint', hint: null })
|
||||
})
|
||||
|
||||
it('expires after 6 s; a mouse hover pauses it, a touch does not', async () => {
|
||||
|
||||
Reference in new issue
Block a user