Add PriceChart component tests for mount and series updates - #385
Open
Benedict315 wants to merge 10 commits into
Open
Add PriceChart component tests for mount and series updates#385Benedict315 wants to merge 10 commits into
Benedict315 wants to merge 10 commits into
Conversation
|
@jotel-dev is attempting to deploy a commit to the josephchimebuka's projects Team on Vercel. A member of the Team first needs to authorize it. |
…act Hooks violations
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.
Created comprehensive test suite for PriceChart.test.tsx with 20 passing tests covering:
Test Suites:
Mount and Unmount (4 tests): Verifies component mounts without canvas dependency failures, proper cleanup on unmount, ref clearing, and requestAnimationFrame cancellation
Series Updates (3 tests): Tests price data fetching on mount, empty data handling, and series creation with chart
Subscribe/Unsubscribe Behavior (4 tests): Validates socket price update subscriptions/unsubscriptions and window resize event listener management
Offline Badge Behavior (4 tests): Confirms LIVE/OFFLINE badge display and ConnectionStatus component visibility based on connection state
Error Handling (2 tests): Tests API error handling and loading state display
Chart Configuration (3 tests): Verifies chart creation with correct configuration, line series options, and custom height prop usage
Key Implementation:
Mocked lightweight-charts library to avoid real canvas dependencies
Mocked api-client, socket service, and useConnectionStatus hook
Implemented synchronous requestAnimationFrame mock for immediate execution
All cleanup assertions verify proper resource disposal on unmount
Acceptance Criteria Met:
✓ No real canvas dependency failures
✓ Cleanup on unmount asserted
✓ Subscribe/unsubscribe behavior tested
✓ Offline badge behavior tested
Closes #333