Skip to content

Commit

Permalink
Merge pull request #2117 from cardano-foundation/feature/MET-1521-upd…
Browse files Browse the repository at this point in the history
…ate-cypress-test-for-the-new-functions

feat: MET-1521 update cypress test for these new functions
  • Loading branch information
sato-thuyetnguyen authored Oct 5, 2023
2 parents 89bf4df + eeca6b9 commit e25005c
Show file tree
Hide file tree
Showing 33 changed files with 404 additions and 260 deletions.
6 changes: 6 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export default defineConfig({
hideXHRInCommandLog: true,
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 200000,
pageLoadTimeout: 200000,
execTimeout: 200000,
taskTimeout: 200000,
requestTimeout: 200000,
responseTimeout: 200000,
setupNodeEvents() {
// implement node event listeners here
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/ConnectWallet.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe("Connect wallet and enter user name", () => {
cy.visit("/sign-in");
});

it("check screen sign up", () => {
it.only("check screen sign up", () => {
cy.get('[data-testid="signin-title"]').should("be.visible").contains("Sign In");
cy.get('[data-testid="forgot-password-link"] > .MuiBox-root').should("be.visible").contains("Forgot password");
cy.get('[data-testid="connect-wallet"]').should("be.visible").should("be.enabled");
Expand Down
37 changes: 19 additions & 18 deletions cypress/e2e/DelegatorLifecycleTests.cy.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
describe("Delegator Lifecycle", () => {
beforeEach(() => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='Search stake address or pool ID']").type(stakeId);
cy.get("input[placeholder*='Search stake address or pool ID']").type("{enter}");
});
const stakeId = "stake1u8a5n0u7j7y0tvxu0czxr08064n7fhalp0yae25znh0p8xs0yka8k";
it("should navigate to staking delegation", () => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='address or pool id']").type(stakeId);
cy.get("input[placeholder*='address or pool id']").type("{enter}");
cy.get('[data-testid="delegator-registration-container"]').should("be.visible");
cy.get('[id="step-1"]').click();
cy.get('[data-testid="delegator-delegation-container"]').should("be.visible");
});
it("should on delegation list", () => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='address or pool id']").type(stakeId);
cy.get("input[placeholder*='address or pool id']").type("{enter}");
cy.get('[id="step-1"]').click();
cy.get('[data-testid="delegator-delegation-container"]').should("be.visible");
});
it("should on rewards distribution list", () => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='address or pool id']").type(stakeId);
cy.get("input[placeholder*='address or pool id']").type("{enter}");
cy.get('[id="step-2"]').click();
cy.get(".css-zq7rup").contains("Rewards Distribution");
cy.get("p").contains("Rewards Distribution");
});
it("should on rewards withdrawal", () => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='address or pool id']").type(stakeId);
cy.get("input[placeholder*='address or pool id']").type("{enter}");
cy.get('[id="step-3"]').click();
cy.get('[data-testid="overview-staking"]').should("be.visible");
});
it.only("should on deregistration", () => {
cy.visit("/staking-lifecycle");
cy.get("input[placeholder*='address or pool id']").type(stakeId);
cy.get("input[placeholder*='address or pool id']").type("{enter}");
it("should on deregistration", () => {
cy.get('[id="step-4"]').click();
cy.wait(1000);
cy.get('[data-testid="delegator-deregistration-certificate"]').should("be.visible");
});

it("should on random stake", () => {
cy.visit("/staking-lifecycle");
cy.get("button[data-testid='dropdown-menu-button']").click();
cy.get("ul li").contains("Browse an example delegator").click();
});

it("should on random pool", () => {
cy.visit("/staking-lifecycle");
cy.get("button[data-testid='dropdown-menu-button']").click();
cy.get("ul li").contains("Browse an example stake pool").click();
});
});
3 changes: 1 addition & 2 deletions cypress/e2e/InstantaneousRewardsTests.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ describe("Instantaneous rewards", () => {
});

