test: increase code coverage to >80% #61
Draft
+802
−110
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.
This PR increases the project's test coverage to meet the >80% target. It introduces new unit tests for several critical and complex components that were previously under-tested.
Key Changes
src/hooks/__tests__/useGamification.test.tsx: Tests created for the gamification hook, validating XP calculation, achievement unlocking, and data persistence (localStorage/Firestore).src/context/__tests__/MascotContext.test.tsx: Tests added for the mascot context, verifying mood updates and message handling.src/components/game/questionTypes/__tests__/FillCodeQuestion.test.tsx: Tests added for the code editor component, mockingusePyodideto simulate code execution results (success, failure, errors).src/components/layout/__tests__/Header.test.tsx: Tests added for the global header, checking auth state rendering (guest vs user), navigation, and dynamic avatar display.src/components/mascot/__tests__/Mascot.test.tsx: Tests added for the Mascot UI component, verifying auto-hide logic and mood rendering.Impact
Technical Notes
localStoragemocking was implemented carefully usingObject.definePropertywith restoration inafterEachto avoid side effects on other tests (fixing a potentialReferenceErrorinuseOfflinetests).PR created automatically by Jules for task 5405353165200331866 started by @albertoivo