Skip to content

Commit

Permalink
[WALL] george / WALL-5105 / Remove the jurisdiction information on co…
Browse files Browse the repository at this point in the history
…mpare account table for wallets (deriv-com#17441)

* fix(wallets): 🚑 remove the jurisdiction information

* refactor(wallets): 🔥 remove unused hardcoded values
  • Loading branch information
heorhi-deriv authored Nov 13, 2024
1 parent bfc9810 commit 0c0815a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

@include mobile-or-tablet-screen {
width: 18rem;
height: 66.6rem;
height: 47rem;

&--eu {
height: fit-content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
.wallets-compare-accounts-text-container {
height: 24.5rem;
height: 8.5rem;

@include mobile-or-tablet-screen {
height: 3rem;
}

&--eu {
height: fit-content;
}

@include mobile-or-tablet-screen {
height: 21rem;
&--eu {
height: fit-content;
&--demo {
height: 11.5rem;

@include mobile-or-tablet-screen {
height: 8rem;
}
}

&--demo {
height: 13.5rem;
}
&__separator {
margin: 0.9rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,6 @@ const CompareAccountsDescription = ({
</Text>
</div>
)}
{!isDemo && !isEuRegion && (
<React.Fragment>
<div className='wallets-compare-accounts-text-container__separator'>
<Text align='center' as='h1' size={isTablet ? 'md' : 'sm'} weight='bold'>
{jurisdictionData.counterparty_company}
</Text>
<Text align='center' as='p' size='2xs'>
{jurisdictionData.counterparty_company_description}
</Text>
</div>
<div className='wallets-compare-accounts-text-container__separator'>
<Text align='center' as='h1' size={isTablet ? 'xs' : 'sm'} weight='bold'>
{jurisdictionData.jurisdiction}
</Text>
<Text align='center' as='p' size='2xs'>
{jurisdictionData.jurisdiction_description}
</Text>
</div>
<div className='wallets-compare-accounts-text-container__separator'>
<Text align='center' as='h1' size={isTablet ? 'xs' : 'sm'} weight='bold'>
{jurisdictionData.regulator}
</Text>
{jurisdictionData.regulator_license && (
<Text align='center' as='p' size='2xs'>
{jurisdictionData.regulator_license}
</Text>
)}
<Text align='center' as='p' size='2xs'>
{jurisdictionData.regulator_description}
</Text>
</div>
</React.Fragment>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('CompareAccountsCard', () => {
expect(screen.getByText('Maximum leverage')).toBeInTheDocument();
expect(screen.getByText('0.5 pips')).toBeInTheDocument();
expect(screen.getByText('Spreads from')).toBeInTheDocument();
expect(screen.getByText('Deriv (SVG) LLC')).toBeInTheDocument();
});

it('renders the new banner for Zero Spread platform', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ jest.mock('../compareAccountsConfig', () => ({

describe('CompareAccountsDescription', () => {
const mockJurisdictionData = {
counterparty_company: 'Deriv (SVG) LLC',
counterparty_company_description: 'Counterparty company description',
jurisdiction: 'St. Vincent & Grenadines',
jurisdiction_description: 'Jurisdiction description',
leverage: 'Up to 1:1000',
leverage_description: 'Leverage description',
regulator: 'Financial Commission',
regulator_description: 'Regulator description',
regulator_license: 'License number',
spread: '0.6 pips',
spread_description: 'Spread description',
};
Expand All @@ -42,10 +35,6 @@ describe('CompareAccountsDescription', () => {
expect(screen.getByText('Leverage description')).toBeInTheDocument();
expect(screen.getByText('0.6 pips')).toBeInTheDocument();
expect(screen.getByText('Spread description')).toBeInTheDocument();
expect(screen.getByText('Deriv (SVG) LLC')).toBeInTheDocument();
expect(screen.getByText('St. Vincent & Grenadines')).toBeInTheDocument();
expect(screen.getByText('Financial Commission')).toBeInTheDocument();
expect(screen.getByText('License number')).toBeInTheDocument();
});

it('renders correct compare accounts descriptions for demo accounts', () => {
Expand All @@ -54,8 +43,6 @@ describe('CompareAccountsDescription', () => {
expect(screen.getByText('Up to 1:1000')).toBeInTheDocument();
expect(screen.getByText('Leverage description')).toBeInTheDocument();
expect(screen.getByText('0.6 pips')).toBeInTheDocument();
expect(screen.queryByText('Deriv (SVG) LLC')).not.toBeInTheDocument();
expect(screen.queryByText('St. Vincent & Grenadines')).not.toBeInTheDocument();
});

it('renders correct compare accounts descriptions for EU region accounts', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { localize } from '@deriv-com/translations';
import { CFD_PLATFORMS, MARKET_TYPE } from '../../../constants';
import {
getAccountVerificationStatus,
getHighlightedIconLabel,
getJurisdictionDescription,
getPlatformType,
isCTraderAccountAdded,
isDxtradeAccountAdded,
isMt5AccountAdded,
shouldRestrictBviAccountCreation,
shouldRestrictVanuatuAccountCreation,
} from '../compareAccountsConfig';
import { JURISDICTION, MARKET_TYPE_SHORTCODE } from '../constants';
import { getHighlightedIconLabel, getPlatformType } from '../compareAccountsConfig';
import { JURISDICTION } from '../constants';

describe('compareAccountsConfig', () => {
describe('getHighlightedIconLabel', () => {
Expand Down Expand Up @@ -73,234 +63,4 @@ describe('compareAccountsConfig', () => {
expect(getPlatformType('unknown')).toBe('OtherCFDs');
});
});

describe('getJurisdictionDescription', () => {
it('returns correct description for synthetic BVI', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.SYNTHETIC_BVI);
expect(result.jurisdiction).toBe('British Virgin Islands');
});

it('returns correct description for financial BVI', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.FINANCIAL_BVI);
expect(result.jurisdiction).toBe('British Virgin Islands');
});

it('returns correct description for synthetic Vanuatu', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.SYNTHETIC_VANUATU);
expect(result.jurisdiction).toBe('Vanuatu');
});

it('returns correct description for financial Vanuatu', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.FINANCIAL_VANUATU);
expect(result.jurisdiction).toBe('Vanuatu');
});

it('returns correct description for financial Labuan', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.FINANCIAL_LABUAN);
expect(result.jurisdiction).toBe('Labuan');
});

it('returns correct description for financial Maltainvest', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.FINANCIAL_MALTAINVEST);
expect(result.jurisdiction).toBe('Malta');
});

it('returns default description for DerivX', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.ALL_DXTRADE);
expect(result).toEqual(
expect.objectContaining({
jurisdiction: 'St. Vincent & Grenadines',
})
);
});

it('returns default description for all SVG', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.ALL_SVG);
expect(result).toEqual(
expect.objectContaining({
jurisdiction: 'St. Vincent & Grenadines',
})
);
});

it('returns default description for synthetic SVG', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.SYNTHETIC_SVG);
expect(result).toEqual(
expect.objectContaining({
jurisdiction: 'St. Vincent & Grenadines',
})
);
});

it('returns default description for financial SVG', () => {
const result = getJurisdictionDescription(localize, MARKET_TYPE_SHORTCODE.FINANCIAL_SVG);
expect(result).toEqual(
expect.objectContaining({
jurisdiction: 'St. Vincent & Grenadines',
})
);
});

it('returns default description for unknown shortcode', () => {
const result = getJurisdictionDescription(localize, 'unknown');
expect(result).toEqual(
expect.objectContaining({
jurisdiction: 'St. Vincent & Grenadines',
})
);
});
});

describe('getAccountVerificationStatus', () => {
it('returns correct status for SVG jurisdiction', () => {
expect(getAccountVerificationStatus(JURISDICTION.SVG, false, false, true)).toBe(true);
});

it('returns correct status for BVI jurisdiction', () => {
const authInfo = {
has_poa_been_attempted: true,
has_poi_been_attempted: true,
identity: { services: { manual: { status: 'verified' } } },
poa_status: 'verified',
risk_classification: 'low',
};
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.BVI, false, false, true, authInfo)).toBe(true);
});

it('returns correct status for high risk classification', () => {
const authInfo = {
has_poa_been_attempted: true,
has_poi_been_attempted: true,
identity: { services: { manual: { status: 'verified' } } },
poa_status: 'verified',
risk_classification: 'high',
};
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.BVI, false, false, true, authInfo)).toBe(false);
});

