Test/249 convert js files to ts (#255)
* Explorer-e2e files changed to ts * Files on trading app converted * Fix type error and update Cypress * Remove Jquery type * Update Cypress version in package.json
This commit is contained in:
parent
6079e2027d
commit
753cff95b9
@ -50,7 +50,7 @@ export default class BasePage {
|
||||
cy.get(`a[href='${this.validatorsUrl}']`).click();
|
||||
}
|
||||
|
||||
search(searchText) {
|
||||
search(searchText: string) {
|
||||
if (searchText) {
|
||||
cy.getByTestId(this.searchField).type(searchText);
|
||||
}
|
||||
@ -64,7 +64,7 @@ export default class BasePage {
|
||||
cy.getByTestId(this.openMobileMenuBtn).click({ force: true });
|
||||
}
|
||||
|
||||
validateUrl(expectedUrl) {
|
||||
validateUrl(expectedUrl: string) {
|
||||
cy.url().should('include', expectedUrl);
|
||||
}
|
||||
|
||||
@ -76,13 +76,13 @@ export default class BasePage {
|
||||
cy.getByTestId(this.searchField).should('be.visible');
|
||||
}
|
||||
|
||||
validateSearchErrorDisplayed(errorMessage) {
|
||||
validateSearchErrorDisplayed(errorMessage: string) {
|
||||
cy.getByTestId(this.searchError).should('have.text', errorMessage);
|
||||
}
|
||||
|
||||
validateBlockDataDisplayed(headerTestId) {
|
||||
validateBlockDataDisplayed(headerTestId: string) {
|
||||
cy.getByTestId(headerTestId).then(($assetHeaders) => {
|
||||
const headersAmount = parseInt($assetHeaders.length);
|
||||
const headersAmount = Number($assetHeaders.length);
|
||||
|
||||
cy.wrap($assetHeaders).each(($header) => {
|
||||
expect($header).to.not.be.empty;
|
@ -86,7 +86,7 @@ export default class BlocksPage extends BasePage {
|
||||
cy.getByTestId(this.nextBlockBtn).click();
|
||||
}
|
||||
|
||||
jumpToBlock(blockNumber) {
|
||||
jumpToBlock(blockNumber: string) {
|
||||
cy.getByTestId(this.jumpToBlockInput).type(blockNumber);
|
||||
cy.getByTestId(this.jumpToBlockSubmit).click();
|
||||
}
|
@ -53,7 +53,7 @@ export default class MarketPage extends BasePage {
|
||||
);
|
||||
}
|
||||
|
||||
clickOnMarket(text) {
|
||||
clickOnMarket(text: string) {
|
||||
cy.contains(text).click();
|
||||
}
|
||||
}
|
@ -4,27 +4,27 @@ import DealTicket from '../trading-windows/deal-ticket';
|
||||
const dealTicket = new DealTicket();
|
||||
|
||||
When('I place a buy {string} market order', (orderType) => {
|
||||
dealTicket.placeMarketOrder(true, 100, orderType);
|
||||
dealTicket.placeMarketOrder(true, '100', orderType);
|
||||
dealTicket.clickPlaceOrder();
|
||||
});
|
||||
|
||||
When('I place a sell {string} market order', (orderType) => {
|
||||
dealTicket.placeMarketOrder(false, 100, orderType);
|
||||
dealTicket.placeMarketOrder(false, '100', orderType);
|
||||
dealTicket.clickPlaceOrder();
|
||||
});
|
||||
|
||||
When('I place a buy {string} limit order', (limitOrderType) => {
|
||||
dealTicket.placeLimitOrder(true, 100, 2000, limitOrderType);
|
||||
dealTicket.placeLimitOrder(true, '100', '2000', limitOrderType);
|
||||
dealTicket.clickPlaceOrder();
|
||||
});
|
||||
|
||||
When('I place a sell {string} limit order', (limitOrderType) => {
|
||||
dealTicket.placeLimitOrder(false, 100, 2000, limitOrderType);
|
||||
dealTicket.placeLimitOrder(false, '100', '2000', limitOrderType);
|
||||
dealTicket.clickPlaceOrder();
|
||||
});
|
||||
|
||||
When('I place a buy {string} market order with amount of 0', (orderType) => {
|
||||
dealTicket.placeMarketOrder(true, 0, orderType);
|
||||
dealTicket.placeMarketOrder(true, '0', orderType);
|
||||
dealTicket.clickPlaceOrder();
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ import { generateDealTicketQuery } from '../../../../../libs/deal-ticket/src/__t
|
||||
import { generateMarket } from '../../../../trading/pages/markets/__tests__';
|
||||
/* eslint-enable @nrwl/nx/enforce-module-boundaries */
|
||||
|
||||
const mockMarket = (state) => {
|
||||
const mockMarket = (state: MarketState) => {
|
||||
cy.mockGQL('Market', (req) => {
|
||||
if (hasOperationName(req, 'Market')) {
|
||||
req.reply({
|
@ -8,12 +8,13 @@ export default class DealTicket {
|
||||
orderTypeDropDown = 'order-tif';
|
||||
datePickerField = 'date-picker-field';
|
||||
placeOrderBtn = 'place-order';
|
||||
placeOrderFormError = 'dealticket-error-message';
|
||||
orderDialog = 'order-wrapper';
|
||||
orderStatusHeader = 'order-status-header';
|
||||
orderTransactionHash = 'tx-hash';
|
||||
orderErrorTxt = 'error-reason';
|
||||
|
||||
placeMarketOrder(isBuy, orderSize, orderType) {
|
||||
placeMarketOrder(isBuy: boolean, orderSize: string, orderType: string) {
|
||||
cy.get(`[data-testid=${this.placeOrderBtn}]`, { timeout: 8000 }).should(
|
||||
'be.visible'
|
||||
);
|
||||
@ -26,7 +27,12 @@ export default class DealTicket {
|
||||
cy.getByTestId(this.orderTypeDropDown).select(orderType);
|
||||
}
|
||||
|
||||
placeLimitOrder(isBuy, orderSize, orderPrice, orderType) {
|
||||
placeLimitOrder(
|
||||
isBuy: boolean,
|
||||
orderSize: string,
|
||||
orderPrice: string,
|
||||
orderType: string
|
||||
) {
|
||||
cy.getByTestId(this.limitOrderType).click();
|
||||
|
||||
if (isBuy == false) {
|
||||
@ -71,14 +77,14 @@ export default class DealTicket {
|
||||
cy.getByTestId(this.placeOrderBtn).should('be.disabled');
|
||||
}
|
||||
|
||||
verifySubmitBtnErrorText(expectedText) {
|
||||
verifySubmitBtnErrorText(expectedText: string) {
|
||||
cy.getByTestId('dealticket-error-message').should(
|
||||
'have.text',
|
||||
expectedText
|
||||
);
|
||||
}
|
||||
|
||||
verifyOrderRejected(errorMsg) {
|
||||
verifyOrderRejected(errorMsg: string) {
|
||||
cy.getByTestId(this.orderStatusHeader).should(
|
||||
'have.text',
|
||||
'Order rejected by wallet'
|
||||
@ -90,8 +96,8 @@ export default class DealTicket {
|
||||
|
||||
reloadPageIfPublicKeyErrorDisplayed() {
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find(`[data-testid=${this.inputError}]`).length) {
|
||||
cy.getByTestId(this.inputError)
|
||||
if ($body.find(`[data-testid=${this.placeOrderFormError}]`).length) {
|
||||
cy.getByTestId(this.placeOrderFormError)
|
||||
.invoke('text')
|
||||
.then(($errorText) => {
|
||||
if ($errorText == 'No public key selected') {
|
||||
@ -102,8 +108,8 @@ export default class DealTicket {
|
||||
});
|
||||
}
|
||||
|
||||
formatDate(date) {
|
||||
const padZero = (num) => num.toString().padStart(2, '0');
|
||||
formatDate(date: Date) {
|
||||
const padZero = (num: number) => num.toString().padStart(2, '0');
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = padZero(date.getMonth() + 1);
|
@ -12,7 +12,7 @@ export default class VegaWallet {
|
||||
cy.getByTestId(this.walletConnectors).find('button').click();
|
||||
}
|
||||
|
||||
fillInWalletForm(walletName, walletPassphrase) {
|
||||
fillInWalletForm(walletName: string, walletPassphrase: string) {
|
||||
cy.getByTestId(this.walletForm)
|
||||
.find('#wallet')
|
||||
.click({ force: true })
|
@ -1,11 +1,13 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
declare namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
getByTestId(selector: string): Chainable<JQuery<HTMLElement>>;
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
getByTestId(selector: string): Chainable<JQuery<HTMLElement>>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export function addGetTestIdcommand() {
|
||||
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
|
||||
Cypress.Commands.add('getByTestId', (selector, ...args) => {
|
||||
|
@ -1,10 +1,12 @@
|
||||
import type { RouteHandler } from 'cypress/types/net-stubbing';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
declare namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
mockGQL(alias: string, handler: RouteHandler): void;
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
mockGQL(alias: string, handler: RouteHandler): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,13 @@ import merge from 'lodash/merge';
|
||||
import type { TransactionResponse } from '@vegaprotocol/vegawallet-service-api-client';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
declare namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
mockVegaCommandSync(txHash: string, signature: string): void;
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
mockVegaCommandSync(override: PartialDeep<TransactionResponse>): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
declare namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
slack(message: string): void;
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
slack(message: string): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@
|
||||
"@typescript-eslint/parser": "~5.10.0",
|
||||
"babel-jest": "27.2.3",
|
||||
"babel-loader": "8.1.0",
|
||||
"cypress": "^9.5.1",
|
||||
"cypress": "^9.5.4",
|
||||
"cypress-cucumber-preprocessor": "^4.3.1",
|
||||
"eslint": "~8.7.0",
|
||||
"eslint-config-next": "12.0.7",
|
||||
|
10
yarn.lock
10
yarn.lock
@ -9796,10 +9796,10 @@ cypress-cucumber-preprocessor@^4.3.1:
|
||||
minimist "^1.2.5"
|
||||
through "^2.3.8"
|
||||
|
||||
cypress@^9.5.1:
|
||||
version "9.5.2"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.5.2.tgz#8fb6ee4a890fbc35620800810bf6fb11995927bd"
|
||||
integrity sha512-gYiQYvJozMzDOriUV1rCt6CeRM/pRK4nhwGJj3nJQyX2BoUdTCVwp30xDMKc771HiNVhBtgj5o5/iBdVDVXQUg==
|
||||
cypress@9.5.4:
|
||||
version "9.5.4"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.5.4.tgz#49d9272f62eba12f2314faf29c2a865610e87550"
|
||||
integrity sha512-6AyJAD8phe7IMvOL4oBsI9puRNOWxZjl8z1lgixJMcgJ85JJmyKeP6uqNA0dI1z14lmJ7Qklf2MOgP/xdAqJ/Q==
|
||||
dependencies:
|
||||
"@cypress/request" "^2.88.10"
|
||||
"@cypress/xvfb" "^1.2.4"
|
||||
@ -9833,7 +9833,7 @@ cypress@^9.5.1:
|
||||
listr2 "^3.8.3"
|
||||
lodash "^4.17.21"
|
||||
log-symbols "^4.0.0"
|
||||
minimist "^1.2.5"
|
||||
minimist "^1.2.6"
|
||||
ospath "^1.2.2"
|
||||
pretty-bytes "^5.6.0"
|
||||
proxy-from-env "1.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user