From 701ae4a189d79525652ece67a31c2f9e3d602cf2 Mon Sep 17 00:00:00 2001 From: tudorgabriel Date: Wed, 11 Oct 2023 15:55:04 +0300 Subject: [PATCH] Th/cypress fix (#140) * scripts updated --- cypress/constants/enums.ts | 9 ++++++++- cypress/e2e/BatchTransactions/BatchTransactions.cy.ts | 11 ++++++----- .../BatchTransactions/cancelBatchTransactions.cy.ts | 4 ++-- cypress/e2e/BatchTransactions/helpers.ts | 1 - cypress/e2e/SCTransactions/SCTransaction.cy.ts | 10 +++++----- cypress/e2e/Send/Send.cy.ts | 4 ++-- cypress/e2e/SignMessage/SignMessage.cy.ts | 4 ++-- cypress/support/commands.ts | 4 ++-- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/cypress/constants/enums.ts b/cypress/constants/enums.ts index 21f725cd..010267d2 100644 --- a/cypress/constants/enums.ts +++ b/cypress/constants/enums.ts @@ -15,9 +15,16 @@ export enum RoutesEnum { dashboard = '/dashboard' } -export enum walletIDEnum { +export enum WalletIDEnum { unguardedWallet1 = 'check_0', unguardedWallet2 = 'check_1', unguardedWallet3 = 'check_2', unguardedWallet4 = 'check_3' } + +export const enum GlobalSelectorsEnum { + connect = 'Connect', + signAutoSend = 'sign-auto-send', + sendTransactions = 'send-transactions', + swapLock = 'swap-lock' +} diff --git a/cypress/e2e/BatchTransactions/BatchTransactions.cy.ts b/cypress/e2e/BatchTransactions/BatchTransactions.cy.ts index 41b6932c..4bee9fb1 100644 --- a/cypress/e2e/BatchTransactions/BatchTransactions.cy.ts +++ b/cypress/e2e/BatchTransactions/BatchTransactions.cy.ts @@ -1,20 +1,21 @@ import { signTransactions } from './helpers'; -import { walletIDEnum } from '../../constants/enums'; +import { WalletIDEnum, GlobalSelectorsEnum } from '../../constants/enums'; describe('Batch Transaction', () => { beforeEach(() => { - cy.login(walletIDEnum.unguardedWallet1, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet1, 'Connect'); cy.wait(5000); }); it('should successfully sign 5 transactions for auto-send batch', () => { - signTransactions('sign-auto-send'); + signTransactions(GlobalSelectorsEnum.signAutoSend); }); it('should successfully sign 5 transactions for send-transactions', () => { - signTransactions('send-transactions'); + signTransactions(GlobalSelectorsEnum.sendTransactions); }); it('should successfully sign 4 transactions for swap-lock', () => { - signTransactions('swap-lock'); + cy.wait(3000); + signTransactions(GlobalSelectorsEnum.swapLock); }); }); diff --git a/cypress/e2e/BatchTransactions/cancelBatchTransactions.cy.ts b/cypress/e2e/BatchTransactions/cancelBatchTransactions.cy.ts index 91b07d7e..6450cd10 100644 --- a/cypress/e2e/BatchTransactions/cancelBatchTransactions.cy.ts +++ b/cypress/e2e/BatchTransactions/cancelBatchTransactions.cy.ts @@ -1,9 +1,9 @@ import { cancelTransactions } from './helpers'; -import { walletIDEnum } from '../../constants/enums'; +import { WalletIDEnum } from '../../constants/enums'; describe('cancelTransactions', () => { beforeEach(() => { - cy.login(walletIDEnum.unguardedWallet1, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet1, 'Connect'); cy.wait(5000); }); it('should return transaction canceled for auto-send batch ', () => { diff --git a/cypress/e2e/BatchTransactions/helpers.ts b/cypress/e2e/BatchTransactions/helpers.ts index fd855b78..8adcda6e 100644 --- a/cypress/e2e/BatchTransactions/helpers.ts +++ b/cypress/e2e/BatchTransactions/helpers.ts @@ -25,7 +25,6 @@ export const signTransactions = (selector) => { }; export const cancelTransactions = (selector) => { - // cy.visit('/dasboard#batchTransactions'); cy.getSelector(selector).click(); cy.getSelector(scSelectors.accesPass).type(userData.passsword); cy.getSelector(scSelectors.submitButton).click(); diff --git a/cypress/e2e/SCTransactions/SCTransaction.cy.ts b/cypress/e2e/SCTransactions/SCTransaction.cy.ts index fba4bd31..7379fe4a 100644 --- a/cypress/e2e/SCTransactions/SCTransaction.cy.ts +++ b/cypress/e2e/SCTransactions/SCTransaction.cy.ts @@ -2,7 +2,7 @@ import { pingPongHandler } from './SCActions'; import { scSelectors } from './SCTransactionData'; import { userData } from '../../assets/globalData'; -import { RoutesEnum, walletIDEnum } from '../../constants/enums'; +import { RoutesEnum, WalletIDEnum } from '../../constants/enums'; describe('Smart Contract Transactions', () => { afterEach(() => { @@ -10,25 +10,25 @@ describe('Smart Contract Transactions', () => { }); it('should successfully execute the Ping & Pong ABI', () => { - cy.login(walletIDEnum.unguardedWallet1, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet1, 'Connect'); cy.wait(5000); pingPongHandler('Abi'); }); it('should successfully execute the Ping & Pong RAW ', () => { - cy.login(walletIDEnum.unguardedWallet2, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet2, 'Connect'); cy.wait(5000); pingPongHandler('Raw'); }); it('should successfully execute the Ping & Pong Service', () => { - cy.login(walletIDEnum.unguardedWallet3, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet3, 'Connect'); cy.wait(5000); pingPongHandler('Raw'); }); it('should not execute ping&pong aciton', () => { - cy.login(walletIDEnum.unguardedWallet4, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet4, 'Connect'); cy.wait(5000); cy.getSelector('btnPongAbi').click(); cy.getSelector(scSelectors.accesPass).type(userData.passsword); diff --git a/cypress/e2e/Send/Send.cy.ts b/cypress/e2e/Send/Send.cy.ts index 02fd7838..efd23fc6 100644 --- a/cypress/e2e/Send/Send.cy.ts +++ b/cypress/e2e/Send/Send.cy.ts @@ -1,8 +1,8 @@ import { userData } from '../../assets/globalData'; -import { AssertionEnum, RoutesEnum, walletIDEnum } from '../../constants/enums'; +import { AssertionEnum, RoutesEnum, WalletIDEnum } from '../../constants/enums'; describe('Send', () => { beforeEach(() => { - cy.login(walletIDEnum.unguardedWallet1, 'Send transaction'); + cy.login(WalletIDEnum.unguardedWallet1, 'Send transaction'); }); it('should successfully send a demo transaction', () => { cy.checkUrl(RoutesEnum.send); diff --git a/cypress/e2e/SignMessage/SignMessage.cy.ts b/cypress/e2e/SignMessage/SignMessage.cy.ts index 69f2f9b0..40b5db92 100644 --- a/cypress/e2e/SignMessage/SignMessage.cy.ts +++ b/cypress/e2e/SignMessage/SignMessage.cy.ts @@ -1,11 +1,11 @@ import { Routes } from 'react-router-dom'; import { userData } from '../../assets/globalData'; -import { AssertionEnum, RoutesEnum, walletIDEnum } from '../../constants/enums'; +import { AssertionEnum, RoutesEnum, WalletIDEnum } from '../../constants/enums'; import { scSelectors } from '../SCTransactions/SCTransactionData'; describe('Sign Message', () => { beforeEach(() => { - cy.login(walletIDEnum.unguardedWallet1, 'Connect'); + cy.login(WalletIDEnum.unguardedWallet1, 'Connect'); cy.wait(5000); }); it('should sign', () => { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index ceafb927..5e11c753 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,6 +1,6 @@ /// import { userData } from '../assets/globalData'; -import { AssertionEnum } from '../constants/enums'; +import { AssertionEnum, GlobalSelectorsEnum } from '../constants/enums'; import { DEVNET_API } from '../constants/globalLinks'; // Check the url global function @@ -13,7 +13,7 @@ Cypress.Commands.add('login', (walletID, selector) => { cy.session(walletID, () => { cy.visit('/'); cy.contains(selector).click(); - if (selector === 'Connect') { + if (selector === GlobalSelectorsEnum.connect) { cy.getSelector('webWalletLoginBtn').click(); } cy.getSelector('keystoreBtn').click();