-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DTRA] henry/dtra-2087/update-video-player (#17653)
* fix: initial commit * fix: update quill-icons package * fix: package lock * fix: make it work * fix: refactor onclick * fix: reset video time and progress bar to zero if clicking on replay * fix: close dropdown list when auto closing video controls * fix: prevent video controls from closing when there is user interaction * fix: sync with package update branch * chore: fix tests * fix: merge error * fix: resolve comments * fix: build fail * fix: some bugs * fix: syntax * fix: package-lock * fix: merge conflict * fix: do not show overlay on hover * fix: test * fix: test * fix: test * fix: test * fix: add back * fix: trying this * fix: trying new time * fix: add click event * fix: revert back to 500 * fix: error * fix: revert change in i18next file * fix: revert change in i18next file --------- Co-authored-by: Nijil Nirmal <[email protected]>
- Loading branch information
1 parent
b24a1d1
commit 33f4be7
Showing
13 changed files
with
6,656 additions
and
7,586 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
64 changes: 49 additions & 15 deletions
64
packages/components/src/components/video-player/__tests__/video-overlay.spec.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,29 +1,63 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import VideoOverlay from '../video-overlay'; | ||
|
||
const mocked_props = { | ||
onClick: jest.fn(), | ||
}; | ||
jest.mock('@deriv/quill-icons', () => ({ | ||
...jest.requireActual('@deriv/quill-icons'), | ||
StandalonePauseFillIcon: () => 'StandalonePauseFillIcon', | ||
StandalonePlayFillIcon: () => 'StandalonePlayFillIcon', | ||
StandaloneXmarkRegularIcon: () => 'StandaloneXmarkRegularIcon', | ||
})); | ||
|
||
describe('VideoOverlay', () => { | ||
const mockProps = { | ||
onClick: jest.fn(), | ||
togglePlay: jest.fn(), | ||
show_controls: false, | ||
is_ended: false, | ||
is_mobile: false, | ||
is_v2: false, | ||
is_playing: false, | ||
onModalClose: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should handle play/pause state correctly', () => { | ||
render(<VideoOverlay {...mockProps} is_v2={true} is_playing={true} />); | ||
expect(screen.getByText('StandalonePauseFillIcon')).toBeInTheDocument(); | ||
|
||
const icon_testid = 'dt_player_overlay_icon'; | ||
render(<VideoOverlay {...mockProps} is_v2={true} is_playing={false} />); | ||
expect(screen.getByText('StandalonePlayFillIcon')).toBeInTheDocument(); | ||
}); | ||
|
||
describe('<VideoOverlay />', () => { | ||
it('should render the component', () => { | ||
const { container } = render(<VideoOverlay {...mocked_props} />); | ||
it('should handle modal close', () => { | ||
render(<VideoOverlay {...mockProps} is_v2={true} />); | ||
fireEvent.click(screen.getByText('StandaloneXmarkRegularIcon')); | ||
expect(mockProps.onModalClose).toHaveBeenCalled(); | ||
}); | ||
|
||
expect(container).not.toBeEmptyDOMElement(); | ||
it('should not show play/pause icons when video has ended', () => { | ||
render(<VideoOverlay {...mockProps} is_v2={true} is_ended={true} />); | ||
expect(screen.queryByText('StandalonePlayFillIcon')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('StandalonePauseFillIcon')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should pass correct size to icon for desktop', () => { | ||
render(<VideoOverlay {...mocked_props} />); | ||
it('should handle replay icon click when video has ended', () => { | ||
render(<VideoOverlay {...mockProps} is_ended={true} />); | ||
const replayIcon = screen.getByTestId('dt_player_overlay_icon'); | ||
|
||
expect(screen.getByTestId(icon_testid)).toHaveAttribute('height', '128'); | ||
fireEvent.click(replayIcon); | ||
expect(mockProps.togglePlay).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should pass correct size to icon for mobile', () => { | ||
render(<VideoOverlay {...mocked_props} is_mobile />); | ||
it('should handle replay icon click in mobile view', () => { | ||
render(<VideoOverlay {...mockProps} is_ended={true} is_mobile={true} />); | ||
const replayIcon = screen.getByTestId('dt_player_overlay_icon'); | ||
|
||
expect(screen.getByTestId(icon_testid)).toHaveAttribute('height', '88'); | ||
fireEvent.click(replayIcon); | ||
expect(mockProps.togglePlay).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.