fix(explorer): fix order amend tx view (#4197)
This commit is contained in:
parent
bf3ff8fb6f
commit
5e93e98f07
@ -12,7 +12,7 @@ type Amend = components['schemas']['v1OrderAmendment'];
|
|||||||
|
|
||||||
function renderAmendOrderDetails(
|
function renderAmendOrderDetails(
|
||||||
id: string,
|
id: string,
|
||||||
version: number,
|
version: number | undefined,
|
||||||
amend: Amend,
|
amend: Amend,
|
||||||
mocks: MockedResponse[]
|
mocks: MockedResponse[]
|
||||||
) {
|
) {
|
||||||
@ -25,7 +25,11 @@ function renderAmendOrderDetails(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderExistingAmend(id: string, version: number, amend: Amend) {
|
function renderExistingAmend(
|
||||||
|
id: string,
|
||||||
|
version: number | undefined,
|
||||||
|
amend: Amend
|
||||||
|
) {
|
||||||
const mocks = [
|
const mocks = [
|
||||||
{
|
{
|
||||||
request: {
|
request: {
|
||||||
@ -77,6 +81,55 @@ function renderExistingAmend(id: string, version: number, amend: Amend) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
request: {
|
||||||
|
query: ExplorerDeterministicOrderDocument,
|
||||||
|
variables: {
|
||||||
|
orderId: '123',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
data: {
|
||||||
|
orderByID: {
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '123',
|
||||||
|
type: 'GTT',
|
||||||
|
status: Schema.OrderStatus.STATUS_ACTIVE,
|
||||||
|
version: 100,
|
||||||
|
createdAt: '123',
|
||||||
|
updatedAt: '456',
|
||||||
|
expiresAt: '789',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
price: '200',
|
||||||
|
side: 'BUY',
|
||||||
|
remaining: '99',
|
||||||
|
rejectionReason: 'rejection',
|
||||||
|
reference: '123',
|
||||||
|
size: '200',
|
||||||
|
party: {
|
||||||
|
__typename: 'Party',
|
||||||
|
id: '234',
|
||||||
|
},
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'amend-to-order-latest-version',
|
||||||
|
state: 'STATUS_ACTIVE',
|
||||||
|
positionDecimalPlaces: 2,
|
||||||
|
decimalPlaces: '5',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
name: 'amend-to-order-latest-version-test',
|
||||||
|
product: {
|
||||||
|
__typename: 'Future',
|
||||||
|
quoteName: '123',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
request: {
|
request: {
|
||||||
query: ExplorerMarketDocument,
|
query: ExplorerMarketDocument,
|
||||||
@ -157,4 +210,15 @@ describe('Amend order details', () => {
|
|||||||
expect(await res.findByText('New price')).toBeInTheDocument();
|
expect(await res.findByText('New price')).toBeInTheDocument();
|
||||||
expect(await res.findByText('-7879')).toBeInTheDocument();
|
expect(await res.findByText('-7879')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Fetches latest version when version is not specified', async () => {
|
||||||
|
const amend: Amend = {
|
||||||
|
price: '-7879',
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = renderExistingAmend('123', undefined, amend);
|
||||||
|
expect(
|
||||||
|
await res.findByText('amend-to-order-latest-version')
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ import { wrapperClasses } from './deterministic-order-details';
|
|||||||
export interface AmendOrderDetailsProps {
|
export interface AmendOrderDetailsProps {
|
||||||
id: string;
|
id: string;
|
||||||
amend: components['schemas']['v1OrderAmendment'];
|
amend: components['schemas']['v1OrderAmendment'];
|
||||||
// Version to fetch, with 0 being 'latest' and 1 being 'first'. Defaults to 0
|
// Version to fetch. Latest is provided by default
|
||||||
version?: number;
|
version?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,13 +34,11 @@ export function getSideDeltaColour(delta: string): string {
|
|||||||
* @param param0
|
* @param param0
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const AmendOrderDetails = ({
|
const AmendOrderDetails = ({ id, version, amend }: AmendOrderDetailsProps) => {
|
||||||
id,
|
const variables = version ? { orderId: id, version } : { orderId: id };
|
||||||
version = 0,
|
|
||||||
amend,
|
|
||||||
}: AmendOrderDetailsProps) => {
|
|
||||||
const { data, error } = useExplorerDeterministicOrderQuery({
|
const { data, error } = useExplorerDeterministicOrderQuery({
|
||||||
variables: { orderId: id, version },
|
variables,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error || (data && !data.orderByID)) {
|
if (error || (data && !data.orderByID)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user