Skip to content

Commit

Permalink
[WALL] Farhan/WALL-3097/WALL-3100/MT5 Account created modal (pending …
Browse files Browse the repository at this point in the history
…verification) (#12765)

* chore: ✨ show pending verification message upon mt5 account verification with pending poi and poa

* fix: 🔧 failing tests

* fix: 🔧 tradershub error
  • Loading branch information
farhan-nurzi-deriv committed Jan 8, 2024
1 parent 736616c commit a6787c2
Show file tree
Hide file tree
Showing 13 changed files with 653 additions and 238 deletions.
199 changes: 132 additions & 67 deletions packages/api/src/__tests__/useJurisdictionStatus.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ describe('useJurisdictionStatus', () => {
is_idv_revoked: false,
},
});
const { result } = renderHook(() => useJurisdictionStatus('bvi', 'proof_failed'), { wrapper });
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('bvi', 'proof_failed');
expect(data.is_failed).toBe(true);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);

expect(result.current.data.is_failed).toBe(true);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(false);

const { result: labuanResult } = renderHook(() => useJurisdictionStatus('labuan', 'proof_failed'), { wrapper });

expect(labuanResult.current.data.is_failed).toBe(true);
expect(labuanResult.current.data.is_not_applicable).toBe(false);
expect(labuanResult.current.data.is_pending).toBe(false);
const labuanData = result.current.getVerificationStatus('labuan', 'proof_failed');
expect(labuanData.is_failed).toBe(true);
expect(labuanData.is_not_applicable).toBe(false);
expect(labuanData.is_pending).toBe(false);
});
test('for BVI/Labuan, should have a pending verification status if MT5 account status is currently pending verification and IDV status is pending', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
Expand All @@ -67,19 +66,18 @@ describe('useJurisdictionStatus', () => {
is_idv_revoked: false,
},
});
const { result } = renderHook(() => useJurisdictionStatus('bvi', 'verification_pending'), { wrapper });
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('bvi', 'verification_pending');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(true);
expect(data.is_verified).toBe(false);

expect(result.current.data.is_failed).toBe(false);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(true);

const { result: labuanResult } = renderHook(() => useJurisdictionStatus('labuan', 'verification_pending'), {
wrapper,
});

expect(labuanResult.current.data.is_failed).toBe(false);
expect(labuanResult.current.data.is_not_applicable).toBe(false);
expect(labuanResult.current.data.is_pending).toBe(true);
const labuanData = result.current.getVerificationStatus('labuan', 'verification_pending');
expect(labuanData.is_failed).toBe(false);
expect(labuanData.is_not_applicable).toBe(false);
expect(labuanData.is_pending).toBe(true);
expect(data.is_verified).toBe(false);
});
test('for BVI/Labuan, should have a pending verification status if IDV attempts failed and the next compatible service Onfido is pending', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
Expand All @@ -105,19 +103,18 @@ describe('useJurisdictionStatus', () => {
},
},
});
const { result } = renderHook(() => useJurisdictionStatus('bvi', 'verification_pending'), { wrapper });

expect(result.current.data.is_failed).toBe(false);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(true);

const { result: labuanResult } = renderHook(() => useJurisdictionStatus('labuan', 'verification_pending'), {
wrapper,
});
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('bvi', 'verification_pending');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(true);
expect(data.is_verified).toBe(false);

expect(labuanResult.current.data.is_failed).toBe(false);
expect(labuanResult.current.data.is_not_applicable).toBe(false);
expect(labuanResult.current.data.is_pending).toBe(true);
const labuanData = result.current.getVerificationStatus('labuan', 'verification_pending');
expect(labuanData.is_failed).toBe(false);
expect(labuanData.is_not_applicable).toBe(false);
expect(labuanData.is_pending).toBe(true);
expect(data.is_verified).toBe(false);
});
test('for BVI/Labuan, should have a failed verification status if IDV is revoked', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
Expand All @@ -140,20 +137,55 @@ describe('useJurisdictionStatus', () => {
is_idv_revoked: true,
},
});
const { result } = renderHook(() => useJurisdictionStatus('bvi', 'verification_pending'), { wrapper });
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('bvi', 'verification_pending');
expect(data.is_failed).toBe(true);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(false);

expect(result.current.data.is_failed).toBe(true);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(false);
const labuanData = result.current.getVerificationStatus('labuan', 'verification_pending');
expect(labuanData.is_failed).toBe(true);
expect(labuanData.is_not_applicable).toBe(false);
expect(labuanData.is_pending).toBe(false);
expect(data.is_verified).toBe(false);
});

