Test passing for trades list (#262)

* Test passing for trades list

* Remove log and change file to ts

* Update regex to include different date format
This commit is contained in:
Joe Tsang 2022-04-19 10:57:08 +01:00 committed by GitHub
parent 753cff95b9
commit 09e4603eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 20 deletions

View File

@ -8,10 +8,10 @@ Feature: Markets page
Scenario: Select active market
Given I am on the markets page
When I click on an active market
Then I am on the trading page for an active market
When I click on "Active" market
Then trading page for "active" market is displayed
Scenario: Select suspended market
Given I am on the markets page
When I click on a suspended market
Then I am on the trading page for a suspended market
When I click on "Suspended" market
Then trading page for "suspended" market is displayed

View File

@ -1,15 +1,15 @@
import BasePage from './base-page';
export default class TradingPage extends BasePage {
chartTab = 'chart';
ticketTab = 'ticket';
orderbookTab = 'orderbook';
ordersTab = 'orders';
positionsTab = 'positions';
collateralTab = 'collateral';
tradesTab = 'trades';
completedTrades = 'market-trades';
orderBookTab = 'orderbook';
chartTab = 'Chart';
ticketTab = 'Ticket';
orderbookTab = 'Orderbook';
ordersTab = 'Orders';
positionsTab = 'Positions';
collateralTab = 'Collateral';
tradesTab = 'Trades';
completedTrades = 'Market-trades';
orderBookTab = 'Prderbook';
clickOnOrdersTab() {
cy.getByTestId(this.ordersTab).click();

View File

@ -38,10 +38,6 @@ And('the market table is displayed', () => {
marketsPage.validateMarketTableDisplayed();
});
When('I click on an active market', () => {
marketsPage.clickOnMarket('Active');
});
When('I click on a suspended market', () => {
marketsPage.clickOnMarket('Suspended');
When('I click on {string} market', (Expectedmarket) => {
marketsPage.clickOnMarket(Expectedmarket);
});

View File

@ -1,4 +1,4 @@
import { Given } from 'cypress-cucumber-preprocessor/steps';
import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
import { hasOperationName } from '..';
import { MarketState } from '@vegaprotocol/types';
/* eslint-disable @nrwl/nx/enforce-module-boundaries */
@ -9,6 +9,11 @@ import {
} from '../../../../../libs/chart/src/__tests__';
import { generateDealTicketQuery } from '../../../../../libs/deal-ticket/src/__tests__';
import { generateMarket } from '../../../../trading/pages/markets/__tests__';
import TradesList from '../trading-windows/trades-list';
import TradingPage from '../pages/trading-page';
const tradesList = new TradesList();
const tradingPage = new TradingPage();
/* eslint-enable @nrwl/nx/enforce-module-boundaries */
const mockMarket = (state: MarketState) => {
@ -66,3 +71,20 @@ Given('I am on the trading page for a suspended market', () => {
cy.wait('@Market');
cy.contains('Market: SUSPENDED MARKET');
});
Then('trading page for {string} market is displayed', (marketType) => {
switch (marketType) {
case 'active':
mockMarket(MarketState.Active);
cy.wait('@Market');
cy.contains('Market: ACTIVE MARKET');
break;
case 'suspended':
mockMarket(MarketState.Suspended);
cy.wait('@Market');
cy.contains('Market: SUSPENDED MARKET');
break;
}
tradingPage.clickOnTradesTab();
tradesList.verifyTradesListDisplayed();
});

View File

@ -0,0 +1,23 @@
export default class TradesList {
colIdPrice = 'price';
colIdSize = 'size';
colIdCreatedAt = 'createdAt';
verifyTradesListDisplayed() {
cy.get(`[col-id=${this.colIdPrice}]`).each(($tradePrice) => {
cy.wrap($tradePrice).invoke('text').should('not.be.empty');
});
cy.get(`[col-id=${this.colIdSize}]`).each(($tradeSize) => {
cy.wrap($tradeSize).invoke('text').should('not.be.empty');
});
const dateTimeRegex =
/(\d{1,2})\/(\d{1,2})\/(\d{4}), (\d{1,2}):(\d{1,2}):(\d{1,2})/gm;
cy.get(`[col-id=${this.colIdCreatedAt}]`).each(($tradeDateTime, index) => {
if (index != 0) {
//ignore header
cy.wrap($tradeDateTime).invoke('text').should('match', dateTimeRegex);
}
});
}
}