Skip to content
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

[WALL] aum / WALL-[4916 / 4925] / wallets-implement-default-jurisdiction-flows #16867

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
80791d8
feat: added created modal and added DocumentTile component
aum-deriv Sep 17, 2024
d19ae44
feat: added DocumentsList component
aum-deriv Sep 17, 2024
5711c04
refactor: useSortedMT5Accounts to get default jurisdiction accounts
aum-deriv Sep 19, 2024
ba9a266
feat: created MT5LicenceNumber component
aum-deriv Sep 23, 2024
7c995a6
refactor: MT5 password related components to include info for the MT5…
aum-deriv Sep 24, 2024
f791d85
feat: added getClientVerification util
aum-deriv Sep 24, 2024
05672f4
fix: some UI issues
aum-deriv Sep 25, 2024
b14a41f
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 25, 2024
eeadf6f
chore: bump deriv-com/ui from 1.35.0 to 1.35.2
aum-deriv Sep 26, 2024
28cc9cb
feat: added ClientVerificationStatusBadge component
aum-deriv Sep 26, 2024
4150c15
feat: updated usage of badge in DocumentList component
aum-deriv Sep 26, 2024
b5ee6fb
fix: temporary hardcoding of compnay number for non-regulated in MT5L…
aum-deriv Sep 26, 2024
9764b39
refactor: converted getTileProps function to tileProps map in Documen…
aum-deriv Sep 26, 2024
64877a4
fix: refer to correct key for poa and translation for DocumentTile in…
aum-deriv Sep 26, 2024
f17c21c
fix: logic for getClientVerification util
aum-deriv Sep 27, 2024
19f6847
refactor: DocumentList to use getClientVerification
aum-deriv Sep 27, 2024
af5e65a
chore: added unit tests for MT5LicenceMessage and DocumentList component
aum-deriv Sep 27, 2024
d1c1780
refactor: renamed and moved CFDPasswordModalTnc to screens/components…
aum-deriv Sep 27, 2024
b3a54fe
fix: unit tests for MT5PasswordModalTnc
aum-deriv Sep 27, 2024
6f3bd5f
fix: added temporary types for default service
aum-deriv Sep 27, 2024
73b3a29
fix: unit tests for AvailableMT5AccountsList
aum-deriv Sep 28, 2024
c8496a0
chore: added unit tests for EnterPassword component
aum-deriv Sep 28, 2024
0495076
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 28, 2024
3addfe5
fix: sonarcloud issue
aum-deriv Sep 28, 2024
54f5700
fix: the build CI
aum-deriv Sep 28, 2024
1cbbc95
fix: unit test for DocumentsList
aum-deriv Sep 28, 2024
faf80eb
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 30, 2024
70739a3
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 30, 2024
882890c
fix: added missing localize for getMarketTypeDetails
aum-deriv Sep 30, 2024
721e868
refactor: MT5 account filtering and sorting for displaying on traders…
aum-deriv Oct 1, 2024
4731362
chore: applied suggestions
aum-deriv Oct 2, 2024
b1b2bc9
fix: warning for dependency array in MT5AccountAdded
aum-deriv Oct 2, 2024
087c59e
fix: applied comments
aum-deriv Oct 2, 2024
cb88f05
feat: created AddedMT5AccountStatusBadge
aum-deriv Oct 2, 2024
e1dbd58
refactor: AddedMt5AccountsList for default jurisdiction changes
aum-deriv Oct 3, 2024
362c0f7
fix: remove unwanted status checks for added MT5 accounts
aum-deriv Oct 4, 2024
f116417
fix: description width in desktop for ClientVerificationModal
aum-deriv Oct 4, 2024
c50da18
fix: correct check for showing the ClientVerificationModal for pre-ac…
aum-deriv Oct 4, 2024
9d72727
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 4, 2024
59309d2
fix: MT5 account added success screen not showing for first time acco…
aum-deriv Oct 4, 2024
99c9f13
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 4, 2024
29c06eb
fix: add end margin to status badge for AddedMT5AccountsList
aum-deriv Oct 4, 2024
51775fe
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 7, 2024
dd2e8c2
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 7, 2024
ad009f9
perf: added unit test for useSortedMT5Accounts hook
aum-deriv Oct 7, 2024
d325697
refactor: unit tests for AddedMT5AccountsList
aum-deriv Oct 8, 2024
7d9c040
perf: added unit tests for useAddedMT5Accounts
aum-deriv Oct 8, 2024
ffab734
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 9, 2024
d020314
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 9, 2024
0b1f396
Merge pull request #13 from aum-deriv/aum/WALL-4925/default-jurisdict…
aum-deriv Oct 9, 2024
df7ce18
fix: ci error for ordering constants
aum-deriv Oct 9, 2024
3dcb470
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 14, 2024
73837e1
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 15, 2024
1951f61
feat: show the ClientVerificationModal only on the click of the badge…
aum-deriv Oct 15, 2024
d517bd1
fix: updated mt5 accounts sorting order with stp to show multiple acc…
aum-deriv Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@deriv-com/analytics": "1.14.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/utils": "^0.0.34",
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/api": "^1.0.0",
"@deriv-com/quill-ui": "1.16.20",
"@deriv/components": "^1.0.0",
Expand Down
312 changes: 312 additions & 0 deletions packages/api-v2/src/hooks/__tests__/useSortedMT5Accounts.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
import { renderHook } from '@testing-library/react-hooks';
import useActiveAccount from '../useActiveAccount';
import useAvailableMT5Accounts from '../useAvailableMT5Accounts';
import useIsEuRegion from '../useIsEuRegion';
import useMT5AccountsList from '../useMT5AccountsList';
import useSortedMT5Accounts from '../useSortedMT5Accounts';
import { cleanup } from '@testing-library/react';