const { result: labuanResult } = renderHook(() => useJurisdictionStatus('labuan', 'verification_pending'), {
wrapper,
test('for BVI/Labuan, should have a verified verification status if IDV is verified', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
mockUsePOI.mockReturnValue({
data: {
services: {
idv: {
status: 'verified',
},
},
// @ts-expect-error This is just for mocking, we just need to mock some properties only
current: {
service: 'idv',
},
},
});
mockUseAuthentication.mockReturnValue({
// @ts-expect-error This is just for mocking, we just need to mock some properties only
data: {
is_idv_revoked: false,
},
});
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('bvi', 'verified');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(true);

expect(labuanResult.current.data.is_failed).toBe(true);
expect(labuanResult.current.data.is_not_applicable).toBe(false);
expect(labuanResult.current.data.is_pending).toBe(false);
const labuanData = result.current.getVerificationStatus('labuan', 'verified');
expect(labuanData.is_failed).toBe(false);
expect(labuanData.is_not_applicable).toBe(false);
expect(labuanData.is_pending).toBe(false);
expect(data.is_verified).toBe(true);
});

test('for Labuan, should have a failed verification status if is_authenticated_with_idv_photoid is present in account status', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
mockUsePOI.mockReturnValue({
Expand All @@ -175,11 +207,12 @@ describe('useJurisdictionStatus', () => {
is_authenticated_with_idv_photoid: true,
},
});
const { result } = renderHook(() => useJurisdictionStatus('labuan', 'verification_pending'), { wrapper });

expect(result.current.data.is_failed).toBe(true);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(false);
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('labuan', 'verification_pending');
expect(data.is_failed).toBe(true);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(false);
});
test('for SVG, status should not be applicable', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
Expand All @@ -202,37 +235,69 @@ describe('useJurisdictionStatus', () => {
is_idv_revoked: true,
},
});
const { result } = renderHook(() => useJurisdictionStatus('svg', 'verification_pending'), { wrapper });

expect(result.current.data.is_failed).toBe(false);
expect(result.current.data.is_not_applicable).toBe(true);
expect(result.current.data.is_pending).toBe(false);
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('svg', 'verification_pending');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(true);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(false);
});
test('for Vanuatu, status should be failed if MT5 account status is proof_failed', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;

const { result } = renderHook(() => useJurisdictionStatus('vanuatu', 'proof_failed'), { wrapper });

expect(result.current.data.is_failed).toBe(true);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(false);
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('vanuatu', 'proof_failed');
expect(data.is_failed).toBe(true);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
});
test('for Vanuatu, status should be pending if MT5 account status is verification_pending', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;

const { result } = renderHook(() => useJurisdictionStatus('vanuatu', 'verification_pending'), { wrapper });

expect(result.current.data.is_failed).toBe(false);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(true);
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('vanuatu', 'verification_pending');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(true);
expect(data.is_verified).toBe(false);
});
test('for Vanuatu, status should not be failed/pending if MT5 account status is not equal to proof_failed or verification_pending', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;

const { result } = renderHook(() => useJurisdictionStatus('vanuatu', ''), { wrapper });
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('vanuatu', 'none');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(false);
});

expect(result.current.data.is_failed).toBe(false);
expect(result.current.data.is_not_applicable).toBe(false);
expect(result.current.data.is_pending).toBe(false);
test('for Vanuatu, should have a verified verification status if IDV is verified', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
mockUsePOI.mockReturnValue({
data: {
services: {
idv: {
status: 'verified',
},
},
// @ts-expect-error This is just for mocking, we just need to mock some properties only
current: {
service: 'idv',
},
},
});
mockUseAuthentication.mockReturnValue({
// @ts-expect-error This is just for mocking, we just need to mock some properties only
data: {
is_idv_revoked: false,
},
});
const { result } = renderHook(() => useJurisdictionStatus(), { wrapper });
const data = result.current.getVerificationStatus('vanuatu', 'verified');
expect(data.is_failed).toBe(false);
expect(data.is_not_applicable).toBe(false);
expect(data.is_pending).toBe(false);
expect(data.is_verified).toBe(true);
});
});
Loading

1 comment on commit a6787c2

@vercel
Copy link

@vercel vercel bot commented on a6787c2 Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.vercel.app
binary.sx
deriv-app.binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.