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

Amina/feature/90115/update jurisdiction #25

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4ba0537
Ako/ Distinguish dd staging logs (#8569)
ali-hosseini-deriv May 11, 2023
62bd456
Bala/Update messages in stale workflow (#8567)
balakrishna-deriv May 11, 2023
a966981
translations: 📚 sync translations with crowdin (#8572)
github-actions[bot] May 11, 2023
9466612
bahar/88933/feat: doughflow_dark_theme (#7925)
May 12, 2023
f3e4479
maryia/dtra-82/fix: stake value for non-eng languages (#8458)
maryia-deriv May 12, 2023
8315871
fix: redirect to traders hub by default on login (#8183)
jim-deriv May 12, 2023
2cb2fe0
Hamza/90782/useless tooltip deal cancellation (#7958)
hamza-deriv May 12, 2023
3bc96cb
chore: fix error rules delay on amount (#8206)
aizad-deriv May 12, 2023
96b5578
chore: added a wrapper for the logo in traders hub and scss styles (#…
aizad-deriv May 12, 2023
c6c3896
Ameerul /Task 77336 Error model content required when user tries to b…
ameerul-deriv May 12, 2023
5a34450
Sergei / 90221 / set right tab account for derivX when choose account…
sergei-deriv May 12, 2023
1b973f4
chore: add test coverage for demo account card (#8413)
thisyahlen-deriv May 12, 2023
5893b81
test: evgeniy/ 91704/ language settings radio button test coverage (#…
yauheni-deriv May 12, 2023
1f539fb
chore: prevent closing signup flow modal on external link click (#8497)
shahzaib-deriv May 12, 2023
7b393eb
fix: disabled buttons until chat url is updated (#8371)
nada-deriv May 12, 2023
8f5ac5a
thisyahlen/chore: add test coverage for account transfer modal (#8443)
thisyahlen-deriv May 12, 2023
7343041
Suisin/chore: solve input characters error at idv dropdown (#8414)
suisin-deriv May 12, 2023
838372a
translations: 📚 sync translations with crowdin (#8596)
github-actions[bot] May 12, 2023
82e9b30
feat: :sparkles: adds new complaints policy for EU clients (#8526)
shaheer-deriv May 12, 2023
1f7afc8
Merge branch 'binary-com:master' into amina/feature/90115/update_juri…
shaheer-deriv May 12, 2023
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: 8 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ permissions:

name: 'Close stale issues and PRs'
on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *'
- cron: '0 0 * * *'

jobs:
stale:
Expand All @@ -14,5 +15,11 @@ jobs:
- uses: actions/stale@v8
with:
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity. Please reopen it if needed.'
close-pr-message: 'This PR was closed because it has been stalled for 5 days with no activity. Please reopen it if needed.'
days-before-stale: 60
days-before-close: 5
ascending: true
operations-per-run: 200

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import LanguageRadioButton, { TLanguageRadioButton } from '../language-radio-button';

jest.mock('@deriv/translations', () => {
const original_module = jest.requireActual('@deriv/translations');
return {
...original_module,
getAllowedLanguages: jest.fn(() => ({ lang_1: 'Test Lang 1', lang_2: 'Test lang 2' })),
};
});

jest.mock('@deriv/components', () => {
const original_module = jest.requireActual('@deriv/components');
return {
...original_module,
Icon: jest.fn(() => <div>Flag Icon</div>),
};
});

describe('LanguageRadioButton', () => {
const mock_props: TLanguageRadioButton = {
is_current_language: true,
id: 'test id',
language_code: 'lang_1',
name: 'Test Language',
onChange: jest.fn(),
};

it('should render active LanguageRadioButton', () => {
render(<LanguageRadioButton {...mock_props} />);

expect(screen.getByText('Flag Icon')).toBeInTheDocument();
expect(screen.getByText('Test Lang 1')).toBeInTheDocument();
expect(screen.getByTestId('dt_language_settings_button')).toHaveClass(
'settings-language__language-link--active'
);
});

it('should render not active LanguageRadioButton and trigger onchange', () => {
mock_props.is_current_language = false;

render(<LanguageRadioButton {...mock_props} />);

expect(screen.getByText('Flag Icon')).toBeInTheDocument();
expect(screen.getByText('Test Lang 1')).toBeInTheDocument();
expect(screen.getByTestId('dt_language_settings_button')).not.toHaveClass(
'settings-language__language-link--active'
);

const button = screen.getByRole('radio');
expect(button).toHaveClass('settings-language__language--radio-button');
expect(button).toHaveAttribute('id', 'test id');
expect(button).toHaveAttribute('name', 'Test Language');
userEvent.click(button);
expect(mock_props.onChange).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Text, Icon } from '@deriv/components';
import classNames from 'classnames';
import { getAllowedLanguages } from '@deriv/translations';

type TLanguageRadioButton = {
export type TLanguageRadioButton = {
is_current_language: boolean;
id: string;
language_code: string;
Expand All @@ -19,6 +19,7 @@ const LanguageRadioButton = ({ is_current_language, id, language_code, name, onC
'settings-language__language-link--active': is_current_language,
})}
id={`dt_settings_${language_code}_button`}
data-testid={'dt_language_settings_button'}
>
<input
type='radio'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
const [document_image, setDocumentImage] = React.useState(null);
const [is_input_disable, setInputDisable] = React.useState(true);
const [selected_doc, setSelectedDoc] = React.useState(null);
const [input_value, setInputValue] = React.useState('');

const document_data = selected_country.identity.services.idv.documents_supported;

Expand Down Expand Up @@ -197,14 +198,17 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
type='text'
label={localize('Choose the document type')}
list_items={document_list}
value={values.document_type.text ?? ''}
value={values.document_type.text ?? input_value}
onBlur={e => {
handleBlur(e);
if (!getDocument(e.target.value)) {
resetDocumentItemSelected(setFieldValue);
}
}}
onChange={handleChange}
onChange={e => {
setInputValue(e.target.value);
handleChange(e);
}}
onItemSelection={item => {
if (item.text === 'No results found' || !item.text) {
setSelectedDoc(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const IdvDocSubmitOnSignup = ({
const [document_image, setDocumentImage] = React.useState<string | null>(null);
const [is_input_disable, setInputDisable] = React.useState(true);
const [selected_doc, setSelectedDoc] = React.useState(null);
const [input_value, setInputValue] = React.useState('');

const document_data = citizen_data.identity.services.idv.documents_supported;
const {
Expand Down Expand Up @@ -265,7 +266,10 @@ export const IdvDocSubmitOnSignup = ({
'Choose the document type'
)}
list_items={document_list}
value={values.document_type.text ?? ''}
value={
values.document_type.text ??
input_value
}
onBlur={(
e: React.ChangeEvent<HTMLInputElement>
) => {
Expand All @@ -276,7 +280,12 @@ export const IdvDocSubmitOnSignup = ({
);
}
}}
onChange={handleChange}
onChange={(
e: React.ChangeEvent<HTMLInputElement>
) => {
setInputValue(e.target.value);
handleChange(e);
}}
onItemSelection={(
item: FormikValues
) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from 'react';
import AccountTransferModal from '../account-transfer-modal';
import { render, screen } from '@testing-library/react';
import { StoreProvider, mockStore } from '@deriv/stores';

jest.mock('@deriv/cashier/src/pages/account-transfer', () => jest.fn(() => <div>AccountTransfer</div>));

let modal_root_el: HTMLDivElement;
beforeAll(() => {
modal_root_el = document.createElement('div');
modal_root_el.setAttribute('id', 'modal_root');
document.body.appendChild(modal_root_el);
});

afterAll(() => {
document.body.removeChild(modal_root_el);
});

describe('AccountTransferModal', () => {
it('should render the modal', async () => {
const mock = mockStore({
modules: {
cashier: {
account_transfer: {
is_transfer_confirm: false,
should_switch_account: false,
},
},
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

const { container } = render(
<AccountTransferModal is_modal_open={true} toggleModal={mock.traders_hub.toggleAccountTransferModal} />,
{
wrapper,
}
);
expect(container).toBeInTheDocument();
});

it('should render the text and mocked modal correctly', async () => {
const mock = mockStore({
modules: {
cashier: {
account_transfer: {
is_transfer_confirm: false,
should_switch_account: false,
},
},
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

render(
<AccountTransferModal is_modal_open={true} toggleModal={mock.traders_hub.toggleAccountTransferModal} />,
{
wrapper,
}
);
expect(screen.getByText('Transfer funds to your accounts')).toBeInTheDocument();
expect(screen.getByText('AccountTransfer')).toBeInTheDocument();
});

it('should have account-transfer-modal classname if should switch account is true', async () => {
const mock = mockStore({
modules: {
cashier: {
account_transfer: {
is_transfer_confirm: false,
should_switch_account: true,
},
},
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

render(
<AccountTransferModal is_modal_open={true} toggleModal={mock.traders_hub.toggleAccountTransferModal} />,
{
wrapper,
}
);
expect(screen.getByText('Transfer funds to your accounts')).toBeInTheDocument();
expect(screen.getByText('AccountTransfer')).toBeInTheDocument();
expect(screen.getByText('Transfer funds to your accounts')).toHaveClass(
'dc-modal-header__title--account-transfer-modal'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type TAccountTransferModal = {
toggleModal: (e?: boolean) => void;
};

const AccountTransferModal = ({ is_modal_open, toggleModal }: TAccountTransferModal) => {
const AccountTransferModal = observer(({ is_modal_open, toggleModal }: TAccountTransferModal) => {
const {
modules: {
cashier: {
Expand Down Expand Up @@ -59,6 +59,6 @@ const AccountTransferModal = ({ is_modal_open, toggleModal }: TAccountTransferMo
</Modal.Body>
</Modal>
);
};
});

export default observer(AccountTransferModal);
export default AccountTransferModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React from 'react';
import DemoAccountCard from '../demo-account-card';
import { render, screen } from '@testing-library/react';
import { StoreProvider, mockStore } from '@deriv/stores';

describe('DemoAccountCard', () => {
it('should render correctly', () => {
const mock = mockStore({
modules: {
cfd: {
current_list: {
VRTC123123: {
landing_company_short: 'svg',
},
},
},
},
traders_hub: {
selected_account_type: 'demo',
},
client: {
accounts: {
CR1231123: {
balance: 10000,
currency: 'USD',
},
},
loginid: 'CR1231123',
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

const { container } = render(<DemoAccountCard />, {
wrapper,
});
expect(container).toBeInTheDocument();
});

it('should render correctly with the correct balance and text', () => {
const mock = mockStore({
modules: {
cfd: {
current_list: {
VRTC123123: {
landing_company_short: 'svg',
},
},
},
},
traders_hub: {
selected_account_type: 'demo',
},
client: {
accounts: {
VRTC123123: {
balance: 10000,
currency: 'USD',
is_virtual: 1,
},
},
loginid: 'VRTC123123',
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

const { container } = render(<DemoAccountCard />, {
wrapper,
});
expect(container).toBeInTheDocument();
expect(screen.getByText('demo')).toBeInTheDocument();
expect(screen.getByText('10,000.00')).toBeInTheDocument();
});

it('should render the reset balance button when the balance is not 10,000', () => {
const mock = mockStore({
modules: {
cfd: {
current_list: {
VRTC123123: {
landing_company_short: 'svg',
},
},
},
},
traders_hub: {
selected_account_type: 'demo',
},
client: {
accounts: {
VRTC123123: {
balance: 9000,
currency: 'USD',
is_virtual: 1,
},
},
loginid: 'VRTC123123',
},
});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
);

const { container } = render(<DemoAccountCard />, {
wrapper,
});
expect(container).toBeInTheDocument();
expect(screen.getByText('demo')).toBeInTheDocument();
expect(screen.getByText('9,000.00')).toBeInTheDocument();
expect(screen.getByText('Reset Balance')).toBeInTheDocument();
});
});
Loading