it('returns correct status for Vanuatu jurisdiction', () => {
const authInfo = {
has_poa_been_attempted: true,
has_poi_been_attempted: true,
identity: { services: { manual: { status: 'verified' } } },
poa_status: 'verified',
risk_classification: 'low',
};
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.VANUATU, false, false, true, authInfo)).toBe(true);
});

it('returns correct status for Labuan jurisdiction', () => {
const authInfo = {
has_poa_been_attempted: true,
has_poi_been_attempted: true,
identity: { services: { manual: { status: 'verified' } } },
poa_status: 'verified',
risk_classification: 'low',
};
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.LABUAN, false, false, true, authInfo)).toBe(true);
});

it('returns correct status for Maltainvest jurisdiction', () => {
const authInfo = {
has_poa_been_attempted: true,
has_poi_been_attempted: true,
identity: { services: { manual: { status: 'verified' } } },
poa_status: 'verified',
};
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.MALTAINVEST, false, false, true, authInfo)).toBe(true);
// @ts-expect-error - since this is a mock, we only need partial properties of authInfo
expect(getAccountVerificationStatus(JURISDICTION.MALTAINVEST, false, false, true, authInfo, true)).toBe(
true
);
});
});

describe('isMt5AccountAdded', () => {
it('returns true if account is added', () => {
const list = [
{
account_type: 'real',
landing_company_short: 'svg',
market_type: MARKET_TYPE.FINANCIAL,
platform: CFD_PLATFORMS.MT5,
},
];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isMt5AccountAdded(list, MARKET_TYPE.FINANCIAL, 'svg')).toBe(true);
});

it('returns false if account is not added', () => {
const list = [
{
account_type: 'real',
landing_company_short: 'svg',
market_type: MARKET_TYPE.FINANCIAL,
platform: CFD_PLATFORMS.MT5,
},
];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isMt5AccountAdded(list, MARKET_TYPE.FINANCIAL, 'svg', true)).toBe(false);
});
});

