From 110c2b22d4ac71510f166ab540d4007e8c4cf715 Mon Sep 17 00:00:00 2001 From: Nijil Nirmal Date: Wed, 12 Mar 2025 13:10:41 +0400 Subject: [PATCH 1/3] chore: remove max ticks from contract card in open positions and contract details page --- .../__tests__/tick-counter-bar.spec.tsx | 3 +-- .../contract-card-header.tsx | 8 +------- .../contract-card-items/tick-counter-bar.tsx | 5 ++--- .../contract-card-status-timer.spec.tsx | 4 ++-- .../__tests__/contract-card.spec.tsx | 18 +++++++++--------- .../contract-card-status-timer.tsx | 5 ++--- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/packages/components/src/components/contract-card/contract-card-items/__tests__/tick-counter-bar.spec.tsx b/packages/components/src/components/contract-card/contract-card-items/__tests__/tick-counter-bar.spec.tsx index 31326a484c88..015f9671058e 100644 --- a/packages/components/src/components/contract-card/contract-card-items/__tests__/tick-counter-bar.spec.tsx +++ b/packages/components/src/components/contract-card/contract-card-items/__tests__/tick-counter-bar.spec.tsx @@ -6,12 +6,11 @@ describe('TickCounterBar', () => { const mock_props = { current_tick: 12345, label: 'Ticks', - max_ticks_duration: 67890, }; it('should render properly', () => { render(); - const ticks_info_el = screen.getByText('12345/67890 Ticks'); + const ticks_info_el = screen.getByText('12345 Ticks'); expect(ticks_info_el).toHaveClass('dc-tick-counter-bar__text'); }); }); diff --git a/packages/components/src/components/contract-card/contract-card-items/contract-card-header.tsx b/packages/components/src/components/contract-card/contract-card-items/contract-card-header.tsx index e8f29d66b17b..39cebc949fde 100644 --- a/packages/components/src/components/contract-card/contract-card-items/contract-card-header.tsx +++ b/packages/components/src/components/contract-card/contract-card-items/contract-card-header.tsx @@ -173,13 +173,7 @@ const ContractCardHeader = ({ ) : null} - {!is_sold && is_accumulator && ( - - )} + {!is_sold && is_accumulator && }
diff --git a/packages/components/src/components/contract-card/contract-card-items/tick-counter-bar.tsx b/packages/components/src/components/contract-card/contract-card-items/tick-counter-bar.tsx index 8dc1820869f4..9de6a7cacf13 100644 --- a/packages/components/src/components/contract-card/contract-card-items/tick-counter-bar.tsx +++ b/packages/components/src/components/contract-card/contract-card-items/tick-counter-bar.tsx @@ -4,13 +4,12 @@ import Text from '../../text'; type TTickCounterBar = { current_tick?: number; label: string; - max_ticks_duration?: number; }; -const TickCounterBar = ({ current_tick, label, max_ticks_duration }: TTickCounterBar) => ( +const TickCounterBar = ({ current_tick, label }: TTickCounterBar) => (
- {`${current_tick}/${max_ticks_duration} ${label}`} + {`${current_tick} ${label}`}
diff --git a/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card-status-timer.spec.tsx b/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card-status-timer.spec.tsx index 3165a6f9a9ee..874732428ee1 100644 --- a/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card-status-timer.spec.tsx +++ b/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card-status-timer.spec.tsx @@ -23,9 +23,9 @@ describe('ContractCardStatusTimer', () => { expect(screen.getByText('00:16:40')).toBeInTheDocument(); }); it('should render ticks progress if currentTick and tick_count are passed', () => { - render(); + render(); - expect(screen.getByText('2/10 ticks')).toBeInTheDocument(); + expect(screen.getByText('2 ticks')).toBeInTheDocument(); }); it('should render Closed status if isSold === true', () => { render(); diff --git a/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card.spec.tsx b/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card.spec.tsx index 3c5372195ad9..8045c24a26dc 100644 --- a/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card.spec.tsx +++ b/packages/trader/src/AppV2/Components/ContractCard/__tests__/contract-card.spec.tsx @@ -389,12 +389,12 @@ describe('ContractCard', () => { expect(screen.getByText('Accumulators')).toBeInTheDocument(); expect(screen.getByText(symbolName)).toBeInTheDocument(); expect(screen.getByText('9.00 USD')).toBeInTheDocument(); - expect(screen.getByText('9/230 ticks')).toBeInTheDocument(); + expect(screen.getByText('9 ticks')).toBeInTheDocument(); expect(screen.getByText('0.84 USD')).toBeInTheDocument(); expect(screen.getByRole('button', { name: CLOSE })).toBeEnabled(); expect(screen.queryByRole('button', { name: CANCEL })).not.toBeInTheDocument(); }); - it('should show loader when a Close button is clicked and isSellRequested === true', () => { + it('should show loader when a Close button is clicked and isSellRequested === true', async () => { const mockedOnClose = jest.fn(); const { rerender } = render( mockedContractCard({ @@ -404,7 +404,7 @@ describe('ContractCard', () => { }) ); const closeButton = screen.getByRole('button', { name: getCardLabels().CLOSE }); - userEvent.click(closeButton); + await userEvent.click(closeButton); expect(mockedOnClose).toHaveBeenCalledTimes(1); rerender( @@ -417,7 +417,7 @@ describe('ContractCard', () => { expect(screen.getByTestId(buttonLoaderId)).toBeInTheDocument(); expect(closeButton).toBeDisabled(); }); - it('should show loader when a Cancel button is clicked and isSellRequested === true', () => { + it('should show loader when a Cancel button is clicked and isSellRequested === true', async () => { const mockedOnCancel = jest.fn(); const { rerender } = render( mockedContractCard({ @@ -427,7 +427,7 @@ describe('ContractCard', () => { }) ); const cancelButton = screen.getByRole('button', { name: CANCEL }); - userEvent.click(cancelButton); + await userEvent.click(cancelButton); expect(mockedOnCancel).toHaveBeenCalledTimes(1); rerender( @@ -452,7 +452,7 @@ describe('ContractCard', () => { expect(screen.queryByRole('button', { name: CLOSE })).not.toBeInTheDocument(); expect(screen.queryByRole('button', { name: CANCEL })).not.toBeInTheDocument(); }); - it('should call onClick when a card is clicked, and should redirect to a correct route if redirectTo is passed', () => { + it('should call onClick when a card is clicked, and should redirect to a correct route if redirectTo is passed', async () => { const mockedOnClick = jest.fn(); const redirectTo = getContractPath(Number(closedPositions[0].contract_info.contract_id)); render( @@ -464,11 +464,11 @@ describe('ContractCard', () => { }) ); const card = screen.getByText('Turbos Up'); - userEvent.click(card); + await userEvent.click(card); expect(mockedOnClick).toHaveBeenCalledTimes(1); expect(history.location.pathname).toBe(redirectTo); }); - it('should call onClick when a card is clicked, but should not redirect anywhere if redirectTo prop is missing', () => { + it('should call onClick when a card is clicked, but should not redirect anywhere if redirectTo prop is missing', async () => { const mockedOnClick = jest.fn(); const redirectTo = getContractPath(Number(closedPositions[0].contract_info.contract_id)); render( @@ -479,7 +479,7 @@ describe('ContractCard', () => { }) ); const card = screen.getByText('Turbos Up'); - userEvent.click(card); + await userEvent.click(card); expect(mockedOnClick).toHaveBeenCalledTimes(1); expect(history.location.pathname).not.toBe(redirectTo); }); diff --git a/packages/trader/src/AppV2/Components/ContractCard/contract-card-status-timer.tsx b/packages/trader/src/AppV2/Components/ContractCard/contract-card-status-timer.tsx index 5449c454b4e8..9b15c4cc954b 100644 --- a/packages/trader/src/AppV2/Components/ContractCard/contract-card-status-timer.tsx +++ b/packages/trader/src/AppV2/Components/ContractCard/contract-card-status-timer.tsx @@ -17,11 +17,10 @@ export const ContractCardStatusTimer = ({ date_expiry, isSold, serverTime, - tick_count, }: TContractCardStatusTimerProps) => { const getDisplayedDuration = () => { - if (tick_count) { - return `${currentTick ?? 0}/${tick_count} ${getCardLabels().TICKS.toLowerCase()}`; + if (currentTick) { + return `${currentTick ?? 0} ${getCardLabels().TICKS.toLowerCase()}`; } if (date_expiry && serverTime) { return ( From f9c78ca7b1009d45c575af4eebf4ab6b82b25b32 Mon Sep 17 00:00:00 2001 From: Nijil Nirmal Date: Thu, 13 Mar 2025 12:12:30 +0400 Subject: [PATCH 2/3] chore: remove max ticks from contract details section --- .../Components/Elements/ContractAudit/contract-details.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx b/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx index c764a2b48008..82d51dcb1eb9 100644 --- a/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx +++ b/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx @@ -81,9 +81,7 @@ const ContractDetails = ({ const show_payout_per_point = isTurbosContract(contract_type) || is_vanilla; const ticks_label = Number(tick_count) < 2 ? localize('tick') : localize('ticks'); const show_strike_barrier = is_vanilla || isAsiansContract(contract_type) || isResetContract(contract_type); - const ticks_duration_text = isAccumulatorContract(contract_type) - ? `${tick_passed}/${tick_count} ${localize('ticks')}` - : `${tick_count} ${ticks_label}`; + const ticks_duration_text = `${tick_count} ${ticks_label}`; const INDICATIVE_HIGH = 'H'; const INDICATIVE_LOW = 'L'; From 6b3c29c6b9373981e7de094b3c5bfbd4c4458ee1 Mon Sep 17 00:00:00 2001 From: Nijil Nirmal Date: Thu, 13 Mar 2025 13:24:51 +0400 Subject: [PATCH 3/3] chore: remove max ticks from contract details section --- .../Components/Elements/ContractAudit/contract-details.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx b/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx index 82d51dcb1eb9..ab3569f36e60 100644 --- a/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx +++ b/packages/trader/src/App/Components/Elements/ContractAudit/contract-details.tsx @@ -81,7 +81,9 @@ const ContractDetails = ({ const show_payout_per_point = isTurbosContract(contract_type) || is_vanilla; const ticks_label = Number(tick_count) < 2 ? localize('tick') : localize('ticks'); const show_strike_barrier = is_vanilla || isAsiansContract(contract_type) || isResetContract(contract_type); - const ticks_duration_text = `${tick_count} ${ticks_label}`; + const ticks_duration_text = isAccumulatorContract(contract_type) + ? `${tick_passed} ${ticks_label}` + : `${tick_count} ${ticks_label}`; const INDICATIVE_HIGH = 'H'; const INDICATIVE_LOW = 'L';