From 868898b2247f294e0ee3fe34f57d068294ec24a2 Mon Sep 17 00:00:00 2001 From: tudorgabriel Date: Fri, 26 Apr 2024 11:25:51 +0300 Subject: [PATCH] Add url scripts (#223) * url scripts added --- .../test/specs/KeystoreScreen/Keystore.e2e.ts | 28 +------ .../NegativeTests.e2e.ts} | 23 +++-- .../{PemScreen => NegativeTests}/actions.ts | 26 +++--- wdio/test/specs/URLScripts/URLScripts.ts | 84 +++++++++++++++++++ wdio/test/utils/actions.ts | 13 ++- wdio/test/utils/enums.ts | 8 +- wdio/wdio.conf.ts | 16 ++-- 7 files changed, 136 insertions(+), 62 deletions(-) rename wdio/test/specs/{PemScreen/PemSpec.e2e.ts => NegativeTests/NegativeTests.e2e.ts} (62%) rename wdio/test/specs/{PemScreen => NegativeTests}/actions.ts (82%) create mode 100644 wdio/test/specs/URLScripts/URLScripts.ts diff --git a/wdio/test/specs/KeystoreScreen/Keystore.e2e.ts b/wdio/test/specs/KeystoreScreen/Keystore.e2e.ts index b1e25ba1..cd172a5f 100644 --- a/wdio/test/specs/KeystoreScreen/Keystore.e2e.ts +++ b/wdio/test/specs/KeystoreScreen/Keystore.e2e.ts @@ -31,8 +31,7 @@ describe('Ping & Pong ABI test', () => { describe('batch transactions', () => { beforeEach(async () => { - await browser.url('https://integration.template-dapp.multiversx.com/'); - await $(GlobalSelectorEnum.connectBtn).click(); + await accesDaap(); }); it('should sign swap & lock transactions', async () => { @@ -44,7 +43,7 @@ describe('batch transactions', () => { await login(loginData); await batchTransactions(GlobalSelectorEnum.swapLockType); await validateToast(GlobalSelectorEnum.toastSelector); - await browser.pause(4500); + await browser.pause(120000); await validateTransaction(TransactionIndexEnum.swapLock); }); }); @@ -81,29 +80,6 @@ describe('PEM', () => { }); }); -describe('Close the wallet test', () => { - beforeEach(async () => { - await accesDaap(); - }); - it('should close the wallet', async () => { - const loginData = { - selector: GlobalSelectorEnum.keystoreBtn, - file: GlobalDataEnum.keystoreFile, - adress: WalletAdressEnum.adress3 - }; - await login(loginData); - await $(GlobalSelectorEnum.batchBtn).click(); - await browser.pause(2500); - await browser.switchWindow(GlobalDataEnum.walletWindow); - for (let i = 0; i < 3; i++) { - await $(GlobalSelectorEnum.accesPass).setValue(`invalid+${i}`); - await $(GlobalSelectorEnum.accesWalletBtn).click(); - await browser.pause(2000); - } - await checkOpenTabs(); - }); -}); - describe('Batch controoled sending', () => { beforeEach(async () => { await accesDaap(); diff --git a/wdio/test/specs/PemScreen/PemSpec.e2e.ts b/wdio/test/specs/NegativeTests/NegativeTests.e2e.ts similarity index 62% rename from wdio/test/specs/PemScreen/PemSpec.e2e.ts rename to wdio/test/specs/NegativeTests/NegativeTests.e2e.ts index d4806f04..ba69dc8d 100644 --- a/wdio/test/specs/PemScreen/PemSpec.e2e.ts +++ b/wdio/test/specs/NegativeTests/NegativeTests.e2e.ts @@ -3,26 +3,25 @@ import { GlobalSelectorEnum, WalletAdressEnum } from '../../utils/enums.ts'; -import { login, pingPongHandler } from '../../utils/actions.ts'; +import { accesDaap, login } from '../../utils/actions.ts'; import { closeTransaction, closeTemplateModal, closeWalletTab, reloadWalletWindow, cancelTrasaction, - notConfirmPem, - signMsg + signMsg, + notConfirmPass } from './actions.ts'; -describe('Sign transactions with PEM', () => { +describe('Negative tests', () => { beforeEach(async () => { const loginData = { - selector: GlobalSelectorEnum.pemBtn, - file: GlobalDataEnum.pemFile, - adress: WalletAdressEnum.adress1 + selector: GlobalSelectorEnum.keystoreBtn, + file: GlobalDataEnum.keystoreFile, + adress: WalletAdressEnum.adress4 }; - await browser.url('https://integration.template-dapp.multiversx.com/'); - await $(GlobalSelectorEnum.connectBtn).click(); + await accesDaap(); await login(loginData); }); @@ -50,11 +49,11 @@ describe('Sign transactions with PEM', () => { await cancelTrasaction(); }); - it('should return error for invalid confirmation PEM', async () => { - await notConfirmPem(); + it('should close window for 3 wrong passwords', async () => { + await notConfirmPass(); }); - it('should sign msg with PEM', async () => { + it('should sign msg', async () => { await signMsg(); }); }); diff --git a/wdio/test/specs/PemScreen/actions.ts b/wdio/test/specs/NegativeTests/actions.ts similarity index 82% rename from wdio/test/specs/PemScreen/actions.ts rename to wdio/test/specs/NegativeTests/actions.ts index af71cf70..5054e20a 100644 --- a/wdio/test/specs/PemScreen/actions.ts +++ b/wdio/test/specs/NegativeTests/actions.ts @@ -3,22 +3,23 @@ import { checkUrl, initTransaction, uploadFile, - confimPem + confimPem, + confirmPass } from '../../utils/actions.ts'; import { GlobalDataEnum, GlobalSelectorEnum } from '../../utils/enums.ts'; export async function closeTransaction() { const transactionCanceledModal = 'body*=Transaction canceled'; await initTransaction(); - const closeSelectors = await $$(GlobalSelectorEnum.modalCloseBtn); - await $(closeSelectors[1]).click(); + await browser.pause(3000); + const closeSelectors = await $(GlobalSelectorEnum.keystoreCloseModalBtn); + await $(closeSelectors).click(); const allHandles = await browser.getWindowHandles(); expect(allHandles.length).toEqual(1); await browser.switchWindow(GlobalDataEnum.daapWindow); await expect($(transactionCanceledModal)).toBeDisplayed(); await initTransaction(); - await uploadFile(GlobalDataEnum.pemFile); - await $(GlobalSelectorEnum.accesWalletBtn).click(); + await confirmPass(); await expect($(GlobalSelectorEnum.signBtn)).toBeDisplayed(); } @@ -58,16 +59,19 @@ export async function reloadWalletWindow() { export async function cancelTrasaction() { await initTransaction(); - await uploadFile(GlobalDataEnum.pemFile); - await $(GlobalSelectorEnum.accesWalletBtn).click(); + await confirmPass(); await $(GlobalSelectorEnum.closeBtn).click(); await checkOpenTabs(); } -export async function notConfirmPem() { +export async function notConfirmPass() { await initTransaction(); - await uploadFile(GlobalDataEnum.invalidPem); - await expect($(GlobalSelectorEnum.errorMsg)).toBeDisplayed(); + for (let i = 0; i < 3; i++) { + await $(GlobalSelectorEnum.accesPass).setValue('test'); + await $(GlobalSelectorEnum.accesWalletBtn).click(); + } + await browser.pause(1000); + await checkOpenTabs(); } export async function signMsg() { @@ -75,7 +79,7 @@ export async function signMsg() { await $(GlobalSelectorEnum.signMsgBtn).click(); await browser.pause(1000); await browser.switchWindow(GlobalDataEnum.walletWindow); - await confimPem(GlobalDataEnum.pemFile); + await confirmPass(); await $(GlobalSelectorEnum.signMsgWalletBtn).click(); await browser.pause(1000); await browser.switchWindow(GlobalDataEnum.daapWindow); diff --git a/wdio/test/specs/URLScripts/URLScripts.ts b/wdio/test/specs/URLScripts/URLScripts.ts new file mode 100644 index 00000000..afaa3647 --- /dev/null +++ b/wdio/test/specs/URLScripts/URLScripts.ts @@ -0,0 +1,84 @@ +import { + accesDaap, + batchTransactions, + login, + pingPongHandler, + validateToast, + validateTransaction +} from '../../utils/actions.ts'; +import { + GlobalSelectorEnum, + GlobalDataEnum, + WalletAdressEnum, + TransactionIndexEnum +} from '../../utils/enums.ts'; +import { closeTransaction } from '../NegativeTests/actions.ts'; + +describe('Connect via URL - Ping & Pong ABI Test', () => { + beforeEach(async () => { + await accesDaap(); + }); + + it('should connect via URL and sign ping&pong ABI', async () => { + const loginData = { + selector: GlobalSelectorEnum.keystoreBtn, + file: GlobalDataEnum.keystoreFile, + adress: WalletAdressEnum.adress2, + urlConnect: true + }; + await login(loginData); + await pingPongHandler(GlobalSelectorEnum.abiType); + }); +}); + +describe('Connect via URL with PEM', () => { + beforeEach(async () => { + await accesDaap(); + }); + + it('connect via URL and sign transaction with PEM', async () => { + const loginData = { + selector: GlobalSelectorEnum.pemBtn, + file: GlobalDataEnum.pemFile, + adress: WalletAdressEnum.adress3, + urlConnect: true + }; + await login(loginData); + await pingPongHandler(GlobalSelectorEnum.abiType); + }); +}); + +describe('Connect via URL and Sign & Batch', () => { + beforeEach(async () => { + await accesDaap(); + }); + it('connecg via URL sign sign & batch ', async () => { + const loginData = { + selector: GlobalSelectorEnum.keystoreBtn, + file: GlobalDataEnum.keystoreFile, + adress: WalletAdressEnum.adress3, + urlConnect: true + }; + await login(loginData); + await batchTransactions(GlobalSelectorEnum.signAndBatchType); + await validateToast(GlobalSelectorEnum.toastSelector); + await browser.pause(4500); + await validateTransaction(TransactionIndexEnum.signBatch); + }); +}); + +describe('Connect via URL and close transaction', () => { + beforeEach(async () => { + const loginData = { + selector: GlobalSelectorEnum.keystoreBtn, + file: GlobalDataEnum.keystoreFile, + adress: WalletAdressEnum.adress4, + urlConnect: true + }; + await accesDaap(); + await login(loginData); + }); + it('should connect via URL and cancel transaction from wallet', async () => { + await closeTransaction(); + }); +}); diff --git a/wdio/test/utils/actions.ts b/wdio/test/utils/actions.ts index 46d6a1ee..6a2187b2 100644 --- a/wdio/test/utils/actions.ts +++ b/wdio/test/utils/actions.ts @@ -33,10 +33,16 @@ export async function login(payload: { selector: string; file: string; adress: string; + urlConnect?: boolean; }) { const wallet = await $(`[data-testid*=${payload.adress}]`); + if (payload.urlConnect) { + await $(GlobalSelectorEnum.legacyWebWalletLoginDropdownButton).click(); + await $(GlobalSelectorEnum.legacyDropdownValue).click(); + } else { + await $(GlobalSelectorEnum.crossWindowLoginBtn).click(); + } - await $(GlobalSelectorEnum.crossWindowLoginBtn).click(); await browser.pause(4500); await browser.switchWindow(GlobalDataEnum.walletWindow); await $(payload.selector).click(); @@ -49,7 +55,7 @@ export async function login(payload: { } else { await $(GlobalSelectorEnum.accesWalletBtn).click(); } - await browser.pause(1000); + await browser.pause(3000); await browser.switchWindow(GlobalDataEnum.daapWindow); } @@ -74,6 +80,7 @@ export async function initTransaction() { export async function confirmPass() { await $(GlobalSelectorEnum.accesPass).setValue(GlobalDataEnum.globalPassword); + await browser.pause(500); await $(GlobalSelectorEnum.accesWalletBtn).click(); } @@ -153,6 +160,7 @@ export const scTransaction = async (type: string) => { await $(btn).click(); await browser.pause(3000); await browser.switchWindow(GlobalDataEnum.walletWindow); + await browser.pause(1500); if (!(await $(GlobalSelectorEnum.accesPass).isDisplayed())) { await confimPem(GlobalDataEnum.pemFile); await $(GlobalSelectorEnum.signBtn).click(); @@ -164,6 +172,7 @@ export const scTransaction = async (type: string) => { await browser.switchWindow(GlobalDataEnum.daapWindow); await validateToast(GlobalSelectorEnum.toastSelector); await validateTransaction(TransactionIndexEnum.ping); + await browser.pause(5000); } }; diff --git a/wdio/test/utils/enums.ts b/wdio/test/utils/enums.ts index f2943710..365a5b5f 100644 --- a/wdio/test/utils/enums.ts +++ b/wdio/test/utils/enums.ts @@ -62,6 +62,8 @@ export enum GlobalSelectorEnum { deployContract = 'Deploy Contract', walletConnectBtn = 'Connect Your Wallet', crossWindowLoginBtn = '[data-testid="webWalletLoginBtn"]', + legacyWebWalletLoginDropdownButton = '[data-testid="legacyWebWalletLoginDropdownButton"]', + legacyDropdownValue = '//*[@aria-labelledby="dropdown-button"]', sendToSelfBtn = 'button*=Send to self', accesWalletBtn = '[data-testid="submitButton"]', signBtn = '[data-testid="signBtn"]', @@ -90,13 +92,15 @@ export enum GlobalSelectorEnum { controlledSendingType = 'send-transactions', swapLockType = 'swap-lock', clearBtn = '[data-testid="closeTransactionSuccessBtn"]', - batchBtn = '[data-testid="sign-auto-send"]' + batchBtn = '[data-testid="sign-auto-send"]', + keystoreCloseModalBtn = '[data-testid="keystoreCloseModalBtn"]' } export enum WalletAdressEnum { adress1 = 'erd1qtknph0q5hsm4hmjpvzusj8vgy8m48lpvclnv6jlkw4uu7sacj6smz8uhg', adress2 = 'erd16fq70uf7mdkkkv3fylawk7269ef63kv2vh5s4lrtm58aufve8dtqjlhjjn', - adress3 = 'erd1hrv7xl5xyu536cdkz2mu92jm6w93sxecrsjxe2t8y9tv4er24a2qhfqkkr' + adress3 = 'erd1hrv7xl5xyu536cdkz2mu92jm6w93sxecrsjxe2t8y9tv4er24a2qhfqkkr', + adress4 = 'erd1ljyvg76hnt0wnj3asmte3nfxhcl8cxsukmz94kc56emhwvvm8lgsptux0y' } export enum TransactionIndexEnum { diff --git a/wdio/wdio.conf.ts b/wdio/wdio.conf.ts index ebe9ac71..1177e45c 100644 --- a/wdio/wdio.conf.ts +++ b/wdio/wdio.conf.ts @@ -15,14 +15,15 @@ export const config: Options.Testrunner = { specs: ['./test/specs/**/*.ts'], suites: { smoke: [ - './test/specs/PemScreen/PemSpec.e2e.ts', - './test/specs/KeystoreScreen/Keystore.e2e.ts' + './test/specs/KeystoreScreen/Keystore.e2e.ts', + './test/specs/URLScripts/URLScripts.ts', + './test/specs/NegativeTests/NegativeTests.e2e.ts' ] }, // Patterns to exclude. exclude: [], - maxInstances: 4, + maxInstances: 1, specFileRetries: 1, specFileRetriesDeferred: true, @@ -38,23 +39,20 @@ export const config: Options.Testrunner = { ] }, acceptInsecureCerts: true - }, - { - browserName: 'safari' } ], logLevel: 'error', bail: 0, - waitforTimeout: 10000, - connectionRetryTimeout: 120000, + waitforTimeout: 250000, + connectionRetryTimeout: 12000, connectionRetryCount: 2, framework: 'mocha', groupLogsByTestSpec: true, reporters: ['spec', 'concise'], mochaOpts: { ui: 'bdd', - timeout: 160000 + timeout: 250000 }, before: () => {} };