chore(trading): deal ticket tif tests (#5009)
This commit is contained in:
parent
51c88d2fce
commit
66ebb26b0f
@ -1,186 +0,0 @@
|
|||||||
import {
|
|
||||||
TIFlist,
|
|
||||||
orderTIFDropDown,
|
|
||||||
toggleLimit,
|
|
||||||
toggleMarket,
|
|
||||||
} from '../support/deal-ticket';
|
|
||||||
|
|
||||||
const tooltipContent = 'tooltip-content';
|
|
||||||
const reduceOnly = 'reduce-only';
|
|
||||||
const postOnly = 'post-only';
|
|
||||||
|
|
||||||
describe('time in force validation', { tags: '@smoke' }, () => {
|
|
||||||
before(() => {
|
|
||||||
cy.setVegaWallet();
|
|
||||||
cy.mockTradingPage();
|
|
||||||
cy.mockSubscription();
|
|
||||||
cy.clearAllLocalStorage();
|
|
||||||
cy.setOnBoardingViewed();
|
|
||||||
cy.visit('/#/markets/market-0');
|
|
||||||
cy.wait('@Markets');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('must have market order set up to IOC by default', function () {
|
|
||||||
// 7002-SORD-030
|
|
||||||
cy.getByTestId(toggleMarket).click();
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
TIFlist.filter((item) => item.code === 'IOC')[0].text
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('must have time in force set to GTC for limit order', function () {
|
|
||||||
// 7002-SORD-031
|
|
||||||
cy.getByTestId(toggleLimit).click();
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
TIFlist.filter((item) => item.code === 'GTC')[0].text
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selections should be remembered', () => {
|
|
||||||
cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTT');
|
|
||||||
cy.getByTestId(toggleMarket).click();
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
TIFlist.filter((item) => item.code === 'IOC')[0].text
|
|
||||||
);
|
|
||||||
cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_FOK');
|
|
||||||
cy.getByTestId(toggleLimit).click();
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
TIFlist.filter((item) => item.code === 'GTT')[0].text
|
|
||||||
);
|
|
||||||
cy.getByTestId(toggleMarket).click();
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
TIFlist.filter((item) => item.code === 'FOK')[0].text
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('limit order', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.getByTestId(toggleLimit).click();
|
|
||||||
});
|
|
||||||
const validTIF = TIFlist;
|
|
||||||
validTIF.forEach((tif) => {
|
|
||||||
// 7002-SORD-023
|
|
||||||
// 7002-SORD-024
|
|
||||||
// 7002-SORD-025
|
|
||||||
// 7002-SORD-026
|
|
||||||
// 7002-SORD-027
|
|
||||||
// 7002-SORD-028
|
|
||||||
|
|
||||||
it(`must be able to select ${tif.code}`, function () {
|
|
||||||
cy.getByTestId(orderTIFDropDown).select(tif.value);
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
tif.text
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('market order', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.getByTestId(toggleMarket).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code));
|
|
||||||
const invalidTIF = TIFlist.filter(
|
|
||||||
(tif) => !['FOK', 'IOC'].includes(tif.code)
|
|
||||||
);
|
|
||||||
|
|
||||||
validTIF.forEach((tif) => {
|
|
||||||
// 7002-SORD-025
|
|
||||||
// 7002-SORD-026
|
|
||||||
|
|
||||||
it(`must be able to select ${tif.code}`, function () {
|
|
||||||
cy.getByTestId(orderTIFDropDown).select(tif.value);
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
tif.text
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
invalidTIF.forEach((tif) => {
|
|
||||||
// 7002-SORD-023
|
|
||||||
// 7002-SORD-024
|
|
||||||
// 7002-SORD-027
|
|
||||||
// 7002-SORD-028
|
|
||||||
it(`must not be able to select ${tif.code}`, function () {
|
|
||||||
cy.getByTestId(orderTIFDropDown).should('not.contain', tif.text);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('post and reduce - market order', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.getByTestId(toggleMarket).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code));
|
|
||||||
|
|
||||||
validTIF.forEach((tif) => {
|
|
||||||
// 7002-SORD-025
|
|
||||||
// 7002-SORD-026
|
|
||||||
|
|
||||||
it(`post and reduce order market for ${tif.code}`, function () {
|
|
||||||
// 7003-SORD-054
|
|
||||||
// 7003-SORD-055
|
|
||||||
// 7003-SORD-056
|
|
||||||
// 7003-SORD-057
|
|
||||||
|
|
||||||
cy.getByTestId(orderTIFDropDown).select(tif.value);
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
tif.text
|
|
||||||
);
|
|
||||||
cy.getByTestId(postOnly).should('be.disabled');
|
|
||||||
cy.getByTestId(reduceOnly).should('be.enabled');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('post and reduce - limit order', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.getByTestId(toggleLimit).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
const validTIFLimit = TIFlist.filter((tif) =>
|
|
||||||
['GFA', 'GFN', 'GTC', 'GTT'].includes(tif.code)
|
|
||||||
);
|
|
||||||
|
|
||||||
validTIFLimit.forEach((tif) => {
|
|
||||||
it(`post and reduce order for limit ${tif.code}`, function () {
|
|
||||||
// 7003-SORD-054
|
|
||||||
// 7003-SORD-055
|
|
||||||
// 7003-SORD-056
|
|
||||||
// 7003-SORD-057
|
|
||||||
cy.getByTestId(orderTIFDropDown).select(tif.value);
|
|
||||||
cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should(
|
|
||||||
'have.text',
|
|
||||||
tif.text
|
|
||||||
);
|
|
||||||
cy.getByTestId(postOnly).should('be.enabled');
|
|
||||||
cy.getByTestId(reduceOnly).should('be.disabled');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it(`can see explanation of what post only and reduce only is/does`, function () {
|
|
||||||
// 7003-SORD-058
|
|
||||||
cy.get('[for="post-only"]').should('have.text', 'Post only').realHover();
|
|
||||||
cy.getByTestId(tooltipContent).should(
|
|
||||||
'contain.text',
|
|
||||||
`"Post only" will ensure the order is not filled immediately but is placed on the order book as a passive order. When the order is processed it is either stopped (if it would not be filled immediately), or placed in the order book as a passive order until the price taker matches with it.`
|
|
||||||
);
|
|
||||||
cy.get('[for="reduce-only"]')
|
|
||||||
.should('have.text', 'Reduce only')
|
|
||||||
.realHover();
|
|
||||||
cy.getByTestId(tooltipContent).should(
|
|
||||||
'contain.text',
|
|
||||||
`"Reduce only" can be used only with non-persistent orders, such as "Fill or Kill" or "Immediate or Cancel".`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -153,6 +153,7 @@ describe('DealTicket', () => {
|
|||||||
'checked'
|
'checked'
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('order-size')).toHaveDisplayValue('0');
|
expect(screen.getByTestId('order-size')).toHaveDisplayValue('0');
|
||||||
|
// 7002-SORD-031
|
||||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTC
|
Schema.OrderTimeInForce.TIME_IN_FORCE_GTC
|
||||||
);
|
);
|
||||||
@ -235,7 +236,7 @@ describe('DealTicket', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set values for a non-persistent reduce only order and disable post only checkbox', () => {
|
it('should set values for a non-persistent reduce only order and disable post only checkbox', async () => {
|
||||||
const expectedOrder = {
|
const expectedOrder = {
|
||||||
marketId: market.id,
|
marketId: market.id,
|
||||||
type: Schema.OrderType.TYPE_LIMIT,
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
@ -273,13 +274,28 @@ describe('DealTicket', () => {
|
|||||||
expect(screen.getByTestId('order-price')).toHaveDisplayValue(
|
expect(screen.getByTestId('order-price')).toHaveDisplayValue(
|
||||||
expectedOrder.price
|
expectedOrder.price
|
||||||
);
|
);
|
||||||
|
// 7003-SORD-054
|
||||||
|
// 7003-SORD-055
|
||||||
|
// 7003-SORD-057
|
||||||
expect(screen.getByTestId('post-only')).toBeDisabled();
|
expect(screen.getByTestId('post-only')).toBeDisabled();
|
||||||
expect(screen.getByTestId('reduce-only')).toBeEnabled();
|
expect(screen.getByTestId('reduce-only')).toBeEnabled();
|
||||||
expect(screen.getByTestId('reduce-only')).toBeChecked();
|
expect(screen.getByTestId('reduce-only')).toBeChecked();
|
||||||
expect(screen.getByTestId('post-only')).not.toBeChecked();
|
expect(screen.getByTestId('post-only')).not.toBeChecked();
|
||||||
|
userEvent.hover(screen.getByText('Reduce only'));
|
||||||
|
// 7003-SORD-056
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set values for a persistent post only order and disable reduce only checkbox', () => {
|
userEvent.hover(screen.getByText('Post only'));
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set values for a persistent post only order and disable reduce only checkbox', async () => {
|
||||||
const expectedOrder = {
|
const expectedOrder = {
|
||||||
marketId: market.id,
|
marketId: market.id,
|
||||||
type: Schema.OrderType.TYPE_LIMIT,
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
@ -318,10 +334,49 @@ describe('DealTicket', () => {
|
|||||||
expect(screen.getByTestId('order-price')).toHaveDisplayValue(
|
expect(screen.getByTestId('order-price')).toHaveDisplayValue(
|
||||||
expectedOrder.price
|
expectedOrder.price
|
||||||
);
|
);
|
||||||
|
// 7003-SORD-054
|
||||||
|
// 7003-SORD-055
|
||||||
|
// 7003-SORD-057
|
||||||
expect(screen.getByTestId('post-only')).toBeEnabled();
|
expect(screen.getByTestId('post-only')).toBeEnabled();
|
||||||
expect(screen.getByTestId('reduce-only')).toBeDisabled();
|
expect(screen.getByTestId('reduce-only')).toBeDisabled();
|
||||||
expect(screen.getByTestId('post-only')).toBeChecked();
|
expect(screen.getByTestId('post-only')).toBeChecked();
|
||||||
expect(screen.getByTestId('reduce-only')).not.toBeChecked();
|
expect(screen.getByTestId('reduce-only')).not.toBeChecked();
|
||||||
|
|
||||||
|
userEvent.hover(screen.getByText('Reduce only'));
|
||||||
|
// 7003-SORD-056
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toBeVisible();
|
||||||
|
});
|
||||||
|
userEvent.hover(screen.getByText('Post only'));
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should see an explanation of post only', async () => {
|
||||||
|
render(generateJsx());
|
||||||
|
userEvent.hover(screen.getByText('Post only'));
|
||||||
|
// 7003-SORD-058
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toHaveTextContent(
|
||||||
|
`"Post only" will ensure the order is not filled immediately but is placed on the order book as a passive order. When the order is processed it is either stopped (if it would not be filled immediately), or placed in the order book as a passive order until the price taker matches with it.`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should see an explanation of reduce only', async () => {
|
||||||
|
render(generateJsx());
|
||||||
|
userEvent.hover(screen.getByText('Reduce only'));
|
||||||
|
// 7003-SORD-058
|
||||||
|
await waitFor(() => {
|
||||||
|
const tooltips = screen.getAllByTestId('tooltip-content');
|
||||||
|
expect(tooltips[0]).toHaveTextContent(
|
||||||
|
`"Reduce only" can be used only with non-persistent orders, such as "Fill or Kill" or "Immediate or Cancel".`
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set values for a persistent post only iceberg order and disable reduce only checkbox', () => {
|
it('should set values for a persistent post only iceberg order and disable reduce only checkbox', () => {
|
||||||
@ -430,6 +485,12 @@ describe('DealTicket', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Only FOK and IOC should be present for type market order
|
// Only FOK and IOC should be present for type market order
|
||||||
|
// 7002-SORD-023
|
||||||
|
// 7002-SORD-024
|
||||||
|
// 7002-SORD-025
|
||||||
|
// 7002-SORD-026
|
||||||
|
// 7002-SORD-027
|
||||||
|
// 7002-SORD-028
|
||||||
expect(
|
expect(
|
||||||
Array.from(screen.getByTestId('order-tif').children).map(
|
Array.from(screen.getByTestId('order-tif').children).map(
|
||||||
(o) => o.textContent
|
(o) => o.textContent
|
||||||
@ -437,6 +498,7 @@ describe('DealTicket', () => {
|
|||||||
).toEqual(['Fill or Kill (FOK)', 'Immediate or Cancel (IOC)']);
|
).toEqual(['Fill or Kill (FOK)', 'Immediate or Cancel (IOC)']);
|
||||||
|
|
||||||
// IOC should be default
|
// IOC should be default
|
||||||
|
// 7002-SORD-030
|
||||||
expect(screen.getByTestId('order-tif')).toHaveDisplayValue(
|
expect(screen.getByTestId('order-tif')).toHaveDisplayValue(
|
||||||
'Immediate or Cancel (IOC)'
|
'Immediate or Cancel (IOC)'
|
||||||
);
|
);
|
||||||
@ -451,6 +513,12 @@ describe('DealTicket', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Switch to type limit order -> all TIF options should be shown
|
// Switch to type limit order -> all TIF options should be shown
|
||||||
|
// 7002-SORD-023
|
||||||
|
// 7002-SORD-024
|
||||||
|
// 7002-SORD-025
|
||||||
|
// 7002-SORD-026
|
||||||
|
// 7002-SORD-027
|
||||||
|
// 7002-SORD-028
|
||||||
await userEvent.click(screen.getByTestId('order-type-Limit'));
|
await userEvent.click(screen.getByTestId('order-type-Limit'));
|
||||||
expect(screen.getByTestId('order-tif').children).toHaveLength(
|
expect(screen.getByTestId('order-tif').children).toHaveLength(
|
||||||
Object.keys(Schema.OrderTimeInForce).length
|
Object.keys(Schema.OrderTimeInForce).length
|
||||||
|
Loading…
Reference in New Issue
Block a user