fix: hide close button if openVolume is zero (#2768)
This commit is contained in:
parent
1e0e1c7859
commit
b1280c8285
@ -172,3 +172,33 @@ it('displays realised and unrealised PNL', async () => {
|
|||||||
expect(cells[9].textContent).toEqual('1.23');
|
expect(cells[9].textContent).toEqual('1.23');
|
||||||
expect(cells[10].textContent).toEqual('4.56');
|
expect(cells[10].textContent).toEqual('4.56');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('displays close button', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
render(
|
||||||
|
<PositionsTable
|
||||||
|
rowData={singleRowData}
|
||||||
|
onClose={() => {
|
||||||
|
return;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const cells = screen.getAllByRole('gridcell');
|
||||||
|
expect(cells[12].textContent).toEqual('Close');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('do not display close button if openVolume is zero', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
render(
|
||||||
|
<PositionsTable
|
||||||
|
rowData={[{ ...singleRow, openVolume: '0' }]}
|
||||||
|
onClose={() => {
|
||||||
|
return;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const cells = screen.getAllByRole('gridcell');
|
||||||
|
expect(cells[12].textContent).toEqual('');
|
||||||
|
});
|
||||||
|
@ -381,14 +381,16 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
|
|||||||
{onClose ? (
|
{onClose ? (
|
||||||
<AgGridColumn
|
<AgGridColumn
|
||||||
type="rightAligned"
|
type="rightAligned"
|
||||||
cellRenderer={({ data }: VegaICellRendererParams<Position>) => (
|
cellRenderer={({ data }: VegaICellRendererParams<Position>) =>
|
||||||
|
data?.openVolume && data?.openVolume !== '0' ? (
|
||||||
<ButtonLink
|
<ButtonLink
|
||||||
data-testid="close-position"
|
data-testid="close-position"
|
||||||
onClick={() => data && onClose(data)}
|
onClick={() => data && onClose(data)}
|
||||||
>
|
>
|
||||||
{t('Close')}
|
{t('Close')}
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
)}
|
) : null
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</AgGrid>
|
</AgGrid>
|
||||||
|
Loading…
Reference in New Issue
Block a user