describe('isDxtradeAccountAdded', () => {
it('returns true if account is added', () => {
const list = [{ account_type: 'real', platform: CFD_PLATFORMS.DXTRADE }];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isDxtradeAccountAdded(list)).toBe(true);
});

it('returns false if account is not added', () => {
const list = [{ account_type: 'real', platform: CFD_PLATFORMS.DXTRADE }];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isDxtradeAccountAdded(list, true)).toBe(false);
});
});

describe('isCTraderAccountAdded', () => {
it('returns true if account is added', () => {
const list = [{ account_type: 'real', platform: CFD_PLATFORMS.CTRADER }];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isCTraderAccountAdded(list)).toBe(true);
});

it('returns false if account is not added', () => {
const list = [{ account_type: 'real', platform: CFD_PLATFORMS.CTRADER }];
// @ts-expect-error - since this is a mock, we only need partial properties of the list
expect(isCTraderAccountAdded(list, true)).toBe(false);
});
});

describe('shouldRestrictBviAccountCreation', () => {
it('returns true if BVI account creation should be restricted', () => {
const accounts = [{ landing_company_short: 'bvi', status: 'poa_failed' }];
// @ts-expect-error - since this is a mock, we only need partial properties of the accounts
expect(shouldRestrictBviAccountCreation(accounts)).toBe(true);
});

it('returns false if BVI account creation should not be restricted', () => {
const accounts = [{ landing_company_short: 'bvi', status: 'active' }];
// @ts-expect-error - since this is a mock, we only need partial properties of the accounts
expect(shouldRestrictBviAccountCreation(accounts)).toBe(false);
});
});

describe('shouldRestrictVanuatuAccountCreation', () => {
it('returns true if Vanuatu account creation should be restricted', () => {
const accounts = [{ landing_company_short: 'vanuatu', status: 'poa_failed' }];
// @ts-expect-error - since this is a mock, we only need partial properties of the accounts
expect(shouldRestrictVanuatuAccountCreation(accounts)).toBe(true);
});

it('returns false if Vanuatu account creation should not be restricted', () => {
const accounts = [{ landing_company_short: 'vanuatu', status: 'active' }];
// @ts-expect-error - since this is a mock, we only need partial properties of the accounts
expect(shouldRestrictVanuatuAccountCreation(accounts)).toBe(false);
});
});
});
Loading

0 comments on commit 0c0815a

Please sign in to comment.