Skip to content

Commit

Permalink
chore(liveness): update hold still text to show when matched (#4780)
Browse files Browse the repository at this point in the history
* chore(liveness): update hold still text to show when matched

* Create blue-apes-own.md
  • Loading branch information
thaddmt authored Nov 27, 2023
1 parent d026557 commit 33256ee
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-apes-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aws-amplify/ui-react-liveness": patch
---

chore(liveness): update hold still text to show when matched
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const showMatchIndicatorStates = [
FaceMatchState.TOO_FAR,
FaceMatchState.CANT_IDENTIFY,
FaceMatchState.FACE_IDENTIFIED,
FaceMatchState.MATCHED,
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('LivenessCameraModule', () => {
const matchIndicator = cameraModule.getElementsByClassName(
LivenessClassNames.MatchIndicator
);
expect(matchIndicator).toHaveLength(1);
expect(matchIndicator).toHaveLength(0);
});

it('should not render MatchIndicator when isRecording and faceMatchState is TOO_MANY', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,23 @@ export const Hint: React.FC<HintProps> = ({ hintDisplayText }) => {
// During face matching, we want to only show the TOO_CLOSE or
// TOO_FAR texts. If FaceMatchState matches TOO_CLOSE, we'll show
// the TOO_CLOSE text, but for FACE_IDENTIFED, CANT_IDENTIFY, TOO_MANY
// we are defaulting to the TOO_FAR text (for now). For MATCHED state,
// we don't want to show any toasts.
// we are defaulting to the TOO_FAR text (for now).
let resultHintString = FaceMatchStateStringMap[FaceMatchState.TOO_FAR];
if (
faceMatchState === FaceMatchState.TOO_CLOSE ||
faceMatchState === FaceMatchState.MATCHED
) {
resultHintString = FaceMatchStateStringMap[faceMatchState];
}

return (
<Toast
size="large"
variation={
faceMatchState === FaceMatchState.TOO_CLOSE ? 'error' : 'primary'
}
>
{faceMatchState === FaceMatchState.TOO_CLOSE
? FaceMatchStateStringMap[FaceMatchState.TOO_CLOSE]
: FaceMatchStateStringMap[FaceMatchState.TOO_FAR]}
{resultHintString}
</Toast>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ describe('Hint', () => {
).toBeInTheDocument();
});

it('should render HOLD_STILL text if faceMatchState = MATCHED and recording', () => {
faceMatchState = FaceMatchState.MATCHED;
isRecording = true;
mockStateMatchesAndSelectors();

renderWithLivenessProvider(<Hint hintDisplayText={hintDisplayText} />);

expect(
screen.getByText(hintDisplayText.hintHoldFaceForFreshnessText)
).toBeInTheDocument();
});

it('should render TOO_FAR text if faceMatchState = CANT_IDENTIFY and recording', () => {
faceMatchState = FaceMatchState.CANT_IDENTIFY;
isRecording = true;
Expand Down

0 comments on commit 33256ee

Please sign in to comment.