Overview
As a Browserstack user, navigating through a large number of past test runs can be cumbersome. To improve the user experience and performance, we need a robust pagination component for the 'Test Run History' page. This problem focuses on building a client-side pagination system that allows users to efficiently browse through their test results.
What you need to do / Task
Your primary goal is to implement a React component that displays a paginated list of mock test run data. Specifically, you must:
- Display Test Runs: Render a list of test run items based on the current page and selected items per page.
- Implement Pagination Logic: Manage the state for the current page and the number of items displayed per page.
- Navigation Controls: Provide 'Previous' and 'Next' buttons to navigate through pages.
- Items Per Page Selector: Include a dropdown (select element) to allow users to change how many test runs are displayed per page (e.g., 5, 10, 20).
- Page Information Display: Show the current page number and the total number of pages.
UI/UX expectations
- The list of test runs should be clearly visible, with each item displaying its name, status, device, duration, and timestamp.
- Pagination controls should be intuitively placed, typically below the list of test runs.
- The 'Previous' and 'Next' buttons should be clearly distinguishable and indicate their disabled state when appropriate (e.g., on the first or last page).
- The 'Items per page' selector should be easy to find and use.
- Basic styling for statuses (e.g., Passed, Failed) should be applied for better readability.
Acceptance criteria
- On initial load, the component displays the first page of test runs with the default items per page setting.
- Clicking the 'Next' button correctly navigates to the subsequent page, if available.
- Clicking the 'Previous' button correctly navigates to the prior page, if available.
- The 'Previous' button is disabled when on the first page.
- The 'Next' button is disabled when on the last page.
- Changing the value in the 'Items per page' selector updates the displayed list, recalculates the total number of pages, and resets the current page to 1.
- The displayed page number and total page count accurately reflect the current state.
- Each test run item is rendered with its details and status styling.