-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch liveness/alpha in to dca-v2 to include back camera (#5846)
* Update publish workflow * disable e2e tests in workflow * Squashed commit of the following: commit 984fa99 Author: thaddmt <68032955+thaddmt@users.noreply.github.com> Date: Thu Sep 26 11:10:45 2024 -0700 chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * only show on mobile with facemovement challenge only * relax e2e tests on alpha * make more reaadable * fix * update names * refactor, add tests * Update packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.tsx Co-authored-by: Caleb Pollman <cpollman@amazon.com> * refactor --------- Co-authored-by: Caleb Pollman <cpollman@amazon.com>
- Loading branch information
1 parent
1472d99
commit bdc7061
Showing
7 changed files
with
86 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/react-liveness/src/components/FaceLivenessDetector/LivenessCheck/CameraSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Flex, Label, SelectField, View } from '@aws-amplify/ui-react'; | ||
import React from 'react'; | ||
import { LivenessClassNames } from '../types/classNames'; | ||
|
||
interface CameraSelectorProps { | ||
deviceId?: string; | ||
onSelect: (e: React.ChangeEvent<HTMLSelectElement>) => void; | ||
devices: MediaDeviceInfo[]; | ||
} | ||
|
||
export const CameraSelector = (props: CameraSelectorProps): JSX.Element => { | ||
const { | ||
onSelect: onCameraChange, | ||
devices: selectableDevices, | ||
deviceId: selectedDeviceId, | ||
} = props; | ||
return ( | ||
<Flex className={LivenessClassNames.StartScreenCameraSelect}> | ||
<View className={LivenessClassNames.StartScreenCameraSelectContainer}> | ||
<Label | ||
htmlFor="amplify-liveness-camera-select" | ||
className={`${LivenessClassNames.StartScreenCameraSelect}__label`} | ||
> | ||
Camera: | ||
</Label> | ||
<SelectField | ||
id="amplify-liveness-camera-select" | ||
testId="amplify-liveness-camera-select" | ||
label="Camera" | ||
labelHidden | ||
value={selectedDeviceId} | ||
onChange={onCameraChange} | ||
> | ||
{selectableDevices.map((device) => ( | ||
<option value={device.deviceId} key={device.deviceId}> | ||
{device.label} | ||
</option> | ||
))} | ||
</SelectField> | ||
</View> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...eness/src/components/FaceLivenessDetector/LivenessCheck/__tests__/CameraSelector.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { render } from '@testing-library/react'; | ||
import { CameraSelector } from '../CameraSelector'; | ||
import React from 'react'; | ||
|
||
const mockMediaDevice: MediaDeviceInfo = { | ||
deviceId: 'foobar', | ||
groupId: 'foobar', | ||
kind: 'videoinput', | ||
label: 'foobar', | ||
toJSON: jest.fn(), | ||
}; | ||
|
||
describe('CameraSelector', () => { | ||
it('should render', () => { | ||
const result = render( | ||
<CameraSelector onSelect={() => {}} devices={[mockMediaDevice]} /> | ||
); | ||
|
||
expect(result.container).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters