From 2f8a86f01dfad9a9c879acc05eab4ec4c1c4f5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Tomczyk?= Date: Mon, 6 Mar 2023 09:58:29 +0100 Subject: [PATCH] fix: changed accessibility label based on onPress callback (#3719) --- src/components/Appbar/AppbarContent.tsx | 2 +- .../__tests__/Appbar/Appbar.test.tsx | 23 +++++++++++++++++++ .../Appbar/__snapshots__/Appbar.test.tsx.snap | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/Appbar/AppbarContent.tsx b/src/components/Appbar/AppbarContent.tsx index e89a370dab..2947fff66e 100644 --- a/src/components/Appbar/AppbarContent.tsx +++ b/src/components/Appbar/AppbarContent.tsx @@ -130,7 +130,7 @@ const AppbarContent = ({ return ( diff --git a/src/components/__tests__/Appbar/Appbar.test.tsx b/src/components/__tests__/Appbar/Appbar.test.tsx index 9cca04a907..9c49d95e7c 100644 --- a/src/components/__tests__/Appbar/Appbar.test.tsx +++ b/src/components/__tests__/Appbar/Appbar.test.tsx @@ -210,6 +210,29 @@ describe('renderAppbarContent', () => { expect.arrayContaining([expect.objectContaining(v2Spacing)]) ); }); + + it('Is recognized as a header when no onPress callback has been pressed', () => { + const { getByRole } = render( + + + + + + ); + + expect(getByRole('text')).toBeTruthy(); + }); + it('Is recognized as a button when onPress callback has been pressed', () => { + const { getByRole } = render( + + + {}} /> + + + ); + + expect(getByRole('button')).toBeTruthy(); + }); }); describe('AppbarAction', () => { diff --git a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap index bb2a5f0086..15971f4b91 100644 --- a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap +++ b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap @@ -700,7 +700,7 @@ exports[`Appbar passes additional props to AppbarBackAction, AppbarContent and A