fix(editor): loupe copy without ids, two fingers counted in the pinch
Minor 1: the loupe's copy of the drawing drops every id (the equine drawing has 142); its url(#…) and href="#…" resolve to the originals. Minor 2: useFraming's onPinch marks the two-finger flag at the pinch move itself; the passive effect that read the live press phase and the press hook's multi() are removed.
This commit is contained in:
1 parent
181f81789a
commit
dd3f245bca
5 files changed
+59
-33
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/** U2 Task 8: the two-finger hint (R-1) and the loupe of a finger's drag. */
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
act,
|
||||
cleanup,
|
||||
fireEvent,
|
||||
render,
|
||||
@@ -181,7 +182,43 @@ describe('the two-finger hint (R-1)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('fix round 1: the two fingers counted in the pinch itself (Minor 2)', () => {
|
||||
it('a pinch whose framing change lands after the lift still suppresses the hint', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
fireEvent.pointerDown(canvas(), finger(1, 10, 10))
|
||||
fireEvent.pointerDown(canvas(), finger(2, 60, 10))
|
||||
// One batch: the framing renders, and its effects run, only after both fingers lifted.
|
||||
act(() => {
|
||||
fireEvent.pointerMove(canvas(), finger(2, 110, 10))
|
||||
fireEvent.pointerUp(canvas(), { ...finger(2, 110, 10), buttons: 0 })
|
||||
fireEvent.pointerUp(canvas(), { ...finger(1, 10, 10), buttons: 0 })
|
||||
})
|
||||
drag(canvas(), [5, 5], [45, 5])
|
||||
expect(line()).not.toHaveTextContent(HINT)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the loupe of a finger drag', () => {
|
||||
it('copies the drawing without its ids: no id appears twice (Minor 1)', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
// The fixture drawing has no id: give it a few, as a real drawing has.
|
||||
const drawing = screen
|
||||
.getByTestId('annotation-canvas-drawing')
|
||||
.querySelector('svg')!
|
||||
drawing.setAttribute('id', 'drawing-root')
|
||||
drawing.firstElementChild?.setAttribute('id', 'drawing-part')
|
||||
const vertex = hitOf('Sommet 2')
|
||||
fireEvent.pointerDown(vertex, finger(1, 80, 20))
|
||||
fireEvent.pointerMove(vertex, finger(1, 95, 35))
|
||||
expect(loupe()).not.toBeNull()
|
||||
const ids = [...document.querySelectorAll('[id]')].map((el) => el.id)
|
||||
expect(ids).toContain('drawing-root')
|
||||
expect(ids.length).toBe(new Set(ids).size)
|
||||
fireEvent.pointerUp(vertex, { ...finger(1, 95, 35), buttons: 0 })
|
||||
})
|
||||
|
||||
it('shows a picture of the drawing above the finger, then goes on the drop', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
|
||||
Reference in new issue
Block a user