jest.mock('../useActiveAccount', () => jest.fn());
jest.mock('../useAvailableMT5Accounts', () => jest.fn());
jest.mock('../useIsEuRegion', () => jest.fn());
jest.mock('../useMT5AccountsList', () => jest.fn());

const mockMT5NonEUAvailableAccounts = [
{
is_default_jurisdiction: 'false',
product: 'standard',
shortcode: 'svg',
},
{
is_default_jurisdiction: 'false',
product: 'financial',
shortcode: 'svg',
},
{
is_default_jurisdiction: 'true',
product: 'financial',
shortcode: 'vanuatu',
},
{
is_default_jurisdiction: 'true',
product: 'stp',
shortcode: 'vanuatu',
},
{
is_default_jurisdiction: 'true',
product: 'standard',
shortcode: 'vanuatu',
},
{
is_default_jurisdiction: 'true',
product: 'zero_spread',
shortcode: 'bvi',
},
{
is_default_jurisdiction: 'true',
product: 'swap_free',
shortcode: 'svg',
},
];

const mockMT5NonEUAddedAccounts = [
{
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'standard',
},
{
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'financial',
},
{
is_virtual: false,
landing_company_short: 'bvi',
product: 'zero_spread',
},
];

const mockMT5EUAvailableAccounts = [
{
is_default_jurisdiction: 'true',
product: 'financial',
shortcode: 'maltainvest',
},
];

const mockMT5EUAddedAccounts = [
{
is_virtual: false,
landing_company_short: 'maltainvest',
product: 'financial',
},
];

describe('useSortedMT5Accounts', () => {
beforeEach(() => {
(useActiveAccount as jest.Mock).mockReturnValue({
data: { is_virtual: false },
});
(useIsEuRegion as jest.Mock).mockReturnValue({
isEUCountry: false,
});
});
afterEach(cleanup);

it('returns non-eu available accounts with default jurisdiction', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5NonEUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: [],
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).toEqual([
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'standard',
shortcode: 'vanuatu',
},
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'financial',
shortcode: 'vanuatu',
},
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'swap_free',
shortcode: 'svg',
},
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'zero_spread',
shortcode: 'bvi',
},
]);
});

it('returns eu available accounts with default jurisdiction', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5EUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: [],
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).toEqual([
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'financial',
shortcode: 'maltainvest',
},
]);
});

it('returns list of non-eu added and available accounts after some accounts are created', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5NonEUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: mockMT5NonEUAddedAccounts,
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).toEqual([
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'standard',
shortcode: 'vanuatu',
},
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'financial',
shortcode: 'vanuatu',
},
{
is_added: false,
is_default_jurisdiction: 'true',
product: 'swap_free',
shortcode: 'svg',
},
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'bvi',
product: 'zero_spread',
shortcode: 'bvi',
},
]);
});

it('returns list of eu added and available accounts after some accounts are created', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5EUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: mockMT5EUAddedAccounts,
});
(useIsEuRegion as jest.Mock).mockReturnValue({
isEUCountry: true,
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).toEqual([
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'maltainvest',
product: 'financial',
shortcode: 'maltainvest',
},
]);
});

it('returns sorted non-eu accounts list in the correct order', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5NonEUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: [],
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data?.map(account => account.product)).toStrictEqual([
'standard',
'financial',
'swap_free',
'zero_spread',
]);
});

it('filters-out available MT5 financial stp account disabling clients to create it', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5NonEUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: [],
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).not.toContain({
is_added: false,
is_default_jurisdiction: 'true',
product: 'stp',
shortcode: 'vanuatu',
});
});

it('all available MT5 accounts are created', () => {
(useAvailableMT5Accounts as jest.Mock).mockReturnValue({
data: mockMT5NonEUAvailableAccounts,
});
(useMT5AccountsList as jest.Mock).mockReturnValue({
data: [
...mockMT5NonEUAddedAccounts,
{
is_virtual: false,
landing_company_short: 'svg',
product: 'swap_free',
},
],
});

const { result } = renderHook(() => useSortedMT5Accounts());

expect(result.current.data).toEqual([
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'standard',
shortcode: 'vanuatu',
},
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'vanuatu',
product: 'financial',
shortcode: 'vanuatu',
},
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'svg',
product: 'swap_free',
shortcode: 'svg',
},
{
is_added: true,
is_default_jurisdiction: 'true',
is_virtual: false,
landing_company_short: 'bvi',
product: 'zero_spread',
shortcode: 'bvi',
},
]);
});
});
Loading
Loading