fix: 1642 show in type column if order is pegged or LP (#1697)

* fix: #1642 show in type column if order is pegged or LP

* Update libs/orders/src/lib/components/order-list/order-list.spec.tsx

Co-authored-by: Matthew Russell <mattrussell36@gmail.com>

* Update libs/orders/src/lib/components/order-list/order-list.spec.tsx

Co-authored-by: Matthew Russell <mattrussell36@gmail.com>

Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
This commit is contained in:
m.ray 2022-10-10 16:17:38 +01:00 committed by GitHub
parent 4d8abeb2a3
commit e25f0085eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -33,7 +33,7 @@ const defaultProps: OrderListTableProps = {
const generateJsx = (
props: Partial<OrderListTableProps> = defaultProps,
context: PartialDeep<VegaWalletContextShape> = { keypair: { pub: '0x123' } }
context: PartialDeep<VegaWalletContextShape> = { pubKey: '0x123' }
) => {
return (
<MockedProvider>
@ -166,7 +166,7 @@ describe('OrderListTable', () => {
expect(mockCancel).toHaveBeenCalledWith(order);
});
it('doesnt show buttons for liquidity provision orders', async () => {
it('shows if an order is a liquidity provision order and does not show order actions', async () => {
const order = generateOrder({
type: OrderType.TYPE_LIMIT,
timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC,
@ -178,10 +178,12 @@ describe('OrderListTable', () => {
});
const amendCell = getAmendCell();
const typeCell = screen.getAllByRole('gridcell')[2];
expect(typeCell).toHaveTextContent('Liquidity provision');
expect(amendCell.queryAllByRole('button')).toHaveLength(0);
});
it('doesnt show buttons for pegged orders', async () => {
it('shows if an order is a pegged order and does not show order actions', async () => {
const order = generateOrder({
type: OrderType.TYPE_LIMIT,
timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC,
@ -195,6 +197,8 @@ describe('OrderListTable', () => {
});
const amendCell = getAmendCell();
const typeCell = screen.getAllByRole('gridcell')[2];
expect(typeCell).toHaveTextContent('Pegged');
expect(amendCell.queryAllByRole('button')).toHaveLength(0);
});
@ -221,7 +225,7 @@ describe('OrderListTable', () => {
OrderStatus.STATUS_FILLED,
OrderStatus.STATUS_REJECTED,
OrderStatus.STATUS_STOPPED,
])('doesnt show buttons for %s orders', async (status) => {
])('does not show buttons for %s orders', async (status) => {
const order = generateOrder({
type: OrderType.TYPE_LIMIT,
status,

View File

@ -144,9 +144,12 @@ export const OrderListTable = forwardRef<AgGridReact, OrderListTableProps>(
<AgGridColumn
field="type"
valueFormatter={({
data: order,
value,
}: VegaValueFormatterParams<Order, 'type'>) => {
if (!value) return '-';
if (order.peggedOrder) return t('Pegged');
if (order.liquidityProvision) return t('Liquidity provision');
return OrderTypeMapping[value];
}}
/>