Skip to content

Commit

Permalink
fix(liveness): add accessibility attributes to face liveness error mo…
Browse files Browse the repository at this point in the history
…dal (#4803)

* adding aria-labelledby and role attributes to liveness error modal

* make id generic error

* updating test

* Create plenty-snakes-try.md

* updating docs snapshots

* restoring sitemap

* updating snapshots again

* removing sitemap once again

* update aria attributes

* update snapshots

* update test

* making ids more descriptive

* update test

* removing div

* move description down a level

* change id to say message

* fix tests

* using Text

* Update .changeset/plenty-snakes-try.md

Co-authored-by: Scott Rees <[email protected]>

---------

Co-authored-by: Scott Rees <[email protected]>
  • Loading branch information
esauerbo and reesscot authored Dec 12, 2023
1 parent 38bae5e commit a1b4c54
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-snakes-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aws-amplify/ui-react-liveness": patch
---

fix(liveness): add a11y tags to `FaceLivenessErrorModal`
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ const renderToastErrorModal = (props: {
<>
<Flex className={LivenessClassNames.ErrorModal}>
<AlertIcon ariaHidden variation="error" />
<Text className={LivenessClassNames.ErrorModalHeading}>{heading}</Text>
<Text
className={LivenessClassNames.ErrorModalHeading}
id="amplify-liveness-error-heading"
>
{heading}
</Text>
</Flex>
{message}
<Text id="amplify-liveness-error-message">{message}</Text>
</>
);
};
Expand Down Expand Up @@ -116,7 +121,11 @@ export const FaceLivenessErrorModal: React.FC<FaceLivenessErrorModalProps> = (

return (
<Overlay className={LivenessClassNames.OpaqueOverlay}>
<Toast>
<Toast
aria-labelledby="amplify-liveness-error-heading"
aria-describedby="amplify-liveness-error-message"
role="alertdialog"
>
{children}
<Flex justifyContent="center">
<Button variation="primary" type="button" onClick={onRetry}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ describe('FaceLivenessErrorModal', () => {
expect(screen.getByText(timeoutMessageText)).toBeInTheDocument();
});

it('should render the timeout message with proper accessibility attributes', () => {
const errorState = LivenessErrorState.TIMEOUT;
render(
<FaceLivenessErrorModal onRetry={() => {}}>
{renderErrorModal({ errorState })}
</FaceLivenessErrorModal>
);

const timeoutModal = screen.getByRole('alertdialog');
expect(timeoutModal).toBeInTheDocument();
expect(timeoutModal).toHaveAttribute(
'aria-describedby',
'amplify-liveness-error-message'
);
expect(timeoutModal).toHaveAttribute(
'aria-labelledby',
'amplify-liveness-error-heading'
);
});

it('should render the runtime error message appropriately', () => {
const errorState = LivenessErrorState.RUNTIME_ERROR;
render(
Expand Down

0 comments on commit a1b4c54

Please sign in to comment.