Skip to content

TEST-006: Vitest unit tests for all 9 React components (~100% coverage)#9

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/test-react-components
Draft

TEST-006: Vitest unit tests for all 9 React components (~100% coverage)#9
Copilot wants to merge 2 commits intomainfrom
copilot/test-react-components

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

No test infrastructure existed for the frontend. This adds a full Vitest + Testing Library setup covering all 9 components in src/components/.

Test infrastructure

  • Dependencies: vitest, @vitest/coverage-v8, @testing-library/react, @testing-library/jest-dom, @testing-library/user-event, jsdom
  • Config: Vitest wired into vite.config.ts (jsdom env, v8 coverage scoped to src/components/)
  • Scripts: npm test · npm run test:watch · npm run test:coverage
  • Setup: src/test/setup.ts imports @testing-library/jest-dom matchers

Test files (147 tests total, all passing)

File Tests Key scenarios
PlayerCard.test.tsx 21 position badge colors, optional fields, click handler
TeamCard.test.tsx 18 conference badge colors, logo, showStats, click handler
GameCard.test.tsx 26 status badge colors, scores, winner highlight, logos + onError, click handler
PlayerList.test.tsx 14 loading/error/empty states, search + position filters
TeamList.test.tsx 14 loading/error/empty states, conference filter, grouping headers
GameList.test.tsx 16 loading/error/empty states, status/team filters, date grouping, sort order
StatCard.test.tsx 23 value formatting (decimal/percent/integer/default), trend arrows, PlayerStatsGrid optional stats
Layout.test.tsx 5 children rendering, footer, semantic roles
Navigation.test.tsx 10 nav links, active state highlighting per route, hrefs

Coverage

All files  | 100% Stmts | 99.44% Branch | 100% Funcs | 100% Lines

The single uncovered branch (TeamList.tsx:76team.conference \|\| 'Unknown') is dead code: teams are pre-filtered to 'East'/'West' before reaching the groupBy reducer, making the fallback unreachable in practice.

Original prompt

TEST-006: Write unit tests for React components

Work Item Details

Note: Please focus on the descriptions and information that provide context about the task requirements, functionality, and implementation details. Dates, priorities, and administrative metadata are less relevant for coding tasks.

Description

Unit Tests for React Components

Test 9 components in frontend/src/components/ using Vitest + Testing Library.

Components

  • PlayerCard.tsx (85 lines): renders player name, position badge (color-coded PG/SG/SF/PF/C), jersey number, height/weight/college; click handler fires
  • TeamCard.tsx: renders team name, logo, conference, division
  • GameCard.tsx: renders home/away teams, scores, date, status
  • PlayerList.tsx: renders list of PlayerCards, loading state, empty state
  • TeamList.tsx: renders list of TeamCards
  • GameList.tsx: renders list of GameCards with date grouping
  • StatCard.tsx: renders stat label + value
  • Layout.tsx: renders header, navigation, children content
  • Navigation.tsx: renders nav links, active state highlighting

Work item: AB#1734
Created via Azure DevOps


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…, ~100% coverage)

Co-authored-by: edinc <4791281+edinc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for React components using Vitest TEST-006: Vitest unit tests for all 9 React components (~100% coverage) Mar 10, 2026
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