-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEQ] P2P-V2 My Profile balance test #13398
Merged
farrah-deriv
merged 41 commits into
binary-com:master
from
adrienne-deriv:p2p-v2-my-profile-balance-test
Feb 7, 2024
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
16d8abd
chore: removed responsive root
adrienne-deriv 65d8aec
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 8c91e7b
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv b5027cb
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 79a6f21
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 7956e94
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv e2d06d0
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 4783835
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv a64e58f
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 1200577
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 0e70ed5
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv f11377b
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 07bf6e5
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 2e25182
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 0d432e7
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv bacb384
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 89f0f91
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv b5a3745
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 93526fa
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 56744da
chore: reverted old changes
adrienne-deriv eb60b51
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv f2eb3ba
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv c90d747
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv a1ab9d8
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 18030ec
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 1c1fdea
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 7e1de5c
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv cbf6c35
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv aa4223d
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv d9e0e7e
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 97addbc
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv b750467
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv eca7237
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 09782fc
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 62f504d
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv e869a75
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv f39bbae
Merge branch 'master' of github.com:binary-com/deriv-app
adrienne-deriv 0cf479f
chore: added tests for profile balance
adrienne-deriv 4652051
Merge branch 'master' of github.com:binary-com/deriv-app into p2p-v2-…
adrienne-deriv ef734d9
Update MyProfileBalance.spec.tsx
adrienne-deriv 137c6a5
Update MyProfileBalance.spec.tsx
adrienne-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
123 changes: 123 additions & 0 deletions
123
.../p2p-v2/src/pages/my-profile/screens/MyProfileBalance/__tests__/MyProfileBalance.spec.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import React from 'react'; | ||
import { APIProvider } from '@deriv/api'; | ||
import { render, screen, within } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import MyProfileBalance from '../MyProfileBalance'; | ||
|
||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<APIProvider> | ||
<div id='v2_modal_root' /> | ||
{children} | ||
</APIProvider> | ||
); | ||
|
||
let mockUseAdvertiserStats = { | ||
data: { | ||
balance_available: 50000, | ||
daily_buy_limit: 500, | ||
daily_sell_limit: 500, | ||
dailyAvailableBuyLimit: 10, | ||
dailyAvailableSellLimit: 10, | ||
fullName: 'Jane Doe', | ||
isEligibleForLimitUpgrade: false, | ||
name: 'Jane', | ||
show_name: 0, | ||
}, | ||
isLoading: false, | ||
}; | ||
const mockUseActiveAccount = { | ||
data: { | ||
currency: 'USD', | ||
}, | ||
isLoading: false, | ||
}; | ||
|
||
jest.mock('@/hooks', () => ({ | ||
...jest.requireActual('@/hooks'), | ||
useAdvertiserStats: jest.fn(() => mockUseAdvertiserStats), | ||
})); | ||
|
||
jest.mock('@deriv/api', () => ({ | ||
...jest.requireActual('@deriv/api'), | ||
useActiveAccount: jest.fn(() => mockUseActiveAccount), | ||
})); | ||
|
||
describe('MyProfileBalance', () => { | ||
it('should render the correct balance', () => { | ||
render(<MyProfileBalance />, { wrapper }); | ||
const availableBalanceNode = screen.getByTestId('dt_p2p_v2_available_balance_amount'); | ||
expect(within(availableBalanceNode).getByText('50,000.00 USD')).toBeInTheDocument(); | ||
|
||
const balanceInfoIcon = screen.getByTestId('dt_p2p_v2_available_balance_icon'); | ||
userEvent.click(balanceInfoIcon); | ||
expect(screen.getByTestId('dt_p2p_v2_available_p2p_balance_modal')).toBeInTheDocument(); | ||
const okButton = screen.getByRole('button', { | ||
name: 'Ok', | ||
}); | ||
userEvent.click(okButton); | ||
expect(screen.queryByTestId('dt_p2p_v2_available_p2p_balance_modal')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the correct limits', () => { | ||
mockUseAdvertiserStats = { | ||
data: { | ||
...mockUseAdvertiserStats.data, | ||
daily_buy_limit: 500, | ||
daily_sell_limit: 2000, | ||
dailyAvailableBuyLimit: 100, | ||
dailyAvailableSellLimit: 600, | ||
}, | ||
isLoading: false, | ||
}; | ||
render(<MyProfileBalance />, { wrapper }); | ||
const dailyBuyLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_daily_buy_limit'); | ||
expect(within(dailyBuyLimitNode).getByText('500 USD')).toBeInTheDocument(); | ||
const availableBuyLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_available_buy_limit'); | ||
expect(within(availableBuyLimitNode).getByText('100.00 USD')).toBeInTheDocument(); | ||
|
||
const dailySellLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_daily_sell_limit'); | ||
expect(within(dailySellLimitNode).getByText('2000 USD')).toBeInTheDocument(); | ||
const dailyAvailableSellLimit = screen.getByTestId('dt_p2p_v2_profile_balance_available_sell_limit'); | ||
expect(within(dailyAvailableSellLimit).getByText('600.00 USD')).toBeInTheDocument(); | ||
}); | ||
it('should render eligibility for daily limit upgrade', () => { | ||
mockUseAdvertiserStats = { | ||
data: { | ||
...mockUseAdvertiserStats.data, | ||
isEligibleForLimitUpgrade: true, | ||
}, | ||
isLoading: false, | ||
}; | ||
render(<MyProfileBalance />, { wrapper }); | ||
expect(screen.getByTestId('dt_p2p_v2_profile_daily_limit')).toBeInTheDocument(); | ||
|
||
const openDailyLimitModalBtn = screen.getByRole('button', { | ||
name: 'Increase my limits', | ||
}); | ||
userEvent.click(openDailyLimitModalBtn); | ||
const hideDailyLimitBtn = screen.getByRole('button', { | ||
name: 'No', | ||
}); | ||
userEvent.click(hideDailyLimitBtn); | ||
expect(screen.queryByTestId('dt_p2p_v2_daily_limit_modal')).not.toBeInTheDocument(); | ||
}); | ||
it('should render the correct default values', () => { | ||
mockUseAdvertiserStats = { | ||
// @ts-expect-error To clear the mocked values and assert the default values | ||
data: {}, | ||
isLoading: false, | ||
}; | ||
render(<MyProfileBalance />, { wrapper }); | ||
const availableBalanceNode = screen.getByTestId('dt_p2p_v2_available_balance_amount'); | ||
expect(within(availableBalanceNode).getByText('0.00 USD')).toBeInTheDocument(); | ||
const dailyBuyLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_daily_buy_limit'); | ||
expect(within(dailyBuyLimitNode).getByText('0.00 USD')).toBeInTheDocument(); | ||
const availableBuyLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_available_buy_limit'); | ||
expect(within(availableBuyLimitNode).getByText('0.00 USD')).toBeInTheDocument(); | ||
|
||
const dailySellLimitNode = screen.getByTestId('dt_p2p_v2_profile_balance_daily_sell_limit'); | ||
expect(within(dailySellLimitNode).getByText('0.00 USD')).toBeInTheDocument(); | ||
const dailyAvailableSellLimit = screen.getByTestId('dt_p2p_v2_profile_balance_available_sell_limit'); | ||
expect(within(dailyAvailableSellLimit).getByText('0.00 USD')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this modal as it was already included in
<MyProfileDailyLimit />