it("should have enough columns", () => {
//cy.get(".css-1dz0v3k > tr > :nth-child(1)").scrollIntoView().should("be.visible").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").scrollIntoView().should("be.visible").contains("Tx Hash");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").scrollIntoView().should("be.visible").contains("Transaction Hash");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").scrollIntoView().should("be.visible").contains("Created At");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").scrollIntoView().should("be.visible").contains("Block");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").scrollIntoView().should("be.visible").contains("Stake Address");
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/TopAddressDetailTests.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ describe("Top Address Detail Tests", () => {
it("verify element by address ADA Balance", () => {
cy.visit("/addresses");
cy.get('[data-testid="table-common"]').contains("Addresses");
//cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Addresses");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Balance");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Transaction Count");
});
it.only("verify element by Amount Staked", () => {
cy.visit("/addresses");
cy.get('[id*="amount-staked"]').first().click();
//cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Stake Address");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Pool");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Stake amount");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Stake amount", { matchCase: false });
});
});
17 changes: 8 additions & 9 deletions cypress/e2e/addressDetail.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ describe("address detail spec", () => {
cy.visit("/address/Ae2tdPwUPEZKnykUqXyYQxqJSnADNkm4ELUnyqZUBHcCrNJVDqozLYCt9Jv");
cy.get(".css-19nq3tn").contains("Address Details");
cy.get(".css-12n155v").contains(address);
cy.get(":nth-child(2) > .css-198fg3r > .css-1l7sjfb > .css-12euw8y").contains("Analytics");
cy.get(":nth-child(3) > .css-198fg3r > .css-1l7sjfb > .css-12euw8y").contains("Transactions");
//cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Tx Hash");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Created At");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Block");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Fees");
cy.get(".css-1dz0v3k > tr > :nth-child(5)").contains("ADA amount");
cy.get(".css-1dz0v3k > tr > :nth-child(6)").contains("Token");
cy.get("div").contains("Analytics");
cy.get("div").contains("Transactions");
cy.get("table tr th").contains("Tx hash");
cy.get("table tr th").contains("Created At");
cy.get("table tr th").contains("Block");
cy.get("table tr th").contains("Fees");
cy.get("table tr th").contains("ADA amount");
cy.get("table tr th").contains("Token");
});
});
7 changes: 3 additions & 4 deletions cypress/e2e/blocks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("block spec", () => {
cy.visit("/blocks");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Block");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Block ID");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Epoch/Slot");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Epoch / Slot", { matchCase: false });
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Created At");
cy.get(".css-1dz0v3k > tr > :nth-child(5)").contains("Transactions");
cy.get(".css-1dz0v3k > tr > :nth-child(6)").contains("Fees");
Expand All @@ -36,7 +36,7 @@ describe("block spec", () => {
it("should navigate to the block detail page", () => {
const block = "7588518";
cy.visit("/block/7588518");
cy.get(".css-igne3v").contains("Block details");
cy.get(".css-1uehs23").contains("Block details", { matchCase: false });
cy.get(":nth-child(1) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Created At");
cy.get(":nth-child(2) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Confirmations");
cy.get(":nth-child(3) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Transactions");
Expand All @@ -45,8 +45,7 @@ describe("block spec", () => {
cy.get(":nth-child(6) > .css-seof3k").contains(block);
cy.get(":nth-child(7) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Slot");
cy.get('[data-testid="table-common"]').verifyElementDisplay;
//cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Tx Hash");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Tx Hash", { matchCase: false });
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Created At");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Block");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Addresses");
Expand Down
34 changes: 9 additions & 25 deletions cypress/e2e/contracts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,36 @@
describe("contracts spec", () => {
it("should show the contract details of transaction 4223b55d78e90917c5a6054c8a038124f7b1c0ecefc6751dd8bcd6a5016ae2d1", () => {
const transactionHash = "4223b55d78e90917c5a6054c8a038124f7b1c0ecefc6751dd8bcd6a5016ae2d1";
const contractHash =
"addr1zxn9efv2f6w82hagxqtn62ju4m293tqvw0uhmdl64ch8uw6j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pq6s3z70";
const contractCount = 3;

const datumBytes =
"d8799fd8799fd8799f581c4a8508ee9d864103b28f86bd004c74551dcb9a99493e07d6c5f965c1ffd8799fd8799fd8799f581c3ff922f6a662e2ee1e48f6f7e9a2dc337f4483e0ef3a247466b29babffffffffd8799fd8799f581c4a8508ee9d864103b28f86bd004c74551dcb9a99493e07d6c5f965c1ffd8799fd8799fd8799f581c3ff922f6a662e2ee1e48f6f7e9a2dc337f4483e0ef3a247466b29babffffffffd87a80d8799fd8799f4040ff1a16cb22ccff1a001e79ea1a001e8480ff";
const datumHash = "a5e7b0301a29d8a00ada775d1b0c4bda47573e3de06214445e0e0590302b62be";

cy.visit(`/transaction/${transactionHash}/contracts`);
cy.get('[data-testid="tab-contracts"]').should("contain", `Contracts(${contractCount})`);
cy.get(`[data-testid="contract-hash-${contractHash}"]`).should("contain", contractHash);

cy.get(`[data-testid="contract-redeemer-tag-${contractHash}"]`).should("contain", "SPEND");
cy.get(`[data-testid="contract-redeemer-data-${contractHash}"]`).should("contain", "d87980");
cy.get(`[data-testid="contract-redeemer-mem-${contractHash}"]`).should("contain", "61056");
cy.get(`[data-testid="contract-redeemer-steps-${contractHash}"]`).should("contain", "22010239");

cy.get(`[data-testid="contract-datum-hash-${contractHash}"]`).should("contain", datumHash);
cy.get(`[data-testid="contract-datum-bytes-${contractHash}"]`).should("contain", datumBytes);
cy.get(".MuiAccordionSummary-content div").should("contain", `Contracts(${contractCount})`);
cy.get(`p`).contains("Contract Address");
});

it("should navigate to the contract page", () => {
cy.visit("/");
cy.get('[data-testid="menu-button-blockchain"]').click();
cy.get('[data-testid="submenu-button-smart_contracts"]').click();
cy.get(".css-1l7sjfb").contains("Contracts");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("#");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Contract Addresses");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Balance");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Value");
cy.get(".css-1dz0v3k > tr > :nth-child(5)").contains("Transaction Count");
cy.get("h2").contains("Smart Contracts");
cy.get("table tr th").contains("Address");
cy.get("table tr th").contains("Balance");
cy.get("table tr th").contains("Value");
cy.get("table tr th").contains("Transaction Count");
});

it("redirect to correct address detail page", () => {
const address =
"addr1z8snz7c4974vzdpxu65ruphl3zjdvtxw8strf2c2tmqnxz2j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pq0xmsha";
cy.visit("/contracts");
cy.get(".css-1l7sjfb").contains("Contracts");
cy.get("h2").contains("Smart Contracts");
cy.get('[data-testid="search-bar"]').type(address).type("{enter}");
cy.get(".css-19nq3tn").contains("Address Details");
cy.get(".css-12n155v").contains(address);
});

it.only("should navigate to the contract detail page", () => {
cy.visit("/contracts");
cy.get(".css-1l7sjfb").contains("Contracts");
cy.get("h2").contains("Smart Contracts");
cy.get(":nth-child(1) > :nth-child(1) > div > .css-1l62pou").click();
cy.get(".css-1msjg76 > .css-0").contains("Contract Details");
cy.get(":nth-child(1) > .css-1heutcx > .css-k6svam > .css-1xc8op").contains("Address");
Expand Down
32 changes: 15 additions & 17 deletions cypress/e2e/delegationPool.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,26 @@ describe("delegation pool spec", () => {
cy.visit("/");
cy.get('[data-testid="menu-button-blockchain"]').click();
cy.get('[data-testid="submenu-button-pools"]').click();
cy.get(".css-1l7sjfb").contains("Pool");
cy.get(".MuiGrid-container > :nth-child(1) > .css-ouujem > .css-1cs4ejo > .css-6l1v2o").contains("Epoch");
cy.get(".css-1co4lm5 > .css-ouujem > .css-1cs4ejo > .css-6l1v2o").contains("Slot");
cy.get('[style="padding: 30px 0px 0px 30px;"] > .css-6l1v2o').contains("Live Stake");
cy.get(":nth-child(2) > .css-6l1v2o").contains("Delegators");
cy.get(":nth-child(4) > .css-ouujem > .css-1cs4ejo > .css-6l1v2o").contains("Total Pools");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Pool");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Pool size");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("Declared Pledge");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Saturation");
cy.get(".css-1dz0v3k > tr > :nth-child(5)").contains("Number of Delegators");
cy.get(".css-1dz0v3k > tr > :nth-child(6)").contains("Blocks in Epoch");
cy.get(".css-1dz0v3k > tr > :nth-child(7)").contains("Blocks lifetime");
//cy.get('.css-1dz0v3k > tr > :nth-child(8)').contains("Reward");
cy.get(".css-1dz0v3k > tr > :nth-child(8)").contains("Fixed Cost");
//cy.get('.css-1dz0v3k > tr > :nth-child(10)').contains("Margin");
cy.get("h2").contains("Pools");
cy.get("div").contains("Epoch");
cy.get("div").contains("Slot");
cy.get("div").contains("Live Stake");
cy.get("div").contains("Delegators");
cy.get("div").contains("Total Pools");
cy.get("table tr th").contains("Pool");
cy.get("table tr th").contains("Pool size", { matchCase: false });
cy.get("table tr th").contains("Declared Pledge");
cy.get("table tr th").contains("Saturation");
cy.get("table tr th").contains("Number of Delegators");
cy.get("table tr th").contains("Blocks in Epoch");
cy.get("table tr th").contains("Blocks lifetime", { matchCase: false });
cy.get("table tr th").contains("Fixed Cost");
});

it("redirect to correct transaction detail page", () => {
const pool = "pool1m06tlj2ykawzvweacgmhxj43hykczgfuynk2lqzxvshm5lq2lyq";
cy.visit("/pools");
cy.get(".css-1l7sjfb").contains("Pool");
cy.get("div").contains("Pools");
cy.get('[data-testid="search-bar"]').type(pool).type("{enter}");
cy.get(".css-1d87buq").contains(pool);
cy.get(".css-1mwjfms").contains(pool);
Expand Down
42 changes: 25 additions & 17 deletions cypress/e2e/epochs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ describe("epoch spec", () => {

it("should have enough column", () => {
cy.visit("/epochs");
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Epoch");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Start Timestamp");
cy.get(".css-1dz0v3k > tr > :nth-child(3)").contains("End Timestamp");
cy.get(".css-1dz0v3k > tr > :nth-child(4)").contains("Blocks");
cy.get(".css-1dz0v3k > tr > :nth-child(5)").contains("Unique Accounts");
cy.get(".css-1dz0v3k > tr > :nth-child(6)").contains("Transaction Count");
cy.get(".css-1dz0v3k > tr > :nth-child(7)").contains("Rewards Distributed");
cy.get(".css-1dz0v3k > tr > :nth-child(8)").contains("Total Output");
cy.get("table tr th").contains("Epoch");
cy.get("table tr th").contains("Start Timestamp", { matchCase: false });
cy.get("table tr th").contains("End Timestamp", { matchCase: false });
cy.get("table tr th").contains("Blocks");
cy.get("table tr th").contains("Unique Accounts", { matchCase: false });
cy.get("table tr th").contains("Transaction Count", { matchCase: false });
cy.get("table tr th").contains("Rewards Distributed", { matchCase: false });
cy.get("table tr th").contains("Total Output", { matchCase: false });
});

it("should have epoch search bar", () => {
Expand All @@ -33,23 +33,31 @@ describe("epoch spec", () => {
const epoch = "426";
cy.visit("/epochs");
cy.get('[data-testid="search-bar"]').type(epoch).type("{enter}");
cy.get(".css-igne3v").contains("Epoch details");
cy.get("div").contains("Epoch details");
cy.get(".css-17lbe4a").contains(epoch);
});

it("should navigate to the epoch detail page", () => {
it.only("should navigate to the epoch detail page", () => {
const epoch = "426";
cy.visit("/epoch/426");
cy.get(".css-igne3v").contains("Epoch details");
cy.get("div").contains("Epoch details", { matchCase: false });
cy.get(".css-17lbe4a").contains(epoch);
cy.get(":nth-child(1) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Start Timestamp");
cy.get(":nth-child(2) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("End Timestamp");
cy.get(":nth-child(3) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Total Output");
cy.get(":nth-child(1) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Start Timestamp", {
matchCase: false
});
cy.get(":nth-child(2) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("End Timestamp", { matchCase: false });
cy.get(":nth-child(3) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Total Output", { matchCase: false });
cy.get(":nth-child(4) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Blocks");
cy.get(":nth-child(5) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Slot");
cy.get(":nth-child(6) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Unique Accounts");
cy.get(":nth-child(7) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Transaction Count");
cy.get(":nth-child(8) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Rewards Distributed");
cy.get(":nth-child(6) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Unique Accounts", {
matchCase: false
});
cy.get(":nth-child(7) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Transaction Count", {
matchCase: false
});
cy.get(":nth-child(8) > .css-13ne0mf > .css-70qvj9 > .MuiBox-root").contains("Rewards Distributed", {
matchCase: false
});
cy.get('[data-testid="table-common"]').verifyElementDisplay;
cy.get(".css-1dz0v3k > tr > :nth-child(1)").contains("Block");
cy.get(".css-1dz0v3k > tr > :nth-child(2)").contains("Block ID");
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("Home page function should work", () => {
it("should navigate to SignIn page", () => {
cy.getBySelector("header-signin").click();
cy.title().should("eq", "Sign In | Cardano Blockchain Explorer");
cy.getBySelector("signin-title").contains(/^(Sign In)$/i);
cy.getBySelector("signin-title").contains("Sign In", { matchCase: false });
});

it("should change the search option", () => {
Expand Down
Loading

0 comments on commit e25005c

Please sign in to comment.