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

test: deposit default test with handling fee change requests #88

Closed
wants to merge 17 commits into from
Closed
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
"@artifacts and @various",
"@artifacts and @transactionsItems",
"@transactions and @withdraw",
"@transactions and @deposit and @blockchain",
"@various and @emptyWallet",
"@actions and @contacts"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
name: E2E
secrets: inherit
with:
targetUrl: ${{ needs.build.outputs.dappUrl }}
targetUrl: ${{ needs.deploy.outputs.dappUrl }}
network: Goerli
publish_to_allure: true
environmentTags: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@deposit @regression @transactions @blockchain
Feature: Deposit

Background:
Given Connect Metamask extension with login action

@id1418
Scenario: Make a deposit in ETH
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"
abilevych marked this conversation as resolved.
Show resolved Hide resolved
Then Fee should have "$" value
Then Fee should have "ETH" value
When I choose "ETH" as token and insert "0.0000000001" as amount
When I "confirm" transaction after clicking "Add funds to zkSync Era Testnet" button
Then Message "Transaction submitted" should be visible

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 if (elementType === "id") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else if (checkType === "empty") {
await expect(element).toHaveValue("");
} else if (checkType === "filled") {
await expect(element).toHaveValue(null);
}

await expect(element).toHaveValue(checkType);
}
}
}
4 changes: 4 additions & 0 deletions tests/e2e/src/pages/main.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class MainPage extends BasePage {
return `//*[@type='button' and contains(., '${buttonName}')] | //button[text()[contains(string(), '${buttonName}')]]`;
}

get confirmFeeChangeButton() {
return "//button[text()='Confirm']";
}

async selectTransaction(transactionType: string) {
try {
let route: string;
Expand Down
29 changes: 21 additions & 8 deletions tests/e2e/src/pages/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { setTimeout } from "timers/promises";

import { BasePage } from "./base.page";
import { MainPage } from "./main.page";
import { Extension } from "../data/data";
import { depositTag, Helper } from "../helpers/helper";
import { config, wallet } from "../support/config";
Expand Down Expand Up @@ -35,6 +36,9 @@ export class MetamaskPage extends BasePage {
get feeChangerBtn() {
return "//div[@class='edit-gas-display']//button";
}
get feeChangerAlert() {
return "//p[contains(text(), 'Fee has changed')]";
}

get saveFeeBtn() {
return "//*[@class='popover-container']//button";
Expand Down Expand Up @@ -176,15 +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(config.minimalTimeout.timeout);
await popUpContext?.setViewportSize(config.popUpWindowSize);
await popUpContext?.click(this.confirmTransaction);
}
Expand All @@ -196,11 +195,25 @@ export class MetamaskPage extends BasePage {
const [popUp] = await Promise.all([
this.world.context?.waitForEvent("page"),
await helper.checkElementVisible(element),
await this.world.page?.locator(element).first().click(),
await await this.world.page?.locator(element).first().click(),
await setTimeout(config.defaultTimeout.timeout),
await this.isFeeAlert(element),
]);

return popUp;
}

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.confirmFeeChangeButton);
await this.click(mainPage.confirmFeeChangeButton);
await this.catchPopUpByClick(element);
}
}

async catchPopUp() {
const [popUp] = await Promise.all([this.world.context?.waitForEvent("page")]);
return popUp;
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/src/steps/portal.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,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?.waitForSelector(element);
result = await this.page?.locator(element);
await expect(result).toContainText(fee);
});
Expand Down