-
Notifications
You must be signed in to change notification settings - Fork 2
test: add tests for ArchivedShowView #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| @@ -1,50 +1,50 @@ | |||
| export const Event = { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These all make more sense as enums (that's what they are in React Native Track Player itself) and allows us to type things better in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive test coverage for the ArchivedShowView component, including tests for rendering, skip buttons, and boundary conditions. The PR also refactors the track player mock to use TypeScript enums for better type safety and improves the test API ergonomics.
- Adds new test suite for
ArchivedShowViewwith skip forward/backward functionality and edge case handling - Refactors track player mock from const objects to enums for
Event,Capability, andState - Improves test API by exporting
testApidirectly and implementingseekTomock behavior - Adds accessibility labels to play/pause button in
ArchivedShowView - Extracts playback button label and icon to
useMemohooks for better performance
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
__tests__/ArchivedShowView.test.tsx |
New test file covering rendering, skip buttons, and boundary conditions for seeking |
__mocks__/react-native-track-player.ts |
Converts mock to use enums, exports testApi directly, and implements seekTo with position tracking |
__mocks__/MockShows.ts |
New mock data file with realistic show structure for testing |
src/utils/TestUtils.tsx |
Updates to access testApi directly instead of through __testApi property |
src/app/Schedule/ArchivedShowView.tsx |
Adds accessibility label and extracts button rendering to useMemo hooks |
__tests__/PlayButton.test.tsx |
Refactored to use getTrackPlayerTestApi for cleaner test setup |
jest.setup.ts |
Adds mock for useHeaderHeight from @react-navigation/elements |
| describe('ArchivedShowView', () => { | ||
| test('renders ArchivedShowView', async () => { | ||
| await renderAsync(<ArchivedShowView />, { wrapper: TestWrapper }); | ||
|
|
||
| expect(screen.getByText(mockShow.name)).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('renders skip forward and back', async () => { | ||
| const user = userEvent.setup(); | ||
|
|
||
| await renderAsync(<ArchivedShowView />, { wrapper: TestWrapper }); | ||
|
|
||
| await user.press(await screen.findByLabelText('Play')); | ||
|
|
||
| expect( | ||
| await screen.findByLabelText(`Skip backward ${SKIP_INTERVAL} seconds`), | ||
| ).toBeTruthy(); | ||
|
|
||
| expect( | ||
| await screen.findByLabelText(`Skip forward ${SKIP_INTERVAL} seconds`), | ||
| ).toBeTruthy(); | ||
| }); |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should verify that the button toggles between "Play" and "Pause" labels based on playback state. The component has playbackButtonLabel logic that changes the accessibility label between "Play" and "Pause", but there's no test coverage for this toggle behavior. Consider adding a test that:
- Sets the playback state to
State.PlayingusingsetPlaybackState - Renders the component
- Verifies the button shows "Pause" label
- Presses the button to pause
- Verifies the button shows "Play" label again
No description provided.