Skip to content

Commit

Permalink
added locators and method for URI modals
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebyt committed May 7, 2024
1 parent e3131eb commit b5845e4
Showing 1 changed file with 124 additions and 1 deletion.
125 changes: 124 additions & 1 deletion packages/e2e-tests/pages/wallet/walletTab/receiveSubTab.page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,102 @@
import WalletTab from './walletTab.page.js';
import BasePage from '../../basepage.js';
import { twoSeconds, quarterSecond } from '../../../helpers/timeConstants.js';

class GenerateURIModal extends BasePage {
// locators
generateURIModalLocator = {
locator: 'uriGenerateDialog-dialogWindow-modalWindow',
method: 'id',
};
generateURIModalTitleLocator = {
locator: 'uriGenerateDialog-dialogTitle-text',
method: 'id',
};
generateButtonLocator = {
locator: 'uriGenerateDialog-generate-button',
method: 'id',
};
closeModalButtonLocator = {
locator: 'uriGenerateDialog-closeModal-button',
method: 'id',
};
receiverAddressTextLocator = {
locator: '//input[starts-with(@id, "receiver--")]', // unfortunately, I didn't find a way to make a proper ID
method: 'xpath',
};
amountToSendInputLocator = {
locator: '//input[starts-with(@id, "amount--")]', // unfortunately, I didn't find a way to make a proper ID
method: 'xpath',
};
// methods
async getReceiverAddress() {
this.logger.info(`ReceiveSubTab::GenerateURIModal::getReceiverAddress is called.`);
const address = await this.getAttribute(this.receiverAddressTextLocator, 'value');
this.logger.info(`ReceiveSubTab::GenerateURIModal::getReceiverAddress::address - "${address}"`);
return address
}
async enterReceiveAmount(adaAmount) {
this.logger.info(`ReceiveSubTab::GenerateURIModal::enterReceiveAmount is called.`);
await this.click(this.amountToSendInputLocator);
await this.input(this.amountToSendInputLocator, adaAmount);
}
async generateLink() {
this.logger.info(`ReceiveSubTab::GenerateURIModal::generateLink is called.`);
const buttonIsEnabled = await this.customWaiter(
async () => {
const buttonlIsEnabled = await this.getAttribute(this.generateButtonLocator, 'disabled');
return buttonlIsEnabled === null;
},
twoSeconds,
quarterSecond
);
if (buttonIsEnabled) {
await this.click(this.generateButtonLocator);
} else {
throw new Error('The Continue button is disabled');
}
}
}

class DisplayURIModal extends BasePage {
// locators
uriDisplayModalLocator = {
locator: 'uriDisplayDialog-dialogWindow-modalWindow',
method: 'id',
};
uriDisplayModalTitleLocator = {
locator: 'uriDisplayDialog-dialogTitle-text',
method: 'id',
};
closeModalButtonLocator = {
locator: 'uriDisplayDialog-closeModal-button',
method: 'id',
};
linkTextLocator = {
locator: 'uriDisplayDialog-address-text',
method: 'id',
};
copyLinkButtonLocator = {
locator: 'uriDisplayDialog-copyAddress-button',
method: 'id',
};
// methods
// * get the generated link
async getGeneratedLink() {
this.logger.info(`ReceiveSubTab::DisplayURIModal::getGeneratedLink is called.`);
return await this.getText(this.linkTextLocator);
}
// * click copy btn on generated link
async copyGeneratedLink() {
this.logger.info(`ReceiveSubTab::DisplayURIModal::copyGeneratedLink is called.`);
await this.click(this.copyGeneratedLink);
}
// * close the modal window
async closeModalWindow() {
this.logger.info(`ReceiveSubTab::DisplayURIModal::closeModalWindow is called.`);
await this.click(this.closeModalButtonLocator);
}
}

class ReceiveSubTab extends WalletTab {
// locators
Expand Down Expand Up @@ -106,7 +204,7 @@ class ReceiveSubTab extends WalletTab {
};
};
// * address row generate URL btn
generateURLButtonInRowLocator = rowIndex => {
generateURIButtonInRowLocator = rowIndex => {
return {
locator: `wallet:receive:infoPanel:footer:addressRow_${rowIndex}-generateUrl-button`,
method: 'id',
Expand Down Expand Up @@ -222,6 +320,7 @@ class ReceiveSubTab extends WalletTab {
}
// * get balance of displayed addresses
async getBalanceOfDisplayedAddrs() {
this.logger.info(`ReceiveSubTab::getBalanceOfDisplayedAddrs is called. Row index: ${rowIndex}`);
const addrsAmount = await this.getAmountOfAddresses();
let balance = 0;
for (let rowIndex = 0; rowIndex < addrsAmount; rowIndex++) {
Expand All @@ -230,6 +329,30 @@ class ReceiveSubTab extends WalletTab {
}
return balance;
}
// * generate link
async geneneratePaymentURI(rowIndex, adaAmount) {
this.logger.info(`ReceiveSubTab::clickGenerateURL is called. Row index: ${rowIndex}`);
const genURIBtnLocator = this.generateURIButtonInRowLocator(rowIndex);
await this.click(genURIBtnLocator);
const genLinkModal = new GenerateURIModal(this.driver, this.logger);
const selectedAddress = await genLinkModal.getReceiverAddress();
await genLinkModal.enterReceiveAmount(adaAmount);
await genLinkModal.generateLink();
const generatedURIModal = new DisplayURIModal(this.driver, this.logger);
const generatedLink = await generatedURIModal.getGeneratedLink();
await generatedURIModal.closeModalWindow();
return {
address: selectedAddress,
amount: adaAmount,
genLink: generatedLink,
};
}
async getCurrentReceiveAddr() {
this.logger.info(`ReceiveSubTab::getCurrentReceiveAddr is called.`);
const address = await this.getText(this.currentAddressToUseTextLocator);
this.logger.info(`ReceiveSubTab::getCurrentReceiveAddr::address - "${address}"`);
return address;
}
}

export default ReceiveSubTab;

0 comments on commit b5845e4

Please sign in to comment.