forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WALL] Farhan/WALL-3060/POI Icon variation in MT5 Derived & Financial…
… does not match Figma (deriv-com#12694) * fix: 🔧 poi verification not same as design * fix: 🔧 change test cases statements
- Loading branch information
1 parent
ce324a6
commit 88cd7df
Showing
10 changed files
with
246 additions
and
8 deletions.
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
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
173 changes: 173 additions & 0 deletions
173
...allets/src/features/cfd/screens/Jurisdiction/hooks/__tests__/useVerificationDocs.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,173 @@ | ||
import { usePOI, useResidenceList } from '@deriv/api'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import useVerificationDocs from '../useVerificationDocs'; | ||
|
||
jest.mock('@deriv/api', () => ({ | ||
usePOI: jest.fn(), | ||
useResidenceList: jest.fn(), | ||
})); | ||
|
||
const mockUsePOI = usePOI as jest.MockedFunction<typeof usePOI>; | ||
const mockUseResidenceList = useResidenceList as jest.MockedFunction<typeof useResidenceList>; | ||
|
||
describe('useVerificationDocs', () => { | ||
it('should return onfido/manual verification docs for idv unsupported country', () => { | ||
mockUsePOI.mockReturnValue({ | ||
// @ts-expect-error need a way to mock useQuery data | ||
data: { | ||
current: { | ||
country_code: 'id', | ||
service: 'onfido', | ||
status: 'none', | ||
}, | ||
services: { | ||
onfido: { | ||
submissions_left: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
mockUseResidenceList.mockReturnValue( | ||
// @ts-expect-error need a way to mock useQuery data | ||
{ | ||
data: [ | ||
{ | ||
identity: { | ||
services: { | ||
idv: { | ||
is_country_supported: 0, | ||
}, | ||
}, | ||
}, | ||
value: 'id', | ||
}, | ||
], | ||
} | ||
); | ||
const { result } = renderHook(() => useVerificationDocs('bvi')); | ||
expect(result.current).toEqual({ | ||
financial: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
synthetic: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
}); | ||
}); | ||
|
||
it('should return idv verification docs for idv supported country and client has idv attempts left', () => { | ||
mockUsePOI.mockReturnValue({ | ||
// @ts-expect-error need a way to mock useQuery data | ||
data: { | ||
current: { | ||
country_code: 'co', | ||
service: 'idv', | ||
status: 'none', | ||
}, | ||
services: { | ||
idv: { | ||
submissions_left: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
mockUseResidenceList.mockReturnValue( | ||
// @ts-expect-error need a way to mock useQuery data | ||
{ | ||
data: [ | ||
{ | ||
identity: { | ||
services: { | ||
idv: { | ||
is_country_supported: 1, | ||
}, | ||
}, | ||
}, | ||
value: 'co', | ||
}, | ||
], | ||
} | ||
); | ||
const { result } = renderHook(() => useVerificationDocs('bvi')); | ||
expect(result.current).toEqual({ | ||
financial: ['documentNumber', 'nameAndAddress'], | ||
synthetic: ['documentNumber', 'nameAndAddress'], | ||
}); | ||
}); | ||
|
||
it('should return onfido/manual verification docs for idv supported country with no attempts left', () => { | ||
mockUsePOI.mockReturnValue({ | ||
// @ts-expect-error need a way to mock useQuery data | ||
data: { | ||
current: { | ||
country_code: 'co', | ||
service: 'idv', | ||
status: 'none', | ||
}, | ||
services: { | ||
idv: { | ||
submissions_left: 0, | ||
}, | ||
}, | ||
}, | ||
}); | ||
mockUseResidenceList.mockReturnValue( | ||
// @ts-expect-error need a way to mock useQuery data | ||
{ | ||
data: [ | ||
{ | ||
identity: { | ||
services: { | ||
idv: { | ||
is_country_supported: 1, | ||
}, | ||
}, | ||
}, | ||
value: 'co', | ||
}, | ||
], | ||
} | ||
); | ||
const { result } = renderHook(() => useVerificationDocs('bvi')); | ||
expect(result.current).toEqual({ | ||
financial: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
synthetic: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
}); | ||
}); | ||
|
||
it('should return verification docs for unregulated jurisdiction', () => { | ||
mockUsePOI.mockReturnValue({ | ||
// @ts-expect-error need a way to mock useQuery data | ||
data: { | ||
current: { | ||
country_code: 'co', | ||
service: 'idv', | ||
status: 'none', | ||
}, | ||
services: { | ||
idv: { | ||
submissions_left: 0, | ||
}, | ||
}, | ||
}, | ||
}); | ||
mockUseResidenceList.mockReturnValue( | ||
// @ts-expect-error need a way to mock useQuery data | ||
{ | ||
data: [ | ||
{ | ||
identity: { | ||
services: { | ||
idv: { | ||
is_country_supported: 1, | ||
}, | ||
}, | ||
}, | ||
value: 'co', | ||
}, | ||
], | ||
} | ||
); | ||
const { result } = renderHook(() => useVerificationDocs('svg')); | ||
expect(result.current).toEqual({ | ||
financial: ['notApplicable'], | ||
synthetic: ['notApplicable'], | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/wallets/src/features/cfd/screens/Jurisdiction/hooks/useVerificationDocs.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,39 @@ | ||
import { useMemo } from 'react'; | ||
import { usePOI, useResidenceList } from '@deriv/api'; | ||
import { JURISDICTION } from '../../../constants'; | ||
import { getJurisdictionContents } from '../jurisdiction-contents/jurisdiction-contents'; | ||
|
||
type TJurisdictionContent = ReturnType<typeof getJurisdictionContents>; | ||
type TVerificationDocument = TJurisdictionContent[keyof TJurisdictionContent]['verificationDocs']; | ||
|
||
const useVerificationDocs = (jurisdiction: string): TVerificationDocument => { | ||
const { data } = usePOI(); | ||
const { data: residenceList } = useResidenceList(); | ||
const { verificationDocs } = getJurisdictionContents()[jurisdiction]; | ||
const isIDVSupported = useMemo( | ||
() => | ||
residenceList.find(residence => residence.value === data?.current?.country_code)?.identity?.services?.idv | ||
?.is_country_supported, | ||
[data, residenceList] | ||
); | ||
const hasIDVAttempts = useMemo(() => (data?.services?.idv?.submissions_left ?? 0) > 0, [data]); | ||
const isNonIDV = useMemo( | ||
() => (isIDVSupported !== undefined && !isIDVSupported) || (isIDVSupported && !hasIDVAttempts), | ||
[hasIDVAttempts, isIDVSupported] | ||
); | ||
|
||
const modifiedVerificationDocs: TVerificationDocument = useMemo(() => { | ||
const jurisdictionToCheck: string[] = [JURISDICTION.BVI, JURISDICTION.LABUAN, JURISDICTION.VANUATU]; | ||
if (jurisdictionToCheck.includes(jurisdiction) && isNonIDV) { | ||
return { | ||
financial: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
synthetic: ['selfie', 'identityDocument', 'nameAndAddress'], | ||
}; | ||
} | ||
return verificationDocs; | ||
}, [isNonIDV, jurisdiction, verificationDocs]); | ||
|
||
return modifiedVerificationDocs; | ||
}; | ||
|
||
export default useVerificationDocs; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes