Skip to content

Fix critical bugs and add comprehensive PlayController tests#27

Open
DigitalBlueprint239 wants to merge 1 commit intomasterfrom
claude/fix-coach-core-bugs-xvTCu
Open

Fix critical bugs and add comprehensive PlayController tests#27
DigitalBlueprint239 wants to merge 1 commit intomasterfrom
claude/fix-coach-core-bugs-xvTCu

Conversation

@DigitalBlueprint239
Copy link
Copy Markdown
Owner

Summary

This PR fixes 5 critical bugs that prevented the application from building and running, and adds comprehensive test coverage for the PlayController module. All tests now pass (44/44) and TypeScript compilation succeeds with 0 errors.

Key Changes

Bug Fixes

  • Missing addToOfflineQueue function (src/services/firestore.ts): Added the missing function that was being called 6 times but never defined, causing TypeScript build failures
  • Invalid import path (src/components/SmartPlaybook/components/CanvasArea.tsx): Fixed malformed import path from '../:components:SmartPlaybook:Field.js' to '../Field.js'
  • Auth context mismatch (src/App.tsx): Changed AuthProvider import from anonymous-only context to full email/password/Google auth context to match Dashboard's useAuth hook, preventing runtime crashes
  • Shallow copy bug (src/components/SmartPlaybook/PlayController.js): Fixed route point mutation by changing from shallow array copy [...points] to deep copy points.map(p => ({ ...p }))
  • Test setup failures (src/setupTests.ts, src/App.test.tsx): Added comprehensive Firebase mocks and browser API mocks (matchMedia, Notification) to enable tests to run in JSDOM environment

New Test Coverage

  • Added src/components/SmartPlaybook/PlayController.test.js: 43 comprehensive tests covering:
    • Constants validation (PLAYER_POSITIONS, ROUTE_TYPES, ROUTE_COLORS)
    • Player creation and management (createPlayer, addPlayer, removePlayer, selectPlayer)
    • Route creation and management (createRoute, addRoute, removeRoute)
    • State mutations (updatePlayerPosition, savePlay)
    • Undo/Redo functionality with stack management
    • Formation presets (shotgunFormation, fourThreeFormation)
    • Utility functions (calculateDistance, findPlayerAtPosition, hasDuplicateNumber, hasDuplicatePosition)
    • Immutability verification and error handling

Test Infrastructure

  • Enhanced src/setupTests.ts with Firebase mocks and browser API polyfills
  • Added src/__mocks__/firebase.ts for Firebase module mocking
  • Updated src/App.test.tsx with component-level mocks for PWA and push notifications

Verification

  • ✅ TypeScript: 0 errors (was 6)
  • ✅ Build: Clean production build
  • ✅ Tests: 44/44 passing (was 0/1)
  • ✅ Dev server: Starts without crashes

https://claude.ai/code/session_014M61BgZxsHXT2z8aiC3QMr

…low copy, test setup

- Add missing addToOfflineQueue function in firestore.ts (fixed 6 TS errors and build failure)
- Fix CanvasArea.tsx invalid import path using colons instead of slashes
- Fix AuthProvider context mismatch: App.tsx now uses hooks/useAuth so Dashboard shares the same context
- Fix shallow copy bug in PlayController.createRoute — points are now properly deep-copied
- Add comprehensive test infrastructure: Firebase mocks, browser API mocks, 43 new PlayController tests
- All 44 tests pass, zero TypeScript errors, clean production build

https://claude.ai/code/session_014M61BgZxsHXT2z8aiC3QMr
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 5, 2026

Deploy Preview for magical-starlight-0c1207 failed.

Name Link
🔨 Latest commit 3e8772a
🔍 Latest deploy log https://app.netlify.com/projects/magical-starlight-0c1207/deploys/69a8d3a95cfc440008994dad

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