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

chore(e2e): add e2e test for blocks list page and tx details page #311

Merged
merged 6 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions cypress/e2e/pages/blocks/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
context("/blocks on macbook-16", () => {
const BASE_URL = Cypress.config().baseUrl;

beforeEach(() => {
cy.visit("/blocks");
cy.viewport("macbook-16");
});

it("should have page header, footer and search bar", () => {
cy.findByTestId("header-container").should("be.visible");
cy.findByTestId("footer-container").should("be.visible");
cy.findByTestId("search-bar-container").should("be.visible");
});

it("should have heading and list table container", () => {
cy.findByTestId("blocks-list")
.should("be.visible")
.within(() => {
cy.get("h1").should("have.text", "Blocks");
});
});

it("should have data row with block information", () => {
cy.findAllByTestId("mobile-block-row").should("not.exist");
cy.findAllByTestId("desktop-block-row").should("be.visible");
cy.findAllByTestId("desktop-block-row")
.first()
.within(() => {
cy.get('[data-testid^="block-number-"]')
.should("be.visible")
.should("have.attr", "href")
.and("include", "/block/");

cy.findByTestId("block-reward")
.should("be.visible")
.within(() => {
cy.get("span").eq(0).contains("Reward");
cy.get("span").eq(1).contains("DFI");
});

cy.findByTestId("fee-recipient")
.should("be.visible")
.within(() => {
cy.get("span").contains("Fee recipient");
cy.get("a")
.should("contain.text", "0x")
.should("have.attr", "href")
.and("include", "/address/");
});

cy.findByTestId("block-txs-count")
.should("be.visible")
.within(() => {
cy.get("span").contains(" transactions");
});

cy.findByTestId("desktop-block-timeago")
.should("be.visible")
.within(() => {
cy.get("span").contains(" ago");
});
});
});

it("should display pagination on top and bottom part of the page", () => {
cy.findAllByTestId("pagination-container").should("have.length", 2); // top & bottom

// Top pagination, test `next` pages
cy.findAllByTestId("pagination-container").eq(0).should("be.visible");
cy.findAllByTestId("pagination-container")
.eq(0)
.within(() => {
cy.findByTestId("Pagination.Prev").should("not.exist");
cy.findByTestId("Pagination.Next").should("be.visible");

let nextPageLink = "";
cy.findByTestId("page-2")
.should("be.visible")
.invoke("attr", "href")
.then((value) => {
nextPageLink = value || "";
});
cy.findByTestId("page-2").click();
cy.then(() => {
cy.location("href").should("eq", `${BASE_URL}${nextPageLink}`);
cy.findByTestId("Pagination.Prev").should("be.visible");
});
});

// Bottom pagination, test `previous` pages
cy.findAllByTestId("pagination-container").eq(1).should("be.visible");
cy.findAllByTestId("pagination-container")
.eq(1)
.within(() => {
cy.findByTestId("Pagination.Prev").should("be.visible");
cy.findByTestId("Pagination.Next").should("be.visible");

let prevPageLink = "";
cy.findByTestId("Pagination.Prev")
.should("be.visible")
.invoke("attr", "href")
.then((value) => {
prevPageLink = value || "";
});
cy.findByTestId("Pagination.Prev").click();
cy.then(() => {
cy.location("href").should("eq", `${BASE_URL}${prevPageLink}`);
cy.findByTestId("Pagination.Prev").should("not.exist");
cy.findByTestId("Pagination.Next").should("be.visible");
});
});
});
});

