test(editor): view row switches the canvas view
This commit is contained in:
1 parent
7cca88592f
commit
cf9c300c80
1 file changed
+15
-1
@@ -84,6 +84,15 @@ const overview = () =>
|
||||
screen.getByRole('region', { name: 'Aperçu de la fiche' })
|
||||
const card = () =>
|
||||
within(overview()).getByRole('list', { name: 'Annotations de la vue' })
|
||||
/** The visible body: the read-only twin hides the kept edit one. */
|
||||
const body = () =>
|
||||
screen
|
||||
.getAllByTestId('editor-tab-annotations')
|
||||
.find((el) => !el.closest('[hidden]'))!
|
||||
const canvas = (readOnly: boolean) =>
|
||||
within(body()).getByTestId(
|
||||
readOnly ? 'catalogue-canvas' : 'annotation-canvas',
|
||||
)
|
||||
const rows = () => within(card()).getAllByRole('button')
|
||||
const chip = (name: string) =>
|
||||
within(screen.getByRole('group', { name: 'Vues' })).getByRole('button', {
|
||||
@@ -124,7 +133,9 @@ describe.each([
|
||||
await mount(readOnly)
|
||||
const user = userEvent.setup()
|
||||
await user.click(rows()[1])
|
||||
expect(await screen.findByTestId('annotation-properties')).toBeVisible()
|
||||
expect(
|
||||
await within(body()).findByTestId('annotation-properties'),
|
||||
).toBeVisible()
|
||||
await user.click(
|
||||
screen.getByRole('button', { name: 'Toutes les annotations' }),
|
||||
)
|
||||
@@ -135,12 +146,15 @@ describe.each([
|
||||
it('a view row switches the canvas view', async () => {
|
||||
await mount(readOnly)
|
||||
const user = userEvent.setup()
|
||||
const name = (view: string) => (readOnly ? `Dessin : ${view}` : view)
|
||||
expect(canvas(readOnly)).not.toHaveAccessibleName(name('Tête'))
|
||||
expect(chip('Tête')).toHaveAttribute('aria-pressed', 'false')
|
||||
await user.click(within(overview()).getByRole('button', { name: /^Tête/ }))
|
||||
expect(
|
||||
within(overview()).getByRole('button', { name: /^Tête/ }),
|
||||
).toHaveAttribute('aria-current', 'true')
|
||||
expect(chip('Tête')).toHaveAttribute('aria-pressed', 'true')
|
||||
expect(canvas(readOnly)).toHaveAccessibleName(name('Tête'))
|
||||
expect(
|
||||
within(overview()).getByText('Aucune annotation dans cette vue.'),
|
||||
).toBeInTheDocument()
|
||||
|
||||
Reference in new issue
Block a user