From 986d8af5ae615c74933b746426d284ee87db5daa Mon Sep 17 00:00:00 2001 From: amelnytskyi Date: Tue, 27 Feb 2024 13:15:18 +0200 Subject: [PATCH 1/4] test: create autotests for Withdraw and Account test cases --- packages/integration-tests/src/constants.ts | 1 + .../playbook/deploy/use-multitransferETH.ts | 29 +++-- .../tests/api/accounts.test.ts | 32 ++++++ .../tests/ui/withdraw.spec.ts | 105 ++++++++++++++++++ 4 files changed, 156 insertions(+), 11 deletions(-) create mode 100644 packages/integration-tests/tests/ui/withdraw.spec.ts diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index e46f4a17c5..7792b08de5 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -13,6 +13,7 @@ export enum Buffer { paymasterTx = "paymasterTx.txt", addressMultiTransferETH = "multiTransferETH.txt", txMultiTransferETH = "txMultiTransferETH.txt", + txMultiTransferCall = "txMultiTransferCall.txt", txMultiTransferCustomTokenI = "txMultiTransferCustomTokenI.txt", txMultiTransferCustomTokenII = "txMultiTransferCustomTokenII.txt", addressMultiCallMiddle = "multiCallMiddle.txt", diff --git a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts index 5447e7d380..66b0a64fd8 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts @@ -37,6 +37,7 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen const ethTransfer = await makeTransfer(etherAddress, ethers.utils.parseEther("0.101")); const customToken1Transfer = await makeTransfer(customTokenI, ethers.utils.parseUnits("1", 18)); const customToken2Transfer = await makeTransfer(customTokenII, ethers.utils.parseUnits("1", 18)); + const multiTransferResult = await makeMultiTransfer(); async function makeTransfer(token: string, amount: ethers.BigNumber) { const transfer = await wallet.transfer({ @@ -47,22 +48,27 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen }); // await commitment - const transferReceipt = await transfer.wait(1); + const transferReceipt = await transfer.waitFinalize(); console.log(`Tx transfer hash for ${token}: ${transferReceipt.transactionHash}`); return transferReceipt.transactionHash; } //call the deployed contract. - const transferFromContract = await attachedContract.multiTransfer( - [richWalletAddress, mainWalletAddress, secondaryWalletAddress], - [etherAddress, customTokenI, customTokenII], - [ethAmount, customTokenIAmount, customTokenIIAmount] - ); - if (transferFromContract) { - console.log(`Contract transfer to us!`); - } else { - console.error(`Contract said something unexpected: ${transferFromContract}`); + async function makeMultiTransfer() { + const transferFromContract = await attachedContract.multiTransfer( + [richWalletAddress, mainWalletAddress, secondaryWalletAddress], + [etherAddress, customTokenI, customTokenII], + [ethAmount, customTokenIAmount, customTokenIIAmount] + ); + if (transferFromContract) { + console.log(`Contract transfer to us!`); + const transferReceipt = await transferFromContract.waitFinalize(); + console.log(`Contract transfer transaction hash: ${transferReceipt.transactionHash}`); + return transferReceipt.transactionHash; + } else { + console.error(`Contract said something unexpected: ${transferFromContract}`); + } } // Show the contract balance @@ -90,7 +96,8 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen )}" Custom token II` ); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCall, multiTransferResult); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH, ethTransfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI, customToken1Transfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII, customToken2Transfer); -} +} \ No newline at end of file diff --git a/packages/integration-tests/tests/api/accounts.test.ts b/packages/integration-tests/tests/api/accounts.test.ts index 4ac7e0c211..3708b1fb6d 100644 --- a/packages/integration-tests/tests/api/accounts.test.ts +++ b/packages/integration-tests/tests/api/accounts.test.ts @@ -258,5 +258,37 @@ describe("API module: Account", () => { expect(typeof response.body.result[0].blockReward).toStrictEqual("string"); }); }); + + //id1854 + it("Verify /api?module=account&action=txlistinternal&txhash=", async () => { + await helper.retryTestAction(async () => { + const blocks = await request(environment.blockExplorerAPI).get("/blocks"); + const blockNumber = blocks.body.items[0].number; + const txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCall); + apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&txhash=${txHash}`; + response = await helper.performGETrequest(apiRoute); + + expect(response.status).toBe(200); + expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" })); + expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" })); + expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ hash: txHash })); + expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })); + expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ type: "call" })); + expect(typeof response.body.result[0].blockNumber).toStrictEqual("string"); + expect(typeof response.body.result[0].timeStamp).toStrictEqual("string"); + expect(typeof response.body.result[0].from).toStrictEqual("string"); + expect(typeof response.body.result[0].value).toStrictEqual("string"); + expect(typeof response.body.result[0].gas).toStrictEqual("string"); + expect(typeof response.body.result[0].input).toStrictEqual("string"); + expect(typeof response.body.result[0].contractAddress).toBeTruthy(); + expect(typeof response.body.result[0].gasUsed).toStrictEqual("string"); + expect(typeof response.body.result[0].fee).toStrictEqual("string"); + expect(typeof response.body.result[0].l1BatchNumber).toStrictEqual("string"); + expect(typeof response.body.result[0].traceId).toBeTruthy(); + expect(typeof response.body.result[0].transactionType).toStrictEqual("string"); + expect(typeof response.body.result[0].isError).toStrictEqual("string"); + expect(typeof response.body.result[0].errCode).toStrictEqual("string"); + }); + }); }); }); diff --git a/packages/integration-tests/tests/ui/withdraw.spec.ts b/packages/integration-tests/tests/ui/withdraw.spec.ts new file mode 100644 index 0000000000..ead2f95105 --- /dev/null +++ b/packages/integration-tests/tests/ui/withdraw.spec.ts @@ -0,0 +1,105 @@ +import { expect, test } from "@playwright/test"; + +import { config } from "./config"; +import { BlockExplorer, Buffer, Token, Wallets } from "../../src/entities"; +import { Helper } from "../../src/helper"; + +const bufferRoute = "src/playbook/"; +const helper = new Helper(); +let url: string; +let bufferFile; +let withdrawTxHash: string; +let fromAddress: string; +let toAddress: string; + +//@id1661 +test("Check Withdraw ETH transaction on BE", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txEthWithdraw; + withdrawTxHash = await helper.getStringFromFile(bufferFile); + url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; + fromAddress = Wallets.richWalletAddress; + console.log(url); + + await page.goto(url); + + const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); + const toAddressElement = await page + .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x36615Cf349d...c049"]`) + .first(); + const ethValue = await page.locator(`text=0.000009`).first(); + + await expect(hash).toBeVisible(config.extraTimeout); + await expect(ethValue).toBeVisible(config.extraTimeout); + await expect(fromAddressElement).toBeVisible(config.extraTimeout); + await expect(toAddressElement).toBeVisible(config.extraTimeout); +}); + +//@id1686 +test("Verify the ETH withdrawal to the other address", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txEthWithdrawOtherAddress; + withdrawTxHash = await helper.getStringFromFile(bufferFile); + url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; + fromAddress = Wallets.richWalletAddress; + console.log(url); + + await page.goto(url); + + const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); + const toAddressElement = await page + .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x586607935E1...8975"]`) + .first(); + const ethValue = await page.locator(`text=0.000009`).first(); + + await expect(hash).toBeVisible(config.extraTimeout); + await expect(ethValue).toBeVisible(config.extraTimeout); + await expect(fromAddressElement).toBeVisible(config.extraTimeout); + await expect(toAddressElement).toBeVisible(config.extraTimeout); +}); + +//@id1685 +test("Check on BE Withdraw the custom ERC-20 via Portal", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txERC20Withdraw; + withdrawTxHash = await helper.getStringFromFile(bufferFile); + url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; + fromAddress = Wallets.richWalletAddress; + console.log(url); + + await page.goto(url); + + const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); + const toAddressElement = await page + .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x36615Cf349d...c049"]`) + .first(); + const erc20Value = await page.locator(`//*[text()="0x36615Cf349d...c049"]/..//..//*[text()="0.2"]`).first(); + + await expect(hash).toBeVisible(config.extraTimeout); + await expect(erc20Value).toBeVisible(config.extraTimeout); + await expect(fromAddressElement).toBeVisible(config.extraTimeout); + await expect(toAddressElement).toBeVisible(config.extraTimeout); +}); + +//@id1664 +test("Check Withdraw transaction on BE for custom ERC-20 token to a different address", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txERC20WithdrawOtherAddress; + withdrawTxHash = await helper.getStringFromFile(bufferFile); + url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; + fromAddress = Wallets.richWalletAddress; + console.log(url); + + await page.goto(url); + + const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); + const toAddressElement = await page + .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x586607935E1...8975"]`) + .first(); + const erc20Value = await page.locator(`//*[text()="0x586607935E1...8975"]/..//..//*[text()="0.2"]`).first(); + + await expect(hash).toBeVisible(config.extraTimeout); + await expect(erc20Value).toBeVisible(config.extraTimeout); + await expect(fromAddressElement).toBeVisible(config.extraTimeout); + await expect(toAddressElement).toBeVisible(config.extraTimeout); +}); From a6bf6afcb9bb5680c8d027a02b234a99c041f733 Mon Sep 17 00:00:00 2001 From: amelnytskyi Date: Tue, 27 Feb 2024 15:02:57 +0200 Subject: [PATCH 2/4] test: create autotests for Withdraw test cases Removing obsolete variables --- packages/integration-tests/src/constants.ts | 6 +- .../playbook/deploy/use-multitransferETH.ts | 27 ++---- .../tests/api/accounts.test.ts | 32 ------- .../tests/ui/withdraw.spec.ts | 96 +++++++++---------- 4 files changed, 59 insertions(+), 102 deletions(-) diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index 7792b08de5..f165d514e9 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -13,7 +13,6 @@ export enum Buffer { paymasterTx = "paymasterTx.txt", addressMultiTransferETH = "multiTransferETH.txt", txMultiTransferETH = "txMultiTransferETH.txt", - txMultiTransferCall = "txMultiTransferCall.txt", txMultiTransferCustomTokenI = "txMultiTransferCustomTokenI.txt", txMultiTransferCustomTokenII = "txMultiTransferCustomTokenII.txt", addressMultiCallMiddle = "multiCallMiddle.txt", @@ -84,3 +83,8 @@ export enum BlockExplorer { baseUrl = "http://localhost:3010", localNetwork = "/?network=local", } + +const txSumETH = "0.000009"; +export const Values = { + txSumETH: txSumETH, +}; \ No newline at end of file diff --git a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts index 66b0a64fd8..7e5bf49438 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts @@ -37,7 +37,6 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen const ethTransfer = await makeTransfer(etherAddress, ethers.utils.parseEther("0.101")); const customToken1Transfer = await makeTransfer(customTokenI, ethers.utils.parseUnits("1", 18)); const customToken2Transfer = await makeTransfer(customTokenII, ethers.utils.parseUnits("1", 18)); - const multiTransferResult = await makeMultiTransfer(); async function makeTransfer(token: string, amount: ethers.BigNumber) { const transfer = await wallet.transfer({ @@ -48,27 +47,22 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen }); // await commitment - const transferReceipt = await transfer.waitFinalize(); + const transferReceipt = await transfer.wait(1); console.log(`Tx transfer hash for ${token}: ${transferReceipt.transactionHash}`); return transferReceipt.transactionHash; } //call the deployed contract. - async function makeMultiTransfer() { - const transferFromContract = await attachedContract.multiTransfer( - [richWalletAddress, mainWalletAddress, secondaryWalletAddress], - [etherAddress, customTokenI, customTokenII], - [ethAmount, customTokenIAmount, customTokenIIAmount] - ); - if (transferFromContract) { - console.log(`Contract transfer to us!`); - const transferReceipt = await transferFromContract.waitFinalize(); - console.log(`Contract transfer transaction hash: ${transferReceipt.transactionHash}`); - return transferReceipt.transactionHash; - } else { - console.error(`Contract said something unexpected: ${transferFromContract}`); - } + const transferFromContract = await attachedContract.multiTransfer( + [richWalletAddress, mainWalletAddress, secondaryWalletAddress], + [etherAddress, customTokenI, customTokenII], + [ethAmount, customTokenIAmount, customTokenIIAmount] + ); + if (transferFromContract) { + console.log(`Contract transfer to us!`); + } else { + console.error(`Contract said something unexpected: ${transferFromContract}`); } // Show the contract balance @@ -96,7 +90,6 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen )}" Custom token II` ); - await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCall, multiTransferResult); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH, ethTransfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI, customToken1Transfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII, customToken2Transfer); diff --git a/packages/integration-tests/tests/api/accounts.test.ts b/packages/integration-tests/tests/api/accounts.test.ts index 3708b1fb6d..4ac7e0c211 100644 --- a/packages/integration-tests/tests/api/accounts.test.ts +++ b/packages/integration-tests/tests/api/accounts.test.ts @@ -258,37 +258,5 @@ describe("API module: Account", () => { expect(typeof response.body.result[0].blockReward).toStrictEqual("string"); }); }); - - //id1854 - it("Verify /api?module=account&action=txlistinternal&txhash=", async () => { - await helper.retryTestAction(async () => { - const blocks = await request(environment.blockExplorerAPI).get("/blocks"); - const blockNumber = blocks.body.items[0].number; - const txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCall); - apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&txhash=${txHash}`; - response = await helper.performGETrequest(apiRoute); - - expect(response.status).toBe(200); - expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" })); - expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" })); - expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ hash: txHash })); - expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })); - expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ type: "call" })); - expect(typeof response.body.result[0].blockNumber).toStrictEqual("string"); - expect(typeof response.body.result[0].timeStamp).toStrictEqual("string"); - expect(typeof response.body.result[0].from).toStrictEqual("string"); - expect(typeof response.body.result[0].value).toStrictEqual("string"); - expect(typeof response.body.result[0].gas).toStrictEqual("string"); - expect(typeof response.body.result[0].input).toStrictEqual("string"); - expect(typeof response.body.result[0].contractAddress).toBeTruthy(); - expect(typeof response.body.result[0].gasUsed).toStrictEqual("string"); - expect(typeof response.body.result[0].fee).toStrictEqual("string"); - expect(typeof response.body.result[0].l1BatchNumber).toStrictEqual("string"); - expect(typeof response.body.result[0].traceId).toBeTruthy(); - expect(typeof response.body.result[0].transactionType).toStrictEqual("string"); - expect(typeof response.body.result[0].isError).toStrictEqual("string"); - expect(typeof response.body.result[0].errCode).toStrictEqual("string"); - }); - }); }); }); diff --git a/packages/integration-tests/tests/ui/withdraw.spec.ts b/packages/integration-tests/tests/ui/withdraw.spec.ts index ead2f95105..4cfb994eff 100644 --- a/packages/integration-tests/tests/ui/withdraw.spec.ts +++ b/packages/integration-tests/tests/ui/withdraw.spec.ts @@ -1,105 +1,97 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer, Token, Wallets } from "../../src/entities"; +import { BlockExplorer, Buffer, Wallets, Path, Values } from "../../src/constants"; import { Helper } from "../../src/helper"; +import type { Locator } from "@playwright/test"; const bufferRoute = "src/playbook/"; const helper = new Helper(); let url: string; -let bufferFile; let withdrawTxHash: string; -let fromAddress: string; -let toAddress: string; +let initiatorAddress: string; +let hash, initiatorAddressElement, toAddressElement, ethValue, erc20Value: Locator; //@id1661 test("Check Withdraw ETH transaction on BE", async ({ page }) => { - bufferFile = bufferRoute + Buffer.txEthWithdraw; - withdrawTxHash = await helper.getStringFromFile(bufferFile); + withdrawTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdraw); url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; - fromAddress = Wallets.richWalletAddress; - console.log(url); + initiatorAddress = Wallets.richWalletAddress; await page.goto(url); - const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); - const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); - const toAddressElement = await page + hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + initiatorAddressElement = await page.locator(`text=${initiatorAddress}`).first(); + toAddressElement = await page .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x36615Cf349d...c049"]`) .first(); - const ethValue = await page.locator(`text=0.000009`).first(); + ethValue = await page.locator(`text=${Values.txSumETH}`).first(); - await expect(hash).toBeVisible(config.extraTimeout); - await expect(ethValue).toBeVisible(config.extraTimeout); - await expect(fromAddressElement).toBeVisible(config.extraTimeout); - await expect(toAddressElement).toBeVisible(config.extraTimeout); + await expect(hash).toBeVisible(config.defaultTimeout); + await expect(ethValue).toBeVisible(config.defaultTimeout); + await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); + await expect(toAddressElement).toBeVisible(config.defaultTimeout); }); //@id1686 test("Verify the ETH withdrawal to the other address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.txEthWithdrawOtherAddress; - withdrawTxHash = await helper.getStringFromFile(bufferFile); + withdrawTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdrawOtherAddress); url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; - fromAddress = Wallets.richWalletAddress; - console.log(url); + initiatorAddress = Wallets.richWalletAddress; await page.goto(url); - const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); - const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); - const toAddressElement = await page + hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + initiatorAddressElement = await page.locator(`text=${initiatorAddress}`).first(); + toAddressElement = await page .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x586607935E1...8975"]`) .first(); - const ethValue = await page.locator(`text=0.000009`).first(); + ethValue = await page.locator(`text=${Values.txSumETH}`).first(); - await expect(hash).toBeVisible(config.extraTimeout); - await expect(ethValue).toBeVisible(config.extraTimeout); - await expect(fromAddressElement).toBeVisible(config.extraTimeout); - await expect(toAddressElement).toBeVisible(config.extraTimeout); + await expect(hash).toBeVisible(config.defaultTimeout); + await expect(ethValue).toBeVisible(config.defaultTimeout); + await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); + await expect(toAddressElement).toBeVisible(config.defaultTimeout); }); //@id1685 test("Check on BE Withdraw the custom ERC-20 via Portal", async ({ page }) => { - bufferFile = bufferRoute + Buffer.txERC20Withdraw; - withdrawTxHash = await helper.getStringFromFile(bufferFile); + withdrawTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txERC20Withdraw); url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; - fromAddress = Wallets.richWalletAddress; - console.log(url); + initiatorAddress = Wallets.richWalletAddress; await page.goto(url); - const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); - const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); - const toAddressElement = await page + hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + initiatorAddressElement = await page.locator(`text=${initiatorAddress}`).first(); + toAddressElement = await page .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x36615Cf349d...c049"]`) .first(); - const erc20Value = await page.locator(`//*[text()="0x36615Cf349d...c049"]/..//..//*[text()="0.2"]`).first(); + erc20Value = await page.locator(`//*[text()="0x36615Cf349d...c049"]/..//..//*[text()="0.2"]`).first(); - await expect(hash).toBeVisible(config.extraTimeout); - await expect(erc20Value).toBeVisible(config.extraTimeout); - await expect(fromAddressElement).toBeVisible(config.extraTimeout); - await expect(toAddressElement).toBeVisible(config.extraTimeout); + await expect(hash).toBeVisible(config.defaultTimeout); + await expect(erc20Value).toBeVisible(config.defaultTimeout); + await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); + await expect(toAddressElement).toBeVisible(config.defaultTimeout); }); //@id1664 test("Check Withdraw transaction on BE for custom ERC-20 token to a different address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.txERC20WithdrawOtherAddress; - withdrawTxHash = await helper.getStringFromFile(bufferFile); + withdrawTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txERC20WithdrawOtherAddress); url = BlockExplorer.baseUrl + `/tx/${withdrawTxHash}` + BlockExplorer.localNetwork; - fromAddress = Wallets.richWalletAddress; - console.log(url); + initiatorAddress = Wallets.richWalletAddress; await page.goto(url); - const hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); - const fromAddressElement = await page.locator(`text=${fromAddress}`).first(); - const toAddressElement = await page + hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${withdrawTxHash}"]`).first(); + initiatorAddressElement = await page.locator(`text=${initiatorAddress}`).first(); + toAddressElement = await page .locator(`//*[text()="To"]/..//..//..//*[text()="L1"]/..//*[text()="0x586607935E1...8975"]`) .first(); - const erc20Value = await page.locator(`//*[text()="0x586607935E1...8975"]/..//..//*[text()="0.2"]`).first(); + erc20Value = await page.locator(`//*[text()="0x586607935E1...8975"]/..//..//*[text()="0.2"]`).first(); - await expect(hash).toBeVisible(config.extraTimeout); - await expect(erc20Value).toBeVisible(config.extraTimeout); - await expect(fromAddressElement).toBeVisible(config.extraTimeout); - await expect(toAddressElement).toBeVisible(config.extraTimeout); + await expect(hash).toBeVisible(config.defaultTimeout); + await expect(erc20Value).toBeVisible(config.defaultTimeout); + await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); + await expect(toAddressElement).toBeVisible(config.defaultTimeout); }); From 6732d6d7bee9767416b1b9678511c7424cd0ee2e Mon Sep 17 00:00:00 2001 From: amelnytskyi Date: Tue, 12 Mar 2024 16:59:59 +0200 Subject: [PATCH 3/4] test: create autotests for Withdraw test cases Fixed Lint issues/warnings --- packages/integration-tests/src/constants.ts | 2 +- .../src/playbook/deploy/use-multitransferETH.ts | 2 +- packages/integration-tests/tests/ui/withdraw.spec.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index f165d514e9..8e6384d8fc 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -87,4 +87,4 @@ export enum BlockExplorer { const txSumETH = "0.000009"; export const Values = { txSumETH: txSumETH, -}; \ No newline at end of file +}; diff --git a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts index 7e5bf49438..5447e7d380 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts @@ -93,4 +93,4 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH, ethTransfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI, customToken1Transfer); await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII, customToken2Transfer); -} \ No newline at end of file +} diff --git a/packages/integration-tests/tests/ui/withdraw.spec.ts b/packages/integration-tests/tests/ui/withdraw.spec.ts index 4cfb994eff..64b0ebd928 100644 --- a/packages/integration-tests/tests/ui/withdraw.spec.ts +++ b/packages/integration-tests/tests/ui/withdraw.spec.ts @@ -1,11 +1,11 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer, Wallets, Path, Values } from "../../src/constants"; +import { BlockExplorer, Buffer, Path, Values, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; + import type { Locator } from "@playwright/test"; -const bufferRoute = "src/playbook/"; const helper = new Helper(); let url: string; let withdrawTxHash: string; From 745ce83b84c2b6c90a65db88b7dec44423a8fd5d Mon Sep 17 00:00:00 2001 From: amelnytskyi Date: Wed, 13 Mar 2024 14:09:09 +0200 Subject: [PATCH 4/4] test: create autotests for Withdraw test cases Fixed explicit timeout and changed const txSumETH to enum data type --- packages/integration-tests/src/constants.ts | 7 ++-- .../tests/ui/withdraw.spec.ts | 33 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index 8e6384d8fc..d2bc2dce6f 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -84,7 +84,6 @@ export enum BlockExplorer { localNetwork = "/?network=local", } -const txSumETH = "0.000009"; -export const Values = { - txSumETH: txSumETH, -}; +export enum Values { + txSumETH = "0.000009", +} diff --git a/packages/integration-tests/tests/ui/withdraw.spec.ts b/packages/integration-tests/tests/ui/withdraw.spec.ts index 64b0ebd928..9574f31214 100644 --- a/packages/integration-tests/tests/ui/withdraw.spec.ts +++ b/packages/integration-tests/tests/ui/withdraw.spec.ts @@ -1,6 +1,5 @@ import { expect, test } from "@playwright/test"; -import { config } from "./config"; import { BlockExplorer, Buffer, Path, Values, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; @@ -27,10 +26,10 @@ test("Check Withdraw ETH transaction on BE", async ({ page }) => { .first(); ethValue = await page.locator(`text=${Values.txSumETH}`).first(); - await expect(hash).toBeVisible(config.defaultTimeout); - await expect(ethValue).toBeVisible(config.defaultTimeout); - await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); - await expect(toAddressElement).toBeVisible(config.defaultTimeout); + await expect(hash).toBeVisible(); + await expect(ethValue).toBeVisible(); + await expect(initiatorAddressElement).toBeVisible(); + await expect(toAddressElement).toBeVisible(); }); //@id1686 @@ -48,10 +47,10 @@ test("Verify the ETH withdrawal to the other address", async ({ page }) => { .first(); ethValue = await page.locator(`text=${Values.txSumETH}`).first(); - await expect(hash).toBeVisible(config.defaultTimeout); - await expect(ethValue).toBeVisible(config.defaultTimeout); - await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); - await expect(toAddressElement).toBeVisible(config.defaultTimeout); + await expect(hash).toBeVisible(); + await expect(ethValue).toBeVisible(); + await expect(initiatorAddressElement).toBeVisible(); + await expect(toAddressElement).toBeVisible(); }); //@id1685 @@ -69,10 +68,10 @@ test("Check on BE Withdraw the custom ERC-20 via Portal", async ({ page }) => { .first(); erc20Value = await page.locator(`//*[text()="0x36615Cf349d...c049"]/..//..//*[text()="0.2"]`).first(); - await expect(hash).toBeVisible(config.defaultTimeout); - await expect(erc20Value).toBeVisible(config.defaultTimeout); - await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); - await expect(toAddressElement).toBeVisible(config.defaultTimeout); + await expect(hash).toBeVisible(); + await expect(erc20Value).toBeVisible(); + await expect(initiatorAddressElement).toBeVisible(); + await expect(toAddressElement).toBeVisible(); }); //@id1664 @@ -90,8 +89,8 @@ test("Check Withdraw transaction on BE for custom ERC-20 token to a different ad .first(); erc20Value = await page.locator(`//*[text()="0x586607935E1...8975"]/..//..//*[text()="0.2"]`).first(); - await expect(hash).toBeVisible(config.defaultTimeout); - await expect(erc20Value).toBeVisible(config.defaultTimeout); - await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); - await expect(toAddressElement).toBeVisible(config.defaultTimeout); + await expect(hash).toBeVisible(); + await expect(erc20Value).toBeVisible(); + await expect(initiatorAddressElement).toBeVisible(); + await expect(toAddressElement).toBeVisible(); });