fix(editor): name vertex handles after their zone, in a named group
Criterion 18: « Sommet {n} de {nom} », « Ajouter un sommet après le sommet
{n} de {nom} », « Retirer le sommet {n} de {nom} » (EN « Vertex {n} of
{name} » …), {nom} the zone's display name in the current locale; the
handle group is a role="group" named « Sommets de {nom} ».
Tests: no assertion removed; every unit and e2e locator that read the old
names now reads the same handle with the zone name appended (fixtures: N,
Vertèbres thoraciques, Zone dessinée, Zone clavier). New unit tests in
editor-zone-edit cover the FR names, the group and the EN locale.
This commit is contained in:
1 parent
fab641c278
commit
b6aa2819ea
15 files changed
+165
-67
No files matched your search
@@ -708,7 +708,7 @@ describe('polygons and paths', () => {
|
||||
it('« + » adds a vertex on the drawing and « − » removes it', async () => {
|
||||
await mount({ text: zoneText({ type: 'polygon', points: triangle }) })
|
||||
await selectFromList()
|
||||
pressAt(handleHit('Ajouter un sommet après le sommet 1'), 50, 20)
|
||||
pressAt(handleHit('Ajouter un sommet après le sommet 1 de N'), 50, 20)
|
||||
expect(geometryOf('zone-a')).toMatchObject({
|
||||
points: [
|
||||
[20, 20],
|
||||
@@ -717,16 +717,16 @@ describe('polygons and paths', () => {
|
||||
[50, 80],
|
||||
],
|
||||
})
|
||||
pressAt(handleHit('Retirer le sommet 2'), 50, 10)
|
||||
pressAt(handleHit('Retirer le sommet 2 de N'), 50, 10)
|
||||
expect(geometryOf('zone-a')).toMatchObject({ points: triangle })
|
||||
})
|
||||
|
||||
it('never removes a vertex below three: « − » is greyed', async () => {
|
||||
await mount({ text: zoneText({ type: 'polygon', points: triangle }) })
|
||||
await selectFromList()
|
||||
pressAt(handleHit('Sommet 1'), 20, 20)
|
||||
pressAt(handleHit('Sommet 1 de N'), 20, 20)
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Retirer le sommet 1' }),
|
||||
screen.getByRole('button', { name: 'Retirer le sommet 1 de N' }),
|
||||
).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
@@ -909,7 +909,7 @@ describe('refusals through the tab (H8)', () => {
|
||||
await selectFromList()
|
||||
const before = store.getState().documentText
|
||||
const vertex = screen
|
||||
.getByRole('button', { name: 'Sommet 1' })
|
||||
.getByRole('button', { name: 'Sommet 1 de N' })
|
||||
.querySelector('[data-handle]')!
|
||||
mouseDrag(vertex, [20, 20], [500, 20])
|
||||
expect(store.getState().documentText).toBe(before)
|
||||
|
||||
@@ -161,7 +161,7 @@ describe('the two-finger hint (R-1)', () => {
|
||||
it('never replaces a message that shows', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
drag(hitOf('Sommet 2'), [80, 20], [90, 10], 'mouse')
|
||||
drag(hitOf('Sommet 2 de N'), [80, 20], [90, 10], 'mouse')
|
||||
expect(line()).toHaveTextContent('Sommet déplacé')
|
||||
drag(canvas(), [5, 5], [45, 5])
|
||||
expect(line()).toHaveTextContent('Sommet déplacé')
|
||||
@@ -209,7 +209,7 @@ describe('the loupe of a finger drag', () => {
|
||||
.querySelector('svg')!
|
||||
drawing.setAttribute('id', 'drawing-root')
|
||||
drawing.firstElementChild?.setAttribute('id', 'drawing-part')
|
||||
const vertex = hitOf('Sommet 2')
|
||||
const vertex = hitOf('Sommet 2 de N')
|
||||
fireEvent.pointerDown(vertex, finger(1, 80, 20))
|
||||
fireEvent.pointerMove(vertex, finger(1, 95, 35))
|
||||
expect(loupe()).not.toBeNull()
|
||||
@@ -222,7 +222,7 @@ describe('the loupe of a finger drag', () => {
|
||||
it('shows a picture of the drawing above the finger, then goes on the drop', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
const vertex = hitOf('Sommet 2')
|
||||
const vertex = hitOf('Sommet 2 de N')
|
||||
fireEvent.pointerDown(vertex, finger(1, 80, 20))
|
||||
fireEvent.pointerMove(vertex, finger(1, 95, 35))
|
||||
const shown = loupe()!
|
||||
@@ -239,7 +239,7 @@ describe('the loupe of a finger drag', () => {
|
||||
it('goes when the drag is cancelled by a second finger', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
const vertex = hitOf('Sommet 2')
|
||||
const vertex = hitOf('Sommet 2 de N')
|
||||
fireEvent.pointerDown(vertex, finger(1, 80, 20))
|
||||
fireEvent.pointerMove(vertex, finger(1, 95, 35))
|
||||
expect(loupe()).not.toBeNull()
|
||||
@@ -250,7 +250,7 @@ describe('the loupe of a finger drag', () => {
|
||||
it('a mouse drag shows none', async () => {
|
||||
await mount()
|
||||
await select()
|
||||
const vertex = hitOf('Sommet 2')
|
||||
const vertex = hitOf('Sommet 2 de N')
|
||||
fireEvent.pointerDown(vertex, finger(1, 80, 20, 'mouse'))
|
||||
fireEvent.pointerMove(vertex, finger(1, 95, 35, 'mouse'))
|
||||
expect(loupe()).toBeNull()
|
||||
|
||||
@@ -133,11 +133,13 @@ const mouse = {
|
||||
const hitOf = (name: string) =>
|
||||
screen.getByRole('button', { name }).querySelector('[data-handle]')!
|
||||
const vertex = (n: number) =>
|
||||
screen.getByRole('button', { name: `Sommet ${n}` })
|
||||
screen.getByRole('button', { name: `Sommet ${n} de N` })
|
||||
const plus = (n: number) =>
|
||||
screen.getByRole('button', { name: `Ajouter un sommet après le sommet ${n}` })
|
||||
screen.getByRole('button', {
|
||||
name: `Ajouter un sommet après le sommet ${n} de N`,
|
||||
})
|
||||
const minus = (n: number) =>
|
||||
screen.getByRole('button', { name: `Retirer le sommet ${n}` })
|
||||
screen.getByRole('button', { name: `Retirer le sommet ${n} de N` })
|
||||
const clickHandle = (name: string, at: [number, number] = [0, 0]) =>
|
||||
pressAt(hitOf(name), at[0], at[1])
|
||||
const marker = (id: string) =>
|
||||
@@ -166,7 +168,7 @@ describe('a vertex (R-9)', () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
expect(detail()).toHaveTextContent('Zone · 4 sommets')
|
||||
clickHandle('Sommet 2', [80, 20])
|
||||
clickHandle('Sommet 2 de N', [80, 20])
|
||||
expect(chosen()).toEqual({
|
||||
annotationId: 'z',
|
||||
vertex: 1,
|
||||
@@ -185,11 +187,11 @@ describe('a vertex (R-9)', () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
const before = depth()
|
||||
drag(hitOf('Sommet 2'), [80, 20], [90, 10])
|
||||
drag(hitOf('Sommet 2 de N'), [80, 20], [90, 10])
|
||||
expect(pointsOf('z')![1]).toEqual([90, 10])
|
||||
expect(depth()).toBe(before + 1)
|
||||
expect(message()).toHaveTextContent('Sommet déplacé')
|
||||
drag(hitOf('Sommet 2'), [90, 10], [80, 80])
|
||||
drag(hitOf('Sommet 2 de N'), [90, 10], [80, 80])
|
||||
expect(pointsOf('z')![1]).toEqual([90, 10])
|
||||
expect(depth()).toBe(before + 1)
|
||||
})
|
||||
@@ -198,7 +200,7 @@ describe('a vertex (R-9)', () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
const before = depth()
|
||||
clickHandle('Ajouter un sommet après le sommet 1', [50, 20])
|
||||
clickHandle('Ajouter un sommet après le sommet 1 de N', [50, 20])
|
||||
expect(pointsOf('z')).toEqual([[20, 20], [50, 20], ...SQUARE.slice(1)])
|
||||
expect(depth()).toBe(before + 1)
|
||||
expect(chosen()).toMatchObject({ vertex: 1 })
|
||||
@@ -211,8 +213,8 @@ describe('a vertex (R-9)', () => {
|
||||
await mount(squareText())
|
||||
render(<UndoKeys />)
|
||||
await select()
|
||||
clickHandle('Ajouter un sommet après le sommet 1', [50, 20])
|
||||
const bubble = hitOf('Retirer le sommet 2')
|
||||
clickHandle('Ajouter un sommet après le sommet 1 de N', [50, 20])
|
||||
const bubble = hitOf('Retirer le sommet 2 de N')
|
||||
fireEvent.keyDown(document.body, { key: 'z', ctrlKey: true })
|
||||
expect(pointsOf('z')).toEqual(SQUARE)
|
||||
expect(chosen()).toBeNull()
|
||||
@@ -232,8 +234,8 @@ describe('a vertex (R-9)', () => {
|
||||
it('« − » removes the chosen vertex', async () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
clickHandle('Sommet 3', [80, 80])
|
||||
clickHandle('Retirer le sommet 3', [80, 70])
|
||||
clickHandle('Sommet 3 de N', [80, 80])
|
||||
clickHandle('Retirer le sommet 3 de N', [80, 70])
|
||||
expect(pointsOf('z')).toEqual([SQUARE[0], SQUARE[1], SQUARE[3]])
|
||||
expect(chosen()).toBeNull()
|
||||
expect(message()).toHaveTextContent('Sommet retiré')
|
||||
@@ -244,9 +246,9 @@ describe('a vertex (R-9)', () => {
|
||||
await mount(squareText(triangle))
|
||||
await select()
|
||||
const before = depth()
|
||||
clickHandle('Sommet 1', [20, 20])
|
||||
clickHandle('Sommet 1 de N', [20, 20])
|
||||
expect(minus(1)).toHaveAttribute('aria-disabled', 'true')
|
||||
clickHandle('Retirer le sommet 1', [20, 10])
|
||||
clickHandle('Retirer le sommet 1 de N', [20, 10])
|
||||
expect(pointsOf('z')).toEqual(triangle)
|
||||
expect(depth()).toBe(before)
|
||||
expect(message()).toHaveTextContent('Une zone garde au moins 3 sommets')
|
||||
@@ -279,14 +281,64 @@ describe('a vertex (R-9)', () => {
|
||||
.getAllByRole('button')
|
||||
.filter((b) => b.closest('[data-testid="handle-layer"]'))
|
||||
.map((b) => b.getAttribute('aria-label'))
|
||||
expect(order).toContain('Ajouter un sommet après le sommet 4')
|
||||
expect(order).toContain('Sommet 4')
|
||||
expect(order).toContain('Ajouter un sommet après le sommet 4 de N')
|
||||
expect(order).toContain('Sommet 4 de N')
|
||||
fireEvent.keyDown(plus(4), { key: 'Enter' })
|
||||
expect(pointsOf('z')).toHaveLength(5)
|
||||
expect(pointsOf('z')![4]).toEqual([20, 50])
|
||||
})
|
||||
})
|
||||
|
||||
describe('handle names carry the zone name (criterion 18)', () => {
|
||||
const named = (name: { fr: string; en: string }) =>
|
||||
insert(drawnText(), {
|
||||
kind: 'annotation',
|
||||
value: {
|
||||
...zone('z', { type: 'polygon', points: SQUARE }),
|
||||
name,
|
||||
} as Annotation,
|
||||
})
|
||||
|
||||
it('« Sommet {n} de {nom} », the « + » and « − » too, in a named group', async () => {
|
||||
await mount(named({ fr: 'Thoraciques', en: 'Thoracic' }))
|
||||
await select()
|
||||
expect(
|
||||
screen.getByRole('group', { name: 'Sommets de Thoraciques' }),
|
||||
).toBeInTheDocument()
|
||||
clickHandle('Sommet 2 de Thoraciques', [80, 20])
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: 'Ajouter un sommet après le sommet 1 de Thoraciques',
|
||||
}),
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: 'Retirer le sommet 2 de Thoraciques',
|
||||
}),
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('in English, the name of the current locale', async () => {
|
||||
useLocaleStore.setState({ locale: 'en' })
|
||||
await mount(named({ fr: 'Thoraciques', en: 'Thoracic' }))
|
||||
const list = await screen.findByRole('list', {
|
||||
name: 'Annotations of the view',
|
||||
})
|
||||
await userEvent.setup().click(within(list).getAllByRole('button')[0])
|
||||
expect(
|
||||
await screen.findByRole('group', { name: 'Vertices of Thoracic' }),
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Vertex 3 of Thoracic' }),
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: 'Add a vertex after vertex 3 of Thoracic',
|
||||
}),
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
describe('a double click on a handle (R-8, carried Task 2 gap)', () => {
|
||||
const twice = (el: Element, x: number, y: number) => {
|
||||
pressAt(el, x, y)
|
||||
@@ -297,7 +349,7 @@ describe('a double click on a handle (R-8, carried Task 2 gap)', () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
const before = depth()
|
||||
twice(hitOf('Ajouter un sommet après le sommet 1'), 50, 20)
|
||||
twice(hitOf('Ajouter un sommet après le sommet 1 de N'), 50, 20)
|
||||
expect(pointsOf('z')).toHaveLength(5)
|
||||
expect(depth()).toBe(before + 1)
|
||||
})
|
||||
@@ -306,7 +358,7 @@ describe('a double click on a handle (R-8, carried Task 2 gap)', () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
const spy = vi.spyOn(useAnnotationWork, 'setState')
|
||||
twice(hitOf('Sommet 2'), 80, 20)
|
||||
twice(hitOf('Sommet 2 de N'), 80, 20)
|
||||
const choices = spy.mock.calls.filter(
|
||||
([patch]) => typeof patch === 'object' && 'chosen' in patch,
|
||||
)
|
||||
@@ -318,9 +370,9 @@ describe('a double click on a handle (R-8, carried Task 2 gap)', () => {
|
||||
it('on « − »: one removal, never a second', async () => {
|
||||
await mount(squareText([...SQUARE, [10, 50]]))
|
||||
await select()
|
||||
clickHandle('Sommet 2', [80, 20])
|
||||
clickHandle('Sommet 2 de N', [80, 20])
|
||||
const before = depth()
|
||||
pressAt(hitOf('Retirer le sommet 2'), 80, 10)
|
||||
pressAt(hitOf('Retirer le sommet 2 de N'), 80, 10)
|
||||
// The second click of the double click lands on what is there now, at the same place.
|
||||
pressAt(liveBubbleOrCanvas(), 80, 10)
|
||||
expect(pointsOf('z')).toHaveLength(4)
|
||||
@@ -364,7 +416,7 @@ describe('moving the zone (A11, R-12)', () => {
|
||||
it('« Déplacer le sommet » moves the chosen vertex only', async () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
clickHandle('Sommet 3', [80, 80])
|
||||
clickHandle('Sommet 3 de N', [80, 80])
|
||||
await userEvent
|
||||
.setup()
|
||||
.click(screen.getByRole('button', { name: 'Déplacer le sommet' }))
|
||||
@@ -444,10 +496,10 @@ describe('paths (UX_TESTS « Paths »)', () => {
|
||||
await mount(pathAndZone())
|
||||
const before = JSON.stringify(annotationOf('p').geometry)
|
||||
await select(1)
|
||||
clickHandle('Ajouter un sommet après le sommet 1', [72.5, 55])
|
||||
clickHandle('Sommet 2', [72.5, 55])
|
||||
clickHandle('Retirer le sommet 2', [72.5, 45])
|
||||
drag(hitOf('Sommet 1'), [55, 55], [60, 60])
|
||||
clickHandle('Ajouter un sommet après le sommet 1 de N', [72.5, 55])
|
||||
clickHandle('Sommet 2 de N', [72.5, 55])
|
||||
clickHandle('Retirer le sommet 2 de N', [72.5, 45])
|
||||
drag(hitOf('Sommet 1 de N'), [55, 55], [60, 60])
|
||||
drag(marker('z'), [80, 80], [85, 85])
|
||||
expect(depth()).toBe(4)
|
||||
expect(JSON.stringify(annotationOf('p').geometry)).toBe(before)
|
||||
@@ -710,7 +762,7 @@ describe('fix round 1: no lost series, no lost focus, no stale « − »', () =>
|
||||
it('M-2: a chosen vertex stamped on another text removes nothing', async () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
clickHandle('Sommet 2', [80, 20])
|
||||
clickHandle('Sommet 2 de N', [80, 20])
|
||||
const before = depth()
|
||||
act(() =>
|
||||
useAnnotationWork.setState({
|
||||
@@ -818,7 +870,7 @@ describe('the zoom hint for short segments (R-18, D2)', () => {
|
||||
await select()
|
||||
expect(
|
||||
screen.queryByRole('button', {
|
||||
name: 'Ajouter un sommet après le sommet 1',
|
||||
name: 'Ajouter un sommet après le sommet 1 de N',
|
||||
}),
|
||||
).toBeNull()
|
||||
expect(plus(2)).toBeInTheDocument()
|
||||
@@ -835,7 +887,7 @@ describe('the zoom hint for short segments (R-18, D2)', () => {
|
||||
it('a refusal takes its place while shown', async () => {
|
||||
await mount(squareText(SHORT))
|
||||
await select()
|
||||
drag(hitOf('Sommet 3'), [80, 20], [500, 20])
|
||||
drag(hitOf('Sommet 3 de N'), [80, 20], [500, 20])
|
||||
const notice = screen.getByTestId('edit-strip-notice')
|
||||
expect(notice).toHaveTextContent('Déplacement refusé')
|
||||
expect(notice).not.toHaveTextContent(zoomHint)
|
||||
@@ -1011,7 +1063,7 @@ describe('final review I-1: a redo or a handle key never drops pending work', ()
|
||||
it('in a started vertex move, Enter on « − », Insert and Delete change nothing', async () => {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
clickHandle('Sommet 3', [80, 80])
|
||||
clickHandle('Sommet 3 de N', [80, 80])
|
||||
await startedMove('Déplacer le sommet')
|
||||
const before = depth()
|
||||
fireEvent.keyDown(minus(3), { key: 'Enter' })
|
||||
@@ -1039,21 +1091,21 @@ describe('final review I-1 audit: a press on the drawing never drops a keyed ser
|
||||
|
||||
it('a press on « + »: the step is committed, then the insert', async () => {
|
||||
const before = await keyed()
|
||||
clickHandle('Ajouter un sommet après le sommet 1', [50.25, 20])
|
||||
clickHandle('Ajouter un sommet après le sommet 1 de N', [50.25, 20])
|
||||
expect(pointsOf('z')).toEqual([[20.5, 20], [50.25, 20], ...SQUARE.slice(1)])
|
||||
expect(depth()).toBe(before + 2)
|
||||
})
|
||||
|
||||
it('a press on « − »: the step is committed, then the removal', async () => {
|
||||
const before = await keyed([...SQUARE, [10, 50]])
|
||||
clickHandle('Retirer le sommet 1', [20.5, 20])
|
||||
clickHandle('Retirer le sommet 1 de N', [20.5, 20])
|
||||
expect(pointsOf('z')).toEqual([...SQUARE.slice(1), [10, 50]])
|
||||
expect(depth()).toBe(before + 2)
|
||||
})
|
||||
|
||||
it('a drag of another vertex carries the keyed step', async () => {
|
||||
await keyed()
|
||||
drag(hitOf('Sommet 2'), [80, 20], [90, 10])
|
||||
drag(hitOf('Sommet 2 de N'), [80, 20], [90, 10])
|
||||
expect(pointsOf('z')).toEqual([[20.5, 20], [90, 10], ...SQUARE.slice(2)])
|
||||
})
|
||||
})
|
||||
@@ -1144,7 +1196,7 @@ describe('Safari: a strip command clicked with the focus left on a keyed vertex'
|
||||
async function keyedVertex() {
|
||||
await mount(squareText())
|
||||
await select()
|
||||
clickHandle('Sommet 1', [20, 20])
|
||||
clickHandle('Sommet 1 de N', [20, 20])
|
||||
act(() => vertex(1).focus())
|
||||
fireEvent.keyDown(vertex(1), { key: 'ArrowRight' })
|
||||
expect(useAnnotationWork.getState().preview?.source).toBe('keys')
|
||||
|
||||
Reference in new issue
Block a user