test(app): D6b link, listener cleanup and pen cases; useEmptyTap within limits (R1, D6b)
This commit is contained in:
1 parent
bbdfd27311
commit
a1ee194725
2 files changed
+144
-89
No files matched your search
@@ -1207,6 +1207,61 @@ describe('a tap on the drawing (D6b)', () => {
|
||||
expect(announce).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('selects a link (detail trigger) through the click', async () => {
|
||||
const view = insert(drawnText(), {
|
||||
kind: 'view',
|
||||
value: {
|
||||
kind: 'detail',
|
||||
id: 'view-det',
|
||||
name: { fr: 'Tête', en: 'Head' },
|
||||
svg_asset_id: null,
|
||||
view_box: { min_x: 10, min_y: 10, width: 80, height: 80 },
|
||||
parent_view_id: 'view-main',
|
||||
},
|
||||
})
|
||||
const link = {
|
||||
id: 'link-a',
|
||||
view_id: 'view-main',
|
||||
category_id: 'cat-a',
|
||||
laterality: 'unpaired',
|
||||
geometry: { type: 'circle', cx: 90, cy: 90, r: 3 },
|
||||
review_status: 'to_confirm',
|
||||
color: null,
|
||||
kind: 'detail_trigger',
|
||||
name: null,
|
||||
opens_view_id: 'view-det',
|
||||
} as Annotation
|
||||
await mountSpy({ text: insert(view, { kind: 'annotation', value: link }) })
|
||||
tap(marker('link-a'))
|
||||
expect(screen.getByTestId('annotation-properties')).toBeInTheDocument()
|
||||
expect(announce).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('removes the document listener when the canvas unmounts mid-press', async () => {
|
||||
await selected()
|
||||
const spy = vi.spyOn(document, 'removeEventListener')
|
||||
fireEvent.pointerDown(rect(), { ...init(), clientX: 10, clientY: 10 })
|
||||
cleanup()
|
||||
expect(spy).toHaveBeenCalledWith('pointerdown', expect.any(Function), true)
|
||||
spy.mockRestore()
|
||||
})
|
||||
|
||||
it('a context menu during the press removes the listener and does not deselect', async () => {
|
||||
await selected()
|
||||
const spy = vi.spyOn(document, 'removeEventListener')
|
||||
tap(rect(), { during: () => fireEvent.contextMenu(rect()) })
|
||||
expect(spy).toHaveBeenCalledWith('pointerdown', expect.any(Function), true)
|
||||
expect(isDeselected()).toBe(false)
|
||||
spy.mockRestore()
|
||||
})
|
||||
|
||||
it('a pen tap deselects at the pointer-up like a mouse', async () => {
|
||||
await selected()
|
||||
tap(rect(), { type: 'pen' })
|
||||
expect(isDeselected()).toBe(true)
|
||||
expect(announce).toHaveBeenCalledWith(DESELECTED)
|
||||
})
|
||||
|
||||
it('keeps a pending keyboard creation with its typed name', async () => {
|
||||
await mountSpy({ text: drawnText() })
|
||||
const user = userEvent.setup()
|
||||
|
||||
Reference in new issue
Block a user