From bdf166370970a61479869a742bd7160c72249077 Mon Sep 17 00:00:00 2001 From: daro-maj <119658839+daro-maj@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:00:04 +0200 Subject: [PATCH] test(trading): update e2e tests for acs - closed all and proposed markets (#4094) --- .../src/integration/closed-markets.cy.ts | 14 ++++++ .../src/integration/market-all.cy.ts | 38 +++++++++++++- .../src/integration/market-selector.cy.ts | 5 +- .../src/integration/markets-proposed.cy.ts | 49 ++++++++++++++----- 4 files changed, 90 insertions(+), 16 deletions(-) diff --git a/apps/trading-e2e/src/integration/closed-markets.cy.ts b/apps/trading-e2e/src/integration/closed-markets.cy.ts index 08c1819ba..2778d1845 100644 --- a/apps/trading-e2e/src/integration/closed-markets.cy.ts +++ b/apps/trading-e2e/src/integration/closed-markets.cy.ts @@ -450,3 +450,17 @@ describe('Closed markets', { tags: '@smoke' }, () => { .should('have.text', 'View on Explorer'); }); }); + +describe('no closed markets', { tags: '@smoke', testIsolation: true }, () => { + before(() => { + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/all'); + cy.get('[data-testid="Closed markets"]').click(); + }); + + it('can see no markets message', () => { + // 6001-MARK-034 + cy.getByTestId('tab-closed-markets').should('contain.text', 'No markets'); + }); +}); diff --git a/apps/trading-e2e/src/integration/market-all.cy.ts b/apps/trading-e2e/src/integration/market-all.cy.ts index f576a6ee5..9aee10bce 100644 --- a/apps/trading-e2e/src/integration/market-all.cy.ts +++ b/apps/trading-e2e/src/integration/market-all.cy.ts @@ -1,7 +1,10 @@ +import { aliasGQLQuery } from '@vegaprotocol/cypress'; +import type { MarketsQuery } from '@vegaprotocol/markets'; import * as Schema from '@vegaprotocol/types'; const rowSelector = '[data-testid="tab-all-markets"] .ag-center-cols-container .ag-row'; +const colInstrumentCode = '[col-id="tradableInstrument.instrument.code"]'; describe('markets all table', { tags: '@smoke' }, () => { beforeEach(() => { @@ -60,7 +63,7 @@ describe('markets all table', { tags: '@smoke' }, () => { // 6001-MARK-035 cy.get(rowSelector) .first() - .find('[col-id="tradableInstrument.instrument.code"]') + .find(colInstrumentCode) .should('have.text', 'SOLUSD'); // 6001-MARK-036 @@ -155,6 +158,7 @@ describe('markets all table', { tags: '@smoke' }, () => { }); it('able to open and sort full market list - market page', () => { + // 6001-MARK-064 const ExpectedSortedMarkets = [ 'AAPL.MF21', 'BTCUSD.MF21', @@ -167,8 +171,38 @@ describe('markets all table', { tags: '@smoke' }, () => { cy.get('.ag-header-cell-label').contains('Market').click(); // sort by market name for (let i = 0; i < ExpectedSortedMarkets.length; i++) { cy.get(`[row-index=${i}]`) - .find('[col-id="tradableInstrument.instrument.code"]') + .find(colInstrumentCode) .should('have.text', ExpectedSortedMarkets[i]); } }); + + it('can drag and drop columns', () => { + // 6001-MARK-065 + cy.get('.ag-overlay-loading-wrapper').should('not.be.visible'); + cy.get(colInstrumentCode) + .realMouseDown() + .realMouseMove(700, 15) + .realMouseUp(); + cy.get(colInstrumentCode).should(($element) => { + const attributeValue = $element.attr('aria-colindex'); + expect(attributeValue).not.to.equal('1'); + }); + }); +}); + +describe('no all markets', { tags: '@smoke', testIsolation: true }, () => { + before(() => { + cy.mockTradingPage(); + const markets: MarketsQuery = {}; + cy.mockGQL((req) => { + aliasGQLQuery(req, 'Markets', markets); + }); + cy.mockSubscription(); + cy.visit('/#/markets/all'); + }); + + it('can see no markets message', () => { + // 6001-MARK-048 + cy.getByTestId('tab-all-markets').should('contain.text', 'No markets'); + }); }); diff --git a/apps/trading-e2e/src/integration/market-selector.cy.ts b/apps/trading-e2e/src/integration/market-selector.cy.ts index 8a5fa15f3..42792e2b3 100644 --- a/apps/trading-e2e/src/integration/market-selector.cy.ts +++ b/apps/trading-e2e/src/integration/market-selector.cy.ts @@ -25,6 +25,7 @@ describe('markets selector', { tags: '@smoke' }, () => { cy.wait('@MarketsCandles'); }); + // 6001-MARK-066 it('can toggle the sidebar', () => { cy.getByTestId('market-selector').should('be.visible'); cy.getByTestId('sidebar-toggle').click(); @@ -84,7 +85,7 @@ describe('markets selector', { tags: '@smoke' }, () => { }); }); - // 6001-MARK-27 + // 6001-MARK-027 it('can use the filter options', () => { // product type cy.getByTestId('product-Spot').click(); @@ -94,7 +95,7 @@ describe('markets selector', { tags: '@smoke' }, () => { cy.getByTestId('product-Future').click(); cy.getByTestId(list).find('a').should('have.length', 4); - // 6001-MARK-29 + // 6001-MARK-029 cy.getByTestId(searchInput).clear().type('btc'); cy.getByTestId(list).find('a').should('have.length', 2); cy.getByTestId(list).find('a').eq(1).contains('BTCUSD.MF21'); diff --git a/apps/trading-e2e/src/integration/markets-proposed.cy.ts b/apps/trading-e2e/src/integration/markets-proposed.cy.ts index de9c5a13d..1cb30314c 100644 --- a/apps/trading-e2e/src/integration/markets-proposed.cy.ts +++ b/apps/trading-e2e/src/integration/markets-proposed.cy.ts @@ -1,16 +1,16 @@ -import { checkSorting } from '@vegaprotocol/cypress'; +import { aliasGQLQuery, checkSorting } from '@vegaprotocol/cypress'; +import type { ProposalsListQuery } from '@vegaprotocol/proposals'; const rowSelector = '[data-testid="tab-proposed-markets"] .ag-center-cols-container .ag-row'; +const colMarketId = '[col-id="market"]'; describe('markets proposed table', { tags: '@smoke' }, () => { - beforeEach(() => { - cy.clearLocalStorage().then(() => { - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/#/markets/all'); - cy.get('[data-testid="Proposed markets"]').click(); - }); + before(() => { + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/all'); + cy.get('[data-testid="Proposed markets"]').click(); }); it('can see table headers', () => { @@ -35,10 +35,7 @@ describe('markets proposed table', { tags: '@smoke' }, () => { it('renders markets correctly', () => { // 6001-MARK-049 - cy.get(rowSelector) - .first() - .find('[col-id="market"]') - .should('have.text', 'ETHUSD'); + cy.get(rowSelector).first().find(colMarketId).should('have.text', 'ETHUSD'); // 6001-MARK-050 cy.get(rowSelector) @@ -119,6 +116,7 @@ describe('markets proposed table', { tags: '@smoke' }, () => { ); }); it('proposed markets tab should be sorted properly', () => { + // 6001-MARK-062 cy.get('[data-testid="Proposed markets"]').click({ force: true }); const marketColDefault = [ 'ETHUSD', @@ -196,4 +194,31 @@ describe('markets proposed table', { tags: '@smoke' }, () => { ]; checkSorting('state', stateColDefault, stateColAsc, stateColDesc); }); + + it('can drag and drop columns', () => { + // 6001-MARK-063 + cy.get(colMarketId).realMouseDown().realMouseMove(700, 15).realMouseUp(); + cy.get(colMarketId).should(($element) => { + const attributeValue = $element.attr('aria-colindex'); + expect(attributeValue).not.to.equal('1'); + }); + }); +}); + +describe('no markets proposed', { tags: '@smoke', testIsolation: true }, () => { + before(() => { + cy.mockTradingPage(); + const proposal: ProposalsListQuery = {}; + cy.mockGQL((req) => { + aliasGQLQuery(req, 'ProposalsList', proposal); + }); + cy.mockSubscription(); + cy.visit('/#/markets/all'); + cy.get('[data-testid="Proposed markets"]').click(); + }); + + it('can see no markets message', () => { + // 6001-MARK-061 + cy.getByTestId('tab-proposed-markets').should('contain.text', 'No markets'); + }); });