Skip to content

Commit aedbefe

Browse files
committed
feat: take profit text unification
1 parent 54a1a15 commit aedbefe

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/__tests__/take-profit.spec.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import TraderProviders from '../../../../../../../trader-providers';
88
describe('<TakeProfit />', () => {
99
let default_mocked_store: ReturnType<typeof mockStore>,
1010
default_mocked_props: React.ComponentProps<typeof TakeProfit>;
11+
const popoverTestid = 'dt_popover_wrapper';
12+
const takeProfitTooltipText = /When your profit reaches/i;
1113

1214
beforeEach(() => {
1315
default_mocked_store = {
@@ -85,19 +87,19 @@ describe('<TakeProfit />', () => {
8587
it('should render correct text of the tooltip for Multipliers', () => {
8688
render(mockTakeProfit());
8789

88-
expect(screen.queryByText(/When your profit reaches/i)).not.toBeInTheDocument();
89-
userEvent.hover(screen.getByTestId('dt_popover_wrapper'));
90+
expect(screen.queryByText(takeProfitTooltipText)).not.toBeInTheDocument();
91+
userEvent.hover(screen.getByTestId(popoverTestid));
9092

91-
expect(screen.getByText(/When your profit reaches/i)).toBeInTheDocument();
93+
expect(screen.getByText(takeProfitTooltipText)).toBeInTheDocument();
9294
});
9395
it('should render correct text of the tooltip for Accumulators', () => {
9496
default_mocked_store.modules.trade.is_accumulator = true;
9597
default_mocked_store.modules.trade.is_multiplier = false;
9698
render(mockTakeProfit());
9799

98-
expect(screen.queryByText(/Your contract will be closed/i)).not.toBeInTheDocument();
99-
userEvent.hover(screen.getByTestId('dt_popover_wrapper'));
100+
expect(screen.queryByText(takeProfitTooltipText)).not.toBeInTheDocument();
101+
userEvent.hover(screen.getByTestId(popoverTestid));
100102

101-
expect(screen.getByText(/Your contract will be closed/i)).toBeInTheDocument();
103+
expect(screen.getByText(takeProfitTooltipText)).toBeInTheDocument();
102104
});
103105
});

packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/take-profit.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ const TakeProfit = observer((props: TTakeProfitProps) => {
4242
onChange(e);
4343
}
4444
};
45-
const tooltip_text = is_multiplier ? (
46-
<Localize i18n_default_text='When your profit reaches or exceeds this amount, your trade will be closed automatically.' />
47-
) : (
48-
<Localize i18n_default_text='Your contract will be closed automatically if your profit reaches this amount.' />
49-
);
5045

5146
return (
5247
<Fieldset className='trade-container__fieldset'>
@@ -73,7 +68,9 @@ const TakeProfit = observer((props: TTakeProfitProps) => {
7368
name='take_profit'
7469
onChange={changeValue}
7570
setCurrentFocus={setCurrentFocus}
76-
tooltip_label={tooltip_text}
71+
tooltip_label={
72+
<Localize i18n_default_text='When your profit reaches or exceeds this amount, your trade will be closed automatically.' />
73+
}
7774
tooltip_alignment='left'
7875
error_message_alignment='left'
7976
value={take_profit ?? ''}

0 commit comments

Comments
 (0)