Skip to content

Commit

Permalink
feat(TokenEnterAmount): add new flow to EarnEnterAmount.tsx (#6246)
Browse files Browse the repository at this point in the history
### Description
4/5 PR for new Enter Amount component. This PR uses the new component
and hook on Earn flow.

### Test plan

<video
src="https://github.com/user-attachments/assets/23fc0e59-8b04-4d98-ba1d-77ba55baf1a0"
width="500"></video>



### Related issues

- Relates to RET-1208
### Backwards compatibility
Yes

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [x] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
  • Loading branch information
sviderock authored Dec 16, 2024
1 parent 7eb98ed commit 8ee6df3
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 381 deletions.
16 changes: 6 additions & 10 deletions src/earn/EarnEnterAmount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import AppAnalytics from 'src/analytics/AppAnalytics'
import { EarnEvents } from 'src/analytics/Events'
import EarnEnterAmount from 'src/earn/EarnEnterAmount'
import { usePrepareEnterAmountTransactionsCallback } from 'src/earn/hooks'
import { Status as EarnStatus } from 'src/earn/slice'
import { CICOFlow } from 'src/fiatExchanges/types'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
Expand Down Expand Up @@ -35,7 +36,6 @@ import {
mockTokenBalances,
mockUSDCAddress,
} from 'test/values'
import { Status as EarnStatus } from 'src/earn/slice'

jest.mock('src/earn/hooks')
jest.mock('react-native-localize')
Expand Down Expand Up @@ -501,13 +501,6 @@ describe('EarnEnterAmount', () => {

await waitFor(() => expect(getByText('earnFlow.enterAmount.continue')).not.toBeDisabled())

expect(getByTestId('EarnEnterAmount/Withdraw/Crypto')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Withdraw/Crypto')).toHaveTextContent('11.00 USDC')

expect(getByTestId('EarnEnterAmount/Withdraw/Fiat')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Withdraw/Fiat')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Withdraw/Fiat')).toHaveTextContent('₱14.63')

expect(getByTestId('EarnEnterAmount/Fees')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Fees')).toHaveTextContent('₱0.012')

Expand Down Expand Up @@ -725,9 +718,9 @@ describe('EarnEnterAmount', () => {

fireEvent.press(within(getByTestId('EarnEnterAmount/AmountOptions')).getByText('maxSymbol'))
expect(getByTestId('EarnEnterAmount/TokenAmountInput').props.value).toBe(
replaceSeparators('100000.42')
replaceSeparators('100,000.42')
)
expect(getByTestId('EarnEnterAmount/LocalAmountInput').props.value).toBe(
expect(getByTestId('EarnEnterAmount/ExchangeAmount')).toHaveTextContent(
replaceSeparators('₱133,000.56')
)
})
Expand Down Expand Up @@ -788,6 +781,7 @@ describe('EarnEnterAmount', () => {
</Provider>
)

fireEvent.changeText(getByTestId('EarnEnterAmount/TokenAmountInput'), '1')
fireEvent.press(getByTestId('LabelWithInfo/FeeLabel'))
expect(getByText('earnFlow.enterAmount.feeBottomSheet.feeDetails')).toBeVisible()
expect(getByTestId('EstNetworkFee/Value')).toBeTruthy()
Expand All @@ -813,6 +807,7 @@ describe('EarnEnterAmount', () => {
</Provider>
)

fireEvent.changeText(getByTestId('EarnEnterAmount/TokenAmountInput'), '1')
fireEvent.press(getByTestId('LabelWithInfo/FeeLabel'))
expect(getByText('earnFlow.enterAmount.feeBottomSheet.feeDetails')).toBeVisible()
expect(getByTestId('EstNetworkFee/Value')).toBeTruthy()
Expand Down Expand Up @@ -844,6 +839,7 @@ describe('EarnEnterAmount', () => {
</Provider>
)

fireEvent.changeText(getByTestId('EarnEnterAmount/TokenAmountInput'), '1')
fireEvent.press(getByTestId('LabelWithInfo/SwapLabel'))
expect(getByText('earnFlow.enterAmount.swapBottomSheet.swapDetails')).toBeVisible()
expect(getByTestId('SwapTo')).toBeTruthy()
Expand Down
Loading

0 comments on commit 8ee6df3

Please sign in to comment.