Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a Vitest + React Testing Library test setup for the client and introduces a game-page refactor that extracts socket/keyboard logic into reusable hooks and components, enabling broader frontend test coverage.
Changes:
- Added Vitest configuration + jsdom test environment and a shared test setup (jest-dom matchers, localStorage mock).
- Added comprehensive client tests covering routes, auth/services, redux store/slice, utilities, and game route integration.
- Refactored the game route to delegate UI/logic into
GamePage,useGameSocket,useKeyboardControls, and supporting UI components/utilities.
Reviewed changes
Copilot reviewed 32 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
server/tests/gameEngine.test.ts |
Removes an eslint-disable comment now covered by global test lint overrides. |
pnpm-lock.yaml |
Adds Vitest/RTL/jsdom dependencies and lock entries. |
eslint.config.mts |
Ignores coverage output and relaxes several strict TS-eslint rules for tests. |
client/vitest.config.ts |
Introduces Vitest config (jsdom env, setup file, coverage settings). |
client/tests/* |
Adds extensive client test suite; removes old placeholder Mocha test. |
client/package.json |
Switches client test/coverage scripts to Vitest; adds Vitest/RTL/jsdom dev deps. |
client/app/utils/pieceHelpers.ts |
Extracts piece shape/color mapping logic for reuse and testability. |
client/app/routes/game.tsx |
Replaces large in-route implementation with GamePage composition. |
client/app/hooks/useKeyboardControls.ts |
Extracts keyboard intent handling into a hook. |
client/app/hooks/useGameSocket.ts |
Extracts socket lifecycle, room actions, and derived game state into a hook. |
client/app/components/game/* |
Adds modular game UI components (board, previews, opponent card, room controls). |
.gitignore |
Updates coverage ignore pattern. |
client/app/welcome/logo-*.svg |
Removes unused SVG assets. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
The tests do not run for me |
Owner
|
…dling and waitFor and suppress console warnings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frontend Tests
Added comprehensive test coverage for the client using Vitest, React Testing Library, and jsdom.
What's covered
GameModeSelector,LoadingOverlay,LoginForm,RegisterForm,ProtectedRoute,PublicOnlyRouteauthService(token management, register, login, logout, getProfile),gamesService(pagination, stats computation)authSlice(sync reducers, async thunks for register/login/logout/fetchProfile), store configurationuseGameSocket(socket lifecycle, room management, game state),useKeyboardControlsgame,home,login,register; full game route integration (board rendering, opponent cards, win/lose detection, restart flow, keyboard controls, host display)pieceHelpers(shape/color building per mode), constants validation, tetromino definitionsTooling changes
vitest.config.tswith jsdom environment and path aliaseslocalStoragemock and@testing-library/jest-dommatchersno-explicit-any,no-unsafe-*) since test mocks commonly need loose typing