Skip to content

Commit

Permalink
test: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Aug 7, 2023
1 parent 572697b commit 5b655a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Feature: Deposit
Given I am on the Main page
Given I go to "Deposit" transaction section
When I click by "text" with "Your account" value
Then Element with "id" "amount-input" should be ""
Then Element with "testId" "fee-amount" should be "visible"
Then Fee should have "$" value
Then Fee should have "ETH" value
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/src/pages/base.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ export class BasePage {
} else if (checkType === "enabled") {
result = await element.isDisabled();
await expect(result).toBe(false);
} else {
await expect(element).toHaveValue(checkType);
}
}
}
4 changes: 2 additions & 2 deletions tests/e2e/src/pages/main.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class MainPage extends BasePage {
return `${this.byTestId}network-switcher`;
}

get confirmFeeChange() {
return "//*[@class='alert-body']//*[contains(string(), 'Confirm')]";
get confirmFeeChangeButton() {
return "//button[text()='Confirm']";
}

async selectTransaction(transactionType: string) {
Expand Down
29 changes: 10 additions & 19 deletions tests/e2e/src/pages/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class MetamaskPage extends BasePage {
return "//div[@class='edit-gas-display']//button";
}
get feeChangerAlert() {
return "//*[@class='alert-body']//*[contains(text(), 'Fee has changed')]";
return "//p[contains(text(), 'Fee has changed')]";
}

get saveFeeBtn() {
Expand Down Expand Up @@ -180,17 +180,10 @@ export class MetamaskPage extends BasePage {
try {
await this.switchNetwork();
} finally {
await setTimeout(2.5 * 1000);
await setTimeout(config.minimalTimeout.timeout);
await this.click(this.continueBtn);
// const confirmBtnSelector = "//*[@class='alert-body']//button";
// const confirmBtn: any = await this.world.page?.locator(confirmBtnSelector);
// if (await confirmBtn.isEnabled()) {
// console.log("spotted");
// await this.click(confirmBtn);
// }
const popUpContext = await this.catchPopUpByClick(`//span[contains(text(),'${triggeredElement}')]`);
await setTimeout(2.5 * 1000);

await setTimeout(config.minimalTimeout.timeout);
await popUpContext?.setViewportSize(config.popUpWindowSize);
await popUpContext?.click(this.confirmTransaction);
}
Expand All @@ -202,25 +195,23 @@ export class MetamaskPage extends BasePage {
const [popUp] = await Promise.all([
this.world.context?.waitForEvent("page"),
await helper.checkElementVisible(element),
//await helper.checkElementClickable(element),
await this.world.page?.locator(element).first().click(),
await setTimeout(10 * 1000),
await this.isFeeAlert(helper, element),
await await this.world.page?.locator(element).first().click(),
await setTimeout(config.defaultTimeout.timeout),
await this.isFeeAlert(element),
]);

return popUp;
}

async isFeeAlert(helper: Helper, element: string) {
async isFeeAlert(element: string) {
const helper = new Helper(this.world);
const mainPage = new MainPage(this.world);
const feeAlert = await helper.checkElementVisible(this.feeChangerAlert);
if (feeAlert) {
await helper.checkElementVisible(mainPage.confirmFeeChange);
await this.world.page?.locator(mainPage.confirmFeeChange).first().click();
await helper.checkElementVisible(mainPage.confirmFeeChangeButton);
await this.click(mainPage.confirmFeeChangeButton);
await this.catchPopUpByClick(element);
return true;
}
return false;
}

async catchPopUp() {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/src/steps/portal.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Then("Fee should have {string} value", config.stepTimeout, async function (this:
mainPage = new MainPage(this);
basePage = new BasePage(this);
element = mainPage.feeValue;
await this.page?.waitForTimeout(5000);
await this.page?.waitForSelector(element);
result = await this.page?.locator(element);
await expect(result).toContainText(fee);
});
Expand Down

0 comments on commit 5b655a2

Please sign in to comment.