refine...

This commit is contained in:
tommy
2022-11-16 17:07:06 +01:00
parent 6b74a1f091
commit 353ccbe258
3 changed files with 29 additions and 33 deletions
+14 -24
View File
@@ -75,6 +75,10 @@ class Helpers {
await element.waitForDisplayed({ timeout: 6000 });
};
elementGetText = async (element) => {
await element.getText(element);
};
elementClickable = async (element) => {
await element.toBeClickable({ timeout: 8000 });
};
@@ -93,32 +97,18 @@ class Helpers {
expect(error).toContain(expectedText);
};
// token calculations
currentBalance = async (value) => {
return parseFloat(value.split(/\s+/)[0].toString()).toFixed(5);
};
getAccountAddress = async () => {
// fix this in the future to make it generic
let address = await browser.execute(() => {
return document.querySelectorAll("[data-testid='wallet-address']")[0].innerHTML;
});
return address;
}
calculateFees = async (beforeBalance, transactionFee, amount, isSend) => {
let fee;
//removed those nasty methods as we can now get the correct txs fee from estimation
//add cleaner approach
if (isSend) {
//send transaction
fee = transactionFee.split(/\s+/)[0];
} else {
//delegate transaction
fee = transactionFee.split(/\s+/)[3];
}
const currentBalance = beforeBalance.split(/\s+/)[0];
console.log('currenttttt 2 ............. = ' + currentBalance);
const castCurrentBalance = parseFloat(currentBalance).toFixed(5);
console.log('castttt ............. ' + castCurrentBalance);
const transCost = +parseFloat(amount) + +parseFloat(fee).toFixed(5);
console.log('trans .............' + transCost);
let sum = +castCurrentBalance - transCost;
return sum.toFixed(5);
};
}
export default new Helpers();
@@ -10,12 +10,12 @@ class Balance {
}
get copyAccountId(): Promise<WebdriverIO.Element> {
return $("[data-testid='copyIcon']");
} // TO-DO check
return $("[data-testid='ContentCopyIcon']");
}
get walletAddress(): Promise<WebdriverIO.Element> {
return $("[data-testid='walletAddress']");
} // TO-DO check
return $("[data-testid='wallet-address']");
}
get networkDropdown(): Promise<WebdriverIO.Element> {
return $("[data-testid='ArrowDropDownIcon']");
@@ -15,14 +15,20 @@ describe('Balance screen displays correctly', () => {
it('copy the account id', async () => {
// ensure the account number contains *something*
await browser.pause(25000);
await Helper.elementVisible(Balance.walletAddress);
await browser.pause(15000);
await Helper.verifyPartialText(Balance.walletAddress[1], '1');
let getaccountAddress = await Helper.getAccountAddress();
console.log(getaccountAddress);
await Helper.navigateAndClick(Balance.copyAccountId);
// TO-DO is there a way to verify that the copy worked, aka pasting it somewhere maybe?
// disclaimer - I think if it's in clipboard we can use the below...
console.log(await browser.sendKeys(['Shift', 'Insert']));
// let's try using the clipboard api here - TODO
// let clipboard = await browser.execute(() => {
//
// });
//
// })
});
});