Repository navigation
Feat/add extreme price impact tests - #1031
Merged
k-deejah merged 2 commits intoOct 21, 2026
Merged
Conversation
added 2 commits
October 21, 2026 19:29
…in SwapSimulator.test.tsx - Added test suite for extreme price impact scenarios: * Tests for price impact > 15% warning banner * Tests for price impact > 50% critical error state * Verified color coding for low (< 1%), medium (1-5%), and high (> 5%) impact * Tests for high slippage warning with extreme price impact - Added comprehensive custom poolReserves property tests: * Verify custom poolReserves configuration is accepted and used * Test default POOL_RESERVES fallback behavior * Validate correct exchange rate calculation with custom reserves * Test liquidity size multiplier application to custom reserves * Handle empty/missing custom poolReserves gracefully * Test price impact curve rendering with custom reserves * Verify asset pair mapping in custom poolReserves - Added debounced chart calculation tests using fake timers (vi.useFakeTimers): * Test debounce on rapid input changes (300ms delay) * Verify previous debounce timer cancellation on new input * Test debounce applied to chart but not immediate exchange rate updates * Verify chart recalculation correctness after debounce with custom reserves * Test debounced value used in price impact curve SVG rendering * Verify cleanup of debounce timeout on component unmount * Test custom AMOUNT_CHART_DEBOUNCE_MS timing accuracy * Handle zero and negative input values with debounce * Verify correct price impact curve points after debounce with varying amounts All tests follow AAA (Arrange-Act-Assert) pattern and use descriptive names. Acceptance criteria fully met with comprehensive coverage.
…in SwapSimulator.test.tsx - Added test suite for extreme price impact scenarios: * Tests for price impact > 15% warning banner * Tests for price impact > 50% critical error state * Verified color coding for low (< 1%), medium (1-5%), and high (> 5%) impact * Tests for high slippage warning with extreme price impact - Added comprehensive custom poolReserves property tests: * Verify custom poolReserves configuration is accepted and used * Test default POOL_RESERVES fallback behavior * Validate correct exchange rate calculation with custom reserves * Test liquidity size multiplier application to custom reserves * Handle empty/missing custom poolReserves gracefully * Test price impact curve rendering with custom reserves * Verify asset pair mapping in custom poolReserves - Added debounced chart calculation tests using fake timers (vi.useFakeTimers): * Test debounce on rapid input changes (300ms delay) * Verify previous debounce timer cancellation on new input * Test debounce applied to chart but not immediate exchange rate updates * Verify chart recalculation correctness after debounce with custom reserves * Test debounced value used in price impact curve SVG rendering * Verify cleanup of debounce timeout on component unmount * Test custom AMOUNT_CHART_DEBOUNCE_MS timing accuracy * Handle zero and negative input values with debounce * Verify correct price impact curve points after debounce with varying amounts Addresses Sorokit#927 - Extreme price impact and custom reserve tests
|
@Ceejaytech25 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Add Extreme Price Impact and Custom Reserve Tests in SwapSimulator.test.tsx
Description
This PR adds comprehensive test coverage for Issue #927, implementing three test suites with 20 new test cases to the
SwapSimulatorcomponent. The implementation includes testing for extreme price impact scenarios, custom pool reserves configuration, and debounced chart recalculations using fake timers.What Changed
Overview
src/components/SwapSimulator.test.tsxTest Suites Implemented
1. Extreme Price Impact Scenarios (5 tests)
Tests for high and critical price impact warnings and color coding:
displays high price impact warning banner when impact exceeds 15%
shows critical error banner when price impact exceeds 50%
shows correct color coding for low price impact (< 1%)
shows correct color coding for medium price impact (1-5%)
shows critical red banner when slippage is exceeded with extreme impact
2. Custom PoolReserves Props (7 tests)
Tests for custom liquidity pool configuration handling:
accepts and uses custom poolReserves configuration
uses default POOL_RESERVES when custom poolReserves is not provided
calculates correct exchange rate with custom poolReserves
applies liquidity size multiplier correctly to custom poolReserves
handles empty or missing custom poolReserves gracefully
correctly renders price impact curve with custom poolReserves
respects asset pair mapping in custom poolReserves
3. Debounced Chart Calculations with Fake Timers (9 tests)
Tests for debounced chart recalculation using
vi.useFakeTimers():debounces price impact chart recalculation on rapid input changes
cancels previous debounce timer when new input is received before debounce completes
applies debounce to chart recalculation but not to immediate exchange rate updates
recalculates chart correctly after debounce with custom poolReserves
uses debounced value for price impact curve SVG rendering
clears debounce timeout on component unmount
respects custom AMOUNT_CHART_DEBOUNCE_MS timing
handles zero and negative input values with debounce
emits correct price impact curve points after debounce with varying amounts
Acceptance Criteria Met
✅ High and critical price impact warnings are tested
✅ Custom poolReserves props are verified
✅ Debounced SVG chart recalculations are verified with fake timers
vi.useFakeTimers()Technical Implementation
Testing Techniques
vi.useFakeTimers()/vi.advanceTimersByTime()render(),fireEvent,screenqueriesCode Quality
Testing
All tests can be run with:
Closes #927
Closes #926
Closes #925
Closes #924