-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge liveness/alpha into liveness dca v2 (#5992)
* chore(liveness): allow selecting all cameras, allow camera selection … (#5833) * chore(liveness): allow selecting all cameras, allow camera selection on mobile * fix(liveness): fix camera select showing up with one camera, fix camera changing weirdness with hair check screen (#5845) * fix(liveness): Only apply transform style on user-facing video (#5953) * fix(liveness): Fix oval render when switching cameras (#5954) --------- Co-authored-by: thaddmt <[email protected]> Co-authored-by: Caleb Pollman <[email protected]> Co-authored-by: Emma Sauerborn <[email protected]> Co-authored-by: Scott Rees <[email protected]>
- Loading branch information
1 parent
edc0d5b
commit 68e1fe9
Showing
9 changed files
with
502 additions
and
226 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
50 changes: 41 additions & 9 deletions
50
...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 |
---|---|---|
@@ -1,21 +1,53 @@ | ||
import { render } from '@testing-library/react'; | ||
import { fireEvent, render, screen } 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(), | ||
}; | ||
const mockMediaDevices: MediaDeviceInfo[] = [ | ||
{ | ||
deviceId: '1', | ||
groupId: 'foobar', | ||
label: 'Camera 1', | ||
kind: 'videoinput', | ||
toJSON: jest.fn(), | ||
}, | ||
{ | ||
deviceId: '2', | ||
groupId: 'foobar', | ||
label: 'Camera 2', | ||
kind: 'videoinput', | ||
toJSON: jest.fn(), | ||
}, | ||
]; | ||
|
||
const onChange = jest.fn(); | ||
describe('CameraSelector', () => { | ||
beforeEach(() => { | ||
onChange.mockClear(); | ||
}); | ||
|
||
it('should render', () => { | ||
const result = render( | ||
<CameraSelector onSelect={() => {}} devices={[mockMediaDevice]} /> | ||
<CameraSelector onSelect={onChange} devices={mockMediaDevices} /> | ||
); | ||
|
||
expect(result.container).toBeDefined(); | ||
}); | ||
|
||
it('renders CameraSelector when there are multiple devices and allows changing camera', async () => { | ||
render(<CameraSelector onSelect={onChange} devices={mockMediaDevices} />); | ||
|
||
const selectElement = screen.getByRole('combobox') as HTMLSelectElement; | ||
expect(selectElement).toBeInTheDocument(); | ||
expect(selectElement.value).toBe('1'); | ||
|
||
const options = screen.getAllByRole('option'); | ||
expect(options).toHaveLength(2); | ||
expect(options[0].textContent).toBe('Camera 1'); | ||
expect(options[1].textContent).toBe('Camera 2'); | ||
|
||
// Simulate selecting the back camera | ||
fireEvent.change(selectElement, { target: { value: '2' } }); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
expect(selectElement.value).toBe('2'); | ||
}); | ||
}); |
Oops, something went wrong.