Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url scripts (#223) #224

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions wdio/test/specs/KeystoreScreen/Keystore.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
});
});
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -58,24 +59,27 @@ 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() {
await $(GlobalSelectorEnum.textArea).setValue('Test');
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);
Expand Down
84 changes: 84 additions & 0 deletions wdio/test/specs/URLScripts/URLScripts.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
13 changes: 11 additions & 2 deletions wdio/test/utils/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
};

Expand Down
8 changes: 6 additions & 2 deletions wdio/test/utils/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 7 additions & 9 deletions wdio/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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: () => {}
};
Loading