context("/blocks on iphone-x", () => {
beforeEach(() => {
cy.visit("/blocks");
cy.viewport("iphone-x");
});

it("should have page header, footer and search bar", () => {
cy.findByTestId("header-container").should("be.visible");
cy.findByTestId("header-openMenu").should("be.visible");
cy.findByTestId("footer-container").should("be.visible");
cy.findByTestId("search-bar-container").should("be.visible");
});

it("should have heading and list table container", () => {
cy.findByTestId("blocks-list")
.should("be.visible")
.within(() => {
cy.get("h1").should("have.text", "Blocks");
});
});

it("should have data row with block information", () => {
cy.findAllByTestId("desktop-block-row").should("not.exist");
cy.findAllByTestId("mobile-block-row").should("be.visible");
cy.findAllByTestId("mobile-block-row")
.first()
.within(() => {
cy.get('[data-testid^="block-number-"]')
.should("be.visible")
.should("have.attr", "href")
.and("include", "/block/");

cy.findByTestId("block-reward")
.should("be.visible")
.within(() => {
cy.get("span").eq(0).contains("Reward");
cy.get("span").eq(1).contains("DFI");
});

cy.findByTestId("fee-recipient")
.should("be.visible")
.within(() => {
cy.get("span").contains("Fee recipient");
cy.get("a")
.should("contain.text", "0x")
.should("have.attr", "href")
.and("include", "/address/");
});

cy.findByTestId("block-txs-count")
.should("be.visible")
.within(() => {
cy.get("span").contains(" transactions");
});

cy.findByTestId("mobile-block-timeago")
.should("be.visible")
.within(() => {
cy.get("span").contains(" ago");
});
});
});

it("should display pagination on top and bottom part of the page", () => {
cy.findAllByTestId("pagination-container").should("have.length", 2); // top & bottom
cy.findAllByTestId("pagination-container").eq(0).should("be.visible");
cy.findAllByTestId("pagination-container").eq(1).should("be.visible");
});
});
73 changes: 73 additions & 0 deletions cypress/e2e/pages/transaction/TokenMinting.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
context("/tx/[tid] on macbook-16", () => {
const txHash =
"0x760e433e8d215309412d8ecd9927192ddf61d0f2546e532951c129ce5bc33c7b";

beforeEach(() => {
cy.visit(`/tx/${txHash}`);
cy.viewport("macbook-16");
});

it("should display page header, footer and search bar", () => {
cy.findByTestId("header-container").should("be.visible");
cy.findByTestId("footer-container").should("be.visible");
cy.findByTestId("search-bar-container").should("be.visible");
});

it("should display page title", () => {
cy.findByTestId("transaction-details-title")
.should("be.visible")
.should("have.text", "Transaction details");
});

it("should display transaction details", () => {
cy.findByTestId("tx-hash").should("have.text", txHash);
cy.findByTestId("transaction-timestamp").contains(
"(07-26-2023 09:31:33 AM +UTC)"
);
cy.findByTestId("transaction-block").should("have.text", "89946");
cy.findByTestId("transaction-block")
.should("have.attr", "href")
.and("include", `/block/89946`);
cy.findByTestId("transaction-confirmations").contains(" blocks");
cy.findByTestId("transaction-type").should("have.text", "Token minting");
cy.findByTestId("transaction-status").should("have.text", "Success");
cy.findByTestId("transaction-amount").contains("0.00000000 DFI");
cy.findByTestId("transaction-fee").should("have.text", "0.00042306 DFI");
});

it("should display wallet details", () => {
// From address
cy.findByTestId("from-title").should("have.text", "From");
cy.findByTestId("transaction-details-from")
.should("have.attr", "href")
.and("include", "/address/0x36375828fd821935cFf3E8AB6322cAb54BBfaDeC");
// Interacted with contract
cy.findByTestId("interacted-with-contract-(to)-title").should(
"have.text",
"Interacted with contract (To)"
);
cy.findByTestId("transaction-details-to")
.should("have.attr", "href")
.and("include", "/address/0xE815f2aD238B218E6becb93d846EA8FF90eDB39C");
// Tokens minted
cy.findByTestId("tokens-minted-title").should("have.text", "Tokens minted");
cy.findByTestId("token-transfers").should("be.visible");
cy.findByTestId("token-transferred-from")
.should("have.attr", "href")
.and("include", "/address/0x0000000000000000000000000000000000000000");
cy.findByTestId("token-transferred-to")
.should("have.attr", "href")
.and("include", "/address/0x36375828fd821935cFf3E8AB6322cAb54BBfaDeC");
// For token
cy.findByTestId("token-transferred-for").should("be.visible");
cy.findByTestId("for-token-container").contains("For: ");
cy.findByTestId("token-transferred-for").should(
"have.text",
"100,000.00000000"
);
cy.findAllByTestId("token-transferred-for-symbol")
.should("contain.text", "fDUSD")
.should("have.attr", "href")
.and("include", "/token/0xE815f2aD238B218E6becb93d846EA8FF90eDB39C");
});
});
Loading
Loading