From c054b5b9434d223b0cbed15db8a8ad83efa66c4e Mon Sep 17 00:00:00 2001 From: Oleh Bairak Date: Fri, 23 Feb 2024 14:27:30 +0100 Subject: [PATCH] fix: new test integration --- .../tests/api/transactions.test.ts | 9 ++ .../tests/ui/transactions.spec.ts | 89 ++++++++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index cdf0d08f96..4eab4a6223 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -41,12 +41,21 @@ describe("Transactions", () => { apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performGETrequest(apiRoute); + console.log(response.body); + expect(response.status).toBe(200); expect(response.body.items[1].from).toBe(Wallets.richWalletAddress); expect(response.body.items[1].to).toBe(Wallets.mainWalletAddress); + expect(typeof response.body.items[1].blockNumber).toStrictEqual("number"); expect(response.body.items[1].transactionHash).toBe(txHash); + expect(typeof response.body.items[1].blockNumber).toStrictEqual("number"); + expect(response.body.items[1].tokenAddress).toBe(Token.ETHER_ERC20_Address); expect(response.body.items[1].amount).toBe("1000000000000"); expect(response.body.items[1].type).toBe("transfer"); + expect(response.body.items[1].tokenType).toBe("ETH"); + expect(typeof response.body.items[1].fields).toBeTruthy(); // can be null + expect(typeof response.body.items[1].isInternal).toStrictEqual("boolean"); + expect(typeof response.body.items[1].token).toStrictEqual("object"); }); }); diff --git a/packages/integration-tests/tests/ui/transactions.spec.ts b/packages/integration-tests/tests/ui/transactions.spec.ts index 22f923bf1e..d435dc51bc 100644 --- a/packages/integration-tests/tests/ui/transactions.spec.ts +++ b/packages/integration-tests/tests/ui/transactions.spec.ts @@ -1,17 +1,21 @@ import { expect, test } from "@playwright/test"; +import { address } from "hardhat/internal/core/config/config-validation"; +import getWallet from "src/playbook/utils/getWallet"; import { config } from "./config"; -import { BlockExplorer, Buffer } from "../../src/entities"; +import { BlockExplorer, Buffer, Token, Wallets } from "../../src/entities"; import { Helper } from "../../src/helper"; import type { Locator } from "@playwright/test"; const bufferRoute = "src/playbook/"; const helper = new Helper(); +const txSum = "0.000009"; let url: string; let bufferFile; let failedTxHash: string; let contract: string; +let transaction: string; let element: Locator; let selector: string; @@ -42,3 +46,86 @@ test("Verify deployed the own ERC20 token contract", async ({ page }) => { await expect(element).toBeVisible(config.extraTimeout); }); + +//@id1682 +test(" Check on BE Transfer ETH token via Portal", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txEthWithdraw; + transaction = await helper.getStringFromFile(bufferFile); + url = BlockExplorer.baseUrl + `/tx/${transaction}` + BlockExplorer.localNetwork; + + await page.goto(url); + //Check tx hash + selector = `text=${transaction}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + //Check address From + selector = `text=${Wallets.richWalletAddress}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + //Check address To + selector = `text=${Token.ETHER_ERC20_Address}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + + //Check transactino amount + selector = `text=${txSum}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); +}); + +//@id1680 +test(" Check on BE Transfer custom ERC-20 token via Portal", async ({ page }) => { + bufferFile = bufferRoute + Buffer.txMultiTransferCustomTokenI; + transaction = await helper.getStringFromFile(bufferFile); + const bufferFileToAdress = bufferRoute + Buffer.L2; + const adressTo = await helper.getStringFromFile(bufferFileToAdress); + url = BlockExplorer.baseUrl + `/tx/${transaction}` + BlockExplorer.localNetwork; + + await page.goto(url); + //Check tx hash + selector = `text=${transaction}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + //Check address From + selector = `text=${Wallets.richWalletAddress}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + //Check address To + selector = `text=${adressTo}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + + //Check transaction amount + selector = `text= 1 `; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); +}); + +//@id1683 +test("Check on BE contract that makes multiple transfers based on stored/retrieved ETH + ERC20", async ({ page }) => { + //contract address + bufferFile = bufferRoute + Buffer.addressMultiTransferETH; + contract = await helper.getStringFromFile(bufferFile); + //tx hash from deployed contract + const bufferFileAddress = bufferRoute + Buffer.txMultiTransferETH; + const txAddress = await helper.getStringFromFile(bufferFileAddress); + url = BlockExplorer.baseUrl + `/address/${contract}` + BlockExplorer.localNetwork; + + await page.goto(url); + //Check contract address + selector = `text=${contract}`; + element = await page.locator(selector).first(); + + await expect(element).toBeVisible(config.extraTimeout); + //Check tx hash + selector = `text=${txAddress}`; + element = await page.locator(selector).first(); +});