Frontend School

Paginated Test Run History

Machine Coding
medium

Paginated Test Run History

Medium
React
TypeScript
Pagination
UI Development
State Management

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:

  1. Display Test Runs: Render a list of test run items based on the current page and selected items per page.
  2. Implement Pagination Logic: Manage the state for the current page and the number of items displayed per page.
  3. Navigation Controls: Provide 'Previous' and 'Next' buttons to navigate through pages.
  4. 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).
  5. 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.

Constraints

Constraints & assumptions

  • All data for test runs (MOCK_TEST_RUNS) is provided in App.tsx and should be treated as a static array. No external API calls are required.
  • The pagination should be implemented purely client-side using React state and hooks.
  • The ITEMS_PER_PAGE_OPTIONS array defines the available choices for items per page. The component should use the first value in this array as the default.
  • Focus on functional correctness and clean code. Pixel-perfect design is not required, but basic usability and readability are expected.
  • You should use React functional components and hooks.

Out of scope

  • Server-side pagination or actual API integration.
  • Advanced features like sorting, filtering, or searching the test runs.
  • Complex UI component libraries (e.g., Material UI, Ant Design) – stick to basic HTML elements and CSS.
  • Deep accessibility testing beyond basic disabled states for buttons.

What interviewers evaluate

  • Correctness and robustness of the client-side pagination logic.
  • Effective use of React state management (useState, useMemo, useCallback) for performance and maintainability.
  • Clean, modular, and readable component structure.
  • Adherence to all specified UI/UX and acceptance criteria.

Loading editor...