Conversation
- Set up Vitest with React Testing Library and jsdom - Created test suites for all major components (Auth, Navigation, Dashboard, Teams, Players, Bouts, ConfigurationError) - Added comprehensive mocking for Supabase client and authentication - Configured test scripts for coverage and UI testing - Added proper TypeScript integration and ESLint compliance - Implemented test setup with mock data and environment isolation Test coverage includes: - Authentication flows (sign in, sign up, sign out) - Error handling and boundary components - Navigation and user interactions - Component rendering and basic functionality - Form validation and submission flows
- Add comprehensive infrastructure tests for core components - Fix all failing Players component tests (31 tests now passing) - Add new test files for Auth, App, Header, ErrorBoundary, and utilities - Enhance existing test suites for Bouts and Teams components - Update test setup with improved mocking infrastructure - Add coverage reporting and documentation - Achieve 80%+ coverage target across all major components Key improvements: - Players.tsx: 60.57% → 89.71% coverage - All 122 tests now passing with 0 failures - Robust test suite covering CRUD operations, validation, and error handling
- Extract common Supabase mock implementations into reusable factory functions - createMockAuth(): Centralizes auth mock creation - createMockFrom(): Centralizes database query mock creation - createMockSupabaseClient(): Combines auth and from mocks - Eliminates duplication between supabase and requireSupabase mocks - Remove duplicate test cases to improve test suite quality - Remove duplicate 'validates required fields' test in Players.test.tsx - Remove duplicate 'validates form inputs properly' test in Bouts.test.tsx - Reduces test count from 122 to 120 while maintaining coverage - Improve test maintainability and reduce code complexity - All tests continue to pass with improved codebase quality
… factory functions Address PR feedback by eliminating magic numbers and duplicate values in test data: - Add comprehensive test data constants (TEST_IDS, TEST_NUMBERS, TEST_DATES, TEST_NAMES, etc.) - Create typed factory functions for generating mock data: - createMockTeam(): Generate team data with roster - createMockPlayer(): Generate player data with team assignments - createMockPlayerTeamAssignment(): Generate team assignment data - createMockBout(): Generate bout data with team references - createMockBoutTeam(): Generate bout team data - Replace hardcoded values: - Remove duplicate '100' between preferred_number and team assignment number - Replace magic IDs like '1', '2', '3' with named constants (TEST_IDS.PLAYER_1, etc.) - Centralize auth data (user IDs, emails, URLs) in TEST_AUTH constants - Use consistent date formats through TEST_DATES constants - Add proper TypeScript types: - MockPlayerTeamAssignment type for team assignment structure - MockBoutTeam type for bout team references - Remove 'any' types in favor of specific interfaces - Improve maintainability: - Single source of truth for all test data values - Easy to modify test scenarios by changing constants - Consistent data relationships across all mock objects - Better readability and understanding of test data structure All 120 tests continue to pass with improved code quality and maintainability.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace recursive self-reference with stateful query chain simulation - Add proper filtering with support for eq, neq, gt, lt operators - Implement sorting with ascending/descending options - Add field selection and limit functionality - Track query state through chain operations for realistic behavior - Fix test selector for bout cancellation to handle multiple buttons - Maintain type safety with proper error handling Addresses PR feedback about simplistic query mock implementation
…nsights - Replace complex TEST_* object constants with simple individual constants - Simplify factory functions (createTeam, createPlayer) for better readability - Eliminate hardcoded magic numbers and duplicate values in test setup - Add @vercel/speed-insights package and integrate SpeedInsights component - Maintain all 119 passing tests while improving code maintainability - Clean up test data structure for easier maintenance and debugging Changes include: - Refactored src/test/setup.ts with simplified constants and factory functions - Updated package.json with @vercel/speed-insights dependency - Integrated SpeedInsights component in App.tsx - All existing functionality preserved with improved code quality
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove complex ChainableQuery interface that had mismatched method signatures - Use any type for createChainableQuery return to maintain flexibility in test mocks - Fix select method parameter type from string[] to optional string to match implementation - Maintain all 119 passing tests while resolving build errors - Keep test functionality intact with simplified typing approach
- Remove global useAuth mock from setup.ts that could cause conflicts between tests - Individual test files (App.test.tsx, Header.test.tsx) already have proper local mocks - Add createMockAuthState utility function for consistent auth mock configurations - Improve test isolation by allowing each test to configure auth state independently - Maintain all 119 passing tests with better test architecture - Follow best practices for mock management in test suites Benefits: - Tests can now configure different auth states without conflicts - Better test isolation and predictability - Utility function provides consistent auth mock creation - Individual test files maintain full control over their auth mock behavior
- Document current 87.15% statement coverage across 119 passing tests - Detail coverage breakdown by directory and component - Highlight excellent coverage in Auth, Header, Navigation components (100%) - Identify improvement areas in Bouts.tsx (83.24%) and Teams.tsx (81.15%) - Document recent infrastructure improvements (mock isolation, constants refactoring) - Provide actionable next steps for increasing coverage in critical areas - Include detailed quality assessment and testing strengths/weaknesses - Show progression from initial failing tests to robust test suite
- Replace __dirname with fileURLToPath(new URL('.', import.meta.url))
- Add import for fileURLToPath from 'url' module
- Resolve ES module deprecation warning in vitest.config.ts
- Maintain all 119 passing tests with proper setup file resolution
- Follow modern ES module best practices for Node.js compatibility
Fixed additional semi colon
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Update vitest config with pool: 'forks' and isolate: true - Add jsdom environment polyfills for missing globals - Mock browser APIs (currentScript, confirm) for better test isolation - Suppress Vercel Analytics console errors in test environment - Update GitHub Actions to use Node.js 20 with VM modules support - Add NODE_OPTIONS and FORCE_COLOR environment variables for CI - Create local CI testing script for debugging workflow issues - Remove Codecov upload to avoid secret dependency Fixes the webidl-conversions 'Cannot read properties of undefined' errors that were causing test failures in GitHub Actions CI environment.
- Convert require() to import syntax for Node.js ES module compatibility - Fix 'require is not defined in ES module scope' error - Local CI simulation script now works properly
- Replace jsdom with happy-dom test environment for better stability - Add happy-dom dependency for lighter, more reliable browser simulation - Update vitest config to use happy-dom environment - Enhance GitHub Actions with better debugging and environment variables - Add memory optimization and telemetry disabling for CI - Remove jsdom-specific polyfills, add happy-dom compatible ones - Improve test performance (6s vs 13s+ previously) This resolves the persistent webidl-conversions compatibility issues that were causing CI failures with jsdom in GitHub Actions.
- Document happy-dom migration rationale and benefits - Explain CI/CD pipeline configuration and workflows - Provide troubleshooting guide for common issues - Include performance metrics and coverage targets - Add future improvement roadmap for testing infrastructure
- Fix 'Cannot find package text' error by removing invalid --reporter=text - Move coverage reporter configuration to vitest.config.ts - Use built-in 'text', 'lcov', and 'html' reporters in config - Simplify test:coverage script to just 'vitest run --coverage' - Add proper coverage exclusions for test files and configs - Add CI status checking script for monitoring workflows All 119 tests pass with 81.7% coverage. CI pipeline should now work correctly without reporter module errors.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Updated quality-gate.yml to use Node.js 22 - Updated ci.yml to use Node.js 22 - Updated test-before-deploy.yml to use Node.js 22 - Updated check-ci-status.js documentation to reflect Node.js 22 This ensures consistent Node.js runtime across all CI/CD workflows, eliminating potential version-related issues and providing predictable behavior in the continuous integration environment.
- Replace non-existent 'vercel/action@v2' with 'amondnet/vercel-action@v25' - Update both production and preview deployment jobs - Change 'args' parameter to 'vercel-args' as required by amondnet/vercel-action This resolves the 'repository not found' error in GitHub Actions when trying to use the Vercel deployment action.
- Remove --prebuilt flag that requires .vercel/output directory structure - Let Vercel handle the build process directly from source code - Simplify deployment jobs by removing build artifact dependencies - Remove unnecessary download and verification steps - Keep production deployment with --prod flag for main branch - Preview deployment for dev branch uses default Vercel behavior This resolves the 'no prebuilt output found in .vercel/output' error by letting Vercel build the project using its standard process.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add missing 'npm run test' step that was accidentally removed - Fix YAML indentation for build job (was incorrectly nested) - Ensure proper job separation with blank lines This should resolve workflow parsing errors and ensure tests run before deployment.
- Reorder workflow steps for better logical flow - Move test coverage after build step - Add continue-on-error flag for coverage step - Ensure clean YAML formatting without syntax errors This resolves the GitHub Actions YAML parsing error on line 35.
- Restore simple vercel-action configuration - Remove complex Vercel CLI setup that was causing issues - Keep the working pattern that was successful before This should restore preview deployment functionality to the dev branch.
- Add condition to deploy preview for PRs from dev branch - Use github.event.pull_request.head.ref == 'dev' for PR events - Keep existing github.ref == 'refs/heads/dev' for direct pushes - This ensures preview deployments work for both push and PR workflows Resolves issue where deploy-preview job was being skipped on PRs.
🏁 Major Features Added: - Live stat tracking during roller derby bouts with real-time updates - Position-specific rules enforcement (blockers can't score, position-based stats) - Comprehensive bout score integration with batched updates - End bout functionality with detailed summary page 📊 Live Stat Tracking Components: - PlayerStatCard: Individual player stat management with position-aware controls - LiveBoutHeader: Bout header with jam controls, timer, and end bout button - JamLineupSelector: Team lineup selection for each jam - StatButton: Reusable stat increment/decrement controls 🎮 Game Rules Implementation: - Position-based scoring restrictions (blockers show blocks/assists instead of points) - Pivot star passing functionality with visual indicators - Automatic jam timer (2 minutes) with manual end jam capability - Lead jammer tracking and penalty management 💾 Database Integration: - Bout score updates batched at jam end to prevent UI spinners during gameplay - Real-time player stat persistence with upsert operations for duplicate handling - Bout status management (in_progress → completed) - Comprehensive player statistics tracking (jams, points, blocks, assists, penalties) 🎨 UI/UX Improvements: - Compact player cards designed to fit 5 players per team on screen - Inline player info layout (number, name, position on same line) - Quick stats display with 4 key metrics per player - Position-colored badges and indicators - Responsive design for various screen sizes 📈 Bout Summary & Reporting: - Complete bout summary page showing final scores and winner - Detailed player statistics for all participants - Team-organized player performance breakdown - Navigation options for new bout or return to bout list 🔧 Technical Implementation: - React TypeScript components with proper type safety - Supabase integration for real-time data persistence - State management for live gameplay with jam-specific point tracking - CSS Grid and Flexbox layouts for optimal space utilization - Error handling and loading states throughout the application This implementation provides a complete solution for live roller derby bout tracking with professional-grade features for officials and scorekeepers.
🔄 Navigation Improvements: - Replace window.location.reload() with proper state-based navigation - Add onNavigateBack prop to LiveStatTracker component - Add onBackToBouts prop to BoutSummary component - Implement handleNavigateBackToBouts in App component ✨ User Experience Benefits: - Eliminates jarring full page reloads when completing bouts - Provides smooth transitions back to bout selection - Maintains application state during navigation - Improves overall app performance and responsiveness 🔧 Technical Changes: - Proper component prop drilling for navigation callbacks - Clean state reset without page reload - Consistent navigation pattern throughout the app - Better separation of concerns between components
feat: Complete live derby stat tracking system with bout management
📁 Database Organization: - Create dedicated database/ folder for SQL scripts - Move Supabase performance fixes to organized location - Add comprehensive README documentation 🚀 Performance Optimizations: - RLS policy fixes for all tables (22 warnings resolved) - Foreign key indexing for better query performance (4 warnings resolved) - Composite indexes for common query patterns 📋 Supabase Fixes Included: - Teams table: RLS policies + foreign key references - Players table: RLS policies - Player_teams table: RLS policies + team_id indexing - Bouts table: RLS policies + team foreign key indexing - Player_stats table: RLS policies + bout_id indexing 💡 Usage Instructions: - Copy SQL content to Supabase SQL Editor - Scripts are idempotent (safe to run multiple times) - Maintains security while dramatically improving performance - Optimized for live derby stat tracking workloads
Added tests for new functionality
There was a problem hiding this comment.
Pull Request Overview
This PR introduces live stat tracking functionality for roller derby bouts, adding real-time statistics management with comprehensive test coverage. The implementation includes position-specific rule enforcement, bout management integration, and a complete testing infrastructure using Vitest and happy-dom.
Key Changes
- Live stat tracking system with jam-by-jam management and real-time player statistics
- Comprehensive test suite (119 tests, 87.15% coverage) with CI/CD pipeline integration
- Database performance optimizations for RLS policies and foreign key indexing
Reviewed Changes
Copilot reviewed 49 out of 52 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/LiveStatTracker.tsx | Core live tracking component with bout management |
| src/components/PlayerStatCard.tsx | Interactive player stat cards with position-aware controls |
| src/components/JamLineupSelector.tsx | Lineup selection interface for jam management |
| src/components/LiveBoutHeader.tsx | Bout header with timer and jam controls |
| src/components/BoutSummary.tsx | Post-bout summary with detailed statistics |
| src/components/StatButton.tsx | Reusable stat increment/decrement controls |
| src/App.tsx | Integration of live tracking with navigation flow |
| src/components/Bouts.tsx | Added live tracking launch capability |
| src/components/Navigation.tsx | Added live track navigation option |
| vitest.config.ts | Test configuration using happy-dom environment |
| src/test/setup.ts | Comprehensive test setup with Supabase mocks |
| package.json | Test dependencies and script additions |
Comments suppressed due to low confidence (1)
src/components/Bouts.tsx:167
- The date parsing logic assumes the date format contains 'T'. Consider using a more robust date parsing approach like
new Date(bout.bout_date).toISOString().split('T')[0]to handle edge cases and ensure consistent formatting.
bout_date: bout.bout_date.split('T')[0], // Convert to date input format
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/components/Bouts.tsx:167
- The date parsing logic assumes the bout_date always contains a 'T' character, but this could fail if the date format is different. Consider using
new Date(bout.bout_date).toISOString().split('T')[0]for more robust date handling.
bout_date: bout.bout_date.split('T')[0], // Convert to date input format
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/components/LiveBoutHeader.tsx:1
- Duplicate CSS definitions for
.jam-numberand.jam-timer. The first definitions at lines 63-66 and 68-75 should be removed to avoid conflicting styles.
import React, { useState, useEffect } from 'react'
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
🏁 Major Features Added:
📊 Live Stat Tracking Components:
🎮 Game Rules Implementation:
💾 Database Integration:
🎨 UI/UX Improvements:
📈 Bout Summary & Reporting:
🔧 Technical Implementation:
This implementation provides a barebones solution for live roller derby bout tracking.