Skip to content

Conversation

@jsit
Copy link
Member

@jsit jsit commented Nov 22, 2025

No description provided.

@jsit jsit requested a review from a team as a code owner November 22, 2025 18:41
@@ -1,50 +1,50 @@
export const Event = {
Copy link
Member Author

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.

Copy link
Contributor

Copilot AI left a 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 ArchivedShowView with skip forward/backward functionality and edge case handling
  • Refactors track player mock from const objects to enums for Event, Capability, and State
  • Improves test API by exporting testApi directly and implementing seekTo mock behavior
  • Adds accessibility labels to play/pause button in ArchivedShowView
  • Extracts playback button label and icon to useMemo hooks 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

Comment on lines +27 to +48
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();
});
Copy link

Copilot AI Dec 6, 2025

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:

  1. Sets the playback state to State.Playing using setPlaybackState
  2. Renders the component
  3. Verifies the button shows "Pause" label
  4. Presses the button to pause
  5. Verifies the button shows "Play" label again

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants