feat(editor): Backspace and « + » on a vertex handle
This commit is contained in:
1 parent
c01c6f3145
commit
6df66f9bb9
5 files changed
+108
-10
No files matched your search
@@ -352,6 +352,21 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
expect(untouched()).toEqual(before)
|
||||
})
|
||||
|
||||
it('Backspace and « + » on a pending vertex act as Delete and Insert, nothing held', async () => {
|
||||
await resumed()
|
||||
const before = untouched()
|
||||
const vertex = (n: number) =>
|
||||
screen.getByRole('button', { name: `Sommet ${n} de Tibia` })
|
||||
vertex(1).focus()
|
||||
expect(fireEvent.keyDown(vertex(1), { key: '+' })).toBe(false)
|
||||
expect(shape()).toHaveLength(5)
|
||||
expect(shape()![1]).toEqual([50, 20])
|
||||
expect(useAnnotationWork.getState().chosen).toMatchObject({ vertex: 1 })
|
||||
expect(fireEvent.keyDown(vertex(2), { key: 'Backspace' })).toBe(false)
|
||||
expect(shape()).toEqual(SQUARE)
|
||||
expect(untouched()).toEqual(before)
|
||||
})
|
||||
|
||||
it('« − » at three vertices is refused with its reason', async () => {
|
||||
await resumed('Tibia', SQUARE.slice(0, 3))
|
||||
clickHandle('Sommet 1 de Tibia', [20, 20])
|
||||
|
||||
@@ -241,6 +241,30 @@ describe('a vertex (R-9)', () => {
|
||||
expect(message()).toHaveTextContent('Sommet retiré')
|
||||
})
|
||||
|
||||
it('Backspace removes and « + » inserts like Delete and Insert, one commit each, the default prevented', async () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
const before = depth()
|
||||
vertex(1).focus()
|
||||
expect(fireEvent.keyDown(vertex(1), { key: '+' })).toBe(false)
|
||||
expect(pointsOf('z')).toHaveLength(5)
|
||||
expect(chosen()).toMatchObject({ vertex: 1 })
|
||||
expect(fireEvent.keyDown(vertex(2), { key: 'Backspace' })).toBe(false)
|
||||
expect(pointsOf('z')).toEqual(SQUARE)
|
||||
expect(depth()).toBe(before + 2)
|
||||
})
|
||||
|
||||
it('Backspace at three vertices keeps them with the reason; « + » needs no drawn « + »', async () => {
|
||||
await mount(squareText(SQUARE.slice(0, 3)))
|
||||
await select()
|
||||
vertex(1).focus()
|
||||
fireEvent.keyDown(vertex(1), { key: 'Backspace' })
|
||||
expect(pointsOf('z')).toHaveLength(3)
|
||||
expect(message()).toHaveTextContent('Une zone garde au moins 3 sommets')
|
||||
fireEvent.keyDown(vertex(1), { key: '+' })
|
||||
expect(pointsOf('z')).toHaveLength(4)
|
||||
})
|
||||
|
||||
it('« − » is disabled at 3 with its reason; nothing is removed', async () => {
|
||||
const triangle = SQUARE.slice(0, 3)
|
||||
await mount(squareText(triangle))
|
||||
|
||||
Reference in new issue
Block a user