diff --git a/tests/govtool-frontend/playwright/generate_wallets.ts b/tests/govtool-frontend/playwright/generate_wallets.ts index e13de4499..7e62ec2aa 100644 --- a/tests/govtool-frontend/playwright/generate_wallets.ts +++ b/tests/govtool-frontend/playwright/generate_wallets.ts @@ -15,10 +15,11 @@ function saveWallets(wallets: ShelleyWallet[]): void { const jsonWallets = []; for (let i = 0; i < wallets.length; i++) { const dRepId = extractDRepFromWallet(wallets[i]); + const networkId = process.env.NETWORK === "mainnet" ? 1 : 0; jsonWallets.push({ ...wallets[i].json(), - address: wallets[i].addressBech32(0), // testnet + address: wallets[i].addressBech32(networkId), dRepId, }); } diff --git a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts index 2304c5188..4dac42a7c 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts @@ -1,6 +1,8 @@ import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { Page } from "@playwright/test"; +import { IDRep } from "@types"; import { bech32 } from "bech32"; +import * as crypto from "crypto"; export async function fetchFirstActiveDRepDetails(page: Page) { let dRepGivenName: string; @@ -12,7 +14,7 @@ export async function fetchFirstActiveDRepDetails(page: Page) { const response = await route.fetch(); const json = await response.json(); const elements = json["elements"].filter( - (element) => element["givenName"] != null + (element: IDRep) => element.givenName != null && !element.isScriptBased ); dRepGivenName = elements[Math.floor(Math.random() * elements.length)]["givenName"]; diff --git a/tests/govtool-frontend/playwright/lib/helpers/metadata.ts b/tests/govtool-frontend/playwright/lib/helpers/metadata.ts index 08eb1ee7d..f89b4f9aa 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/metadata.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/metadata.ts @@ -8,6 +8,7 @@ import * as fs from "fs"; import { ShelleyWallet } from "./crypto"; import { calculateImageSHA256 } from "./dRep"; import { imageObject } from "@types"; +import environments from "@constants/environments"; export async function downloadMetadata(download: Download): Promise<{ name: string; @@ -22,7 +23,9 @@ export async function downloadMetadata(download: Download): Promise<{ async function calculateMetadataHash() { try { - const paymentAddress = (await ShelleyWallet.generate()).addressBech32(0); + const paymentAddress = (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ); const imageUrl = faker.image.avatarGitHub(); const imageSHA256 = (await calculateImageSHA256(imageUrl)) || ""; const imageObject: imageObject = { diff --git a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts index 6df0d4ef9..4e3a89a97 100644 --- a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts @@ -159,7 +159,7 @@ export default class GovernanceActionsPage { await expect( this.page.getByRole("progressbar").getByRole("img") - ).toBeHidden({ timeout: 10_000 }); + ).toBeHidden({ timeout: 20_000 }); // Frontend validation for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) { diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index de947584c..e60a76a9b 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -348,7 +348,9 @@ export default class ProposalSubmissionPage { proposalType: ProposalType = ProposalType.treasury ): Promise { await this.addLinkBtn.click(); - const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32( + environments.networkId + ); const proposalRequest: ProposalCreateRequest = this.generateValidProposalFormFields( @@ -374,7 +376,9 @@ export default class ProposalSubmissionPage { const proposalFormValue = this.generateValidProposalFormFields( proposalType, true, - ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32(0) + ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32( + environments.networkId + ) ); await this.fillupForm(proposalFormValue); diff --git a/tests/govtool-frontend/playwright/lib/types.ts b/tests/govtool-frontend/playwright/lib/types.ts index 434971811..338c54d1d 100644 --- a/tests/govtool-frontend/playwright/lib/types.ts +++ b/tests/govtool-frontend/playwright/lib/types.ts @@ -110,6 +110,7 @@ export type IDRep = { status: DRepStatus; type: string; latestTxHash: string; + givenName: string | null; latestRegistrationDate: string; }; diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts index 4534f6d4d..104ad40fa 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts @@ -39,7 +39,9 @@ test("2N. Should show DRep information on details page", async ({ const objectives = faker.lorem.paragraph(2); const motivations = faker.lorem.paragraph(2); const qualifications = faker.lorem.paragraph(2); - const paymentAddress = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const paymentAddress = ShelleyWallet.fromJson(wallet).addressBech32( + environments.networkId + ); const linksReferenceLinks: LinkType[] = [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts index 41731b291..aad0a6350 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts @@ -102,7 +102,7 @@ test.describe("Change delegation", () => { page .getByTestId(`${dRepIdFirst}-delegated-card`) .getByTestId(`${dRepIdFirst}-copy-id-button`) - ).toHaveText(dRepIdFirst, { timeout: 20_000 }); + ).toHaveText(`(CIP-105) ${dRepIdFirst}`, { timeout: 20_000 }); // verify delegation await dRepDirectoryPage.delegateToDRep(dRepIdSecond); @@ -113,7 +113,7 @@ test.describe("Change delegation", () => { page .getByTestId(`${dRepIdSecond}-delegated-card`) .getByTestId(`${dRepIdSecond}-copy-id-button`) - ).toHaveText(dRepIdSecond, { timeout: 20_000 }); + ).toHaveText(`(CIP-105) ${dRepIdSecond}`, { timeout: 20_000 }); }); }); @@ -149,7 +149,9 @@ test.describe("Register DRep state", () => { await waitForTxConfirmation(dRepPage); // Checks in dashboard - await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible(); + await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({ + timeout: 20_000, + }); await expect( dRepPage.getByTestId("register-as-sole-voter-button") ).not.toBeVisible(); @@ -168,7 +170,9 @@ test.describe("Register DRep state", () => { ).toBeVisible({ timeout: 15_000 }); await dRepPage.getByTestId("confirm-modal-button").click(); await waitForTxConfirmation(dRepPage); - await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible(); + await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({ + timeout: 20_000, + }); const dRepDirectoryPage = new DRepDirectoryPage(dRepPage); await dRepDirectoryPage.goto(); @@ -260,9 +264,9 @@ test.describe("Abstain delegation", () => { const balance = await kuberService.getBalance(adaHolder03Wallet.address); - await expect( - page.getByText(`You have delegated ₳${balance}`) - ).toBeVisible(); + await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({ + timeout: 20_000, + }); }); }); @@ -287,9 +291,9 @@ test.describe("No confidence delegation", () => { await waitForTxConfirmation(page); const balance = await kuberService.getBalance(adaHolder04Wallet.address); - await expect( - page.getByText(`You have delegated ₳${balance}`) - ).toBeVisible(); + await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({ + timeout: 20_000, + }); }); }); @@ -314,13 +318,13 @@ test.describe("Delegated ADA visibility", () => { ); await expect( page.getByText(`You have delegated ₳ ${adaHolderVotingPower}`) - ).toBeVisible(); + ).toBeVisible({ timeout: 20_000 }); await page.goto("/"); await expect( page.getByText( `Your Voting Power of ₳${adaHolderVotingPower} is Delegated to` ) - ).toBeVisible(); + ).toBeVisible({ timeout: 20_000 }); }); }); diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts index e049300e7..98d262df5 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts @@ -29,11 +29,13 @@ test.describe("Logged in DReps", () => { }) => { await page.goto("/"); - await expect(page.getByTestId("voting-power-chips")).toBeVisible(); + await expect(page.getByTestId("voting-power-chips")).toBeVisible({ + timeout: 20_000, + }); await expect( page.getByTestId("dRep-id-display-card-dashboard") - ).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 }); + ).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 }); const governanceActionsPage = new GovernanceActionsPage(page); @@ -57,7 +59,7 @@ test.describe("Logged in DReps", () => { // Add an assertion to prevent clicking on "View Your dRep Details". await expect( page.getByTestId("dRep-id-display-card-dashboard") - ).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 }); + ).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 }); await page.getByTestId("view-drep-details-button").click(); await page.getByTestId("edit-drep-data-button").click(); @@ -70,7 +72,9 @@ test.describe("Logged in DReps", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), @@ -199,7 +203,9 @@ test.describe("Temporary DReps", () => { await waitForTxConfirmation(dRepPage); - await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible(); + await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible({ + timeout: 20_000, + }); await expect(dRepPage.getByTestId("dRep-id-display")).not.toBeVisible(); @@ -227,7 +233,9 @@ test.describe("Temporary DReps", () => { const dRepRegistrationPage = new DRepRegistrationPage(dRepPage); await dRepRegistrationPage.goto(); - await dRepRegistrationPage.register({ name: faker.person.firstName() }); + await dRepRegistrationPage.registerWithoutTxConfirmation({ + name: faker.person.firstName(), + }); await dRepRegistrationPage.registrationSuccessModal .getByTestId("confirm-modal-button") .click(); @@ -236,5 +244,11 @@ test.describe("Temporary DReps", () => { /in progress/i, { timeout: 20_000 } ); + + await waitForTxConfirmation(dRepPage); + + await expect(dRepPage.getByTestId("d-rep-in-progress")).not.toBeVisible({ + timeout: 20_000, + }); }); }); diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts index 729b87568..b49ed3a25 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts @@ -7,6 +7,7 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index"; import { skipIfNotHardFork } from "@helpers/cardano"; import DRepRegistrationPage from "@pages/dRepRegistrationPage"; import { expect } from "@playwright/test"; +import environments from "@constants/environments"; test.use({ storageState: ".auth/user01.json", @@ -64,7 +65,9 @@ test.describe("Validation of dRep Registration Form", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts index 27abd1a31..8461dc838 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts @@ -33,7 +33,9 @@ test.describe("Validation of edit dRep Form", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts index c49773786..e168afd2a 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts @@ -44,7 +44,8 @@ test.describe("Logged in DRep", () => { const votingPower = await res.json(); await expect(page.getByTestId("voting-power-chips-value")).toHaveText( - `₳ ${lovelaceToAda(votingPower)}` + `₳ ${lovelaceToAda(votingPower)}`, + { timeout: 20_000 } ); }); @@ -56,7 +57,7 @@ test.describe("Logged in DRep", () => { // assert to wait until the loading button is hidden await expect(page.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); govActionDetailsPage = (await isBootStrapingPhase()) diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts index d13c0b012..ac81002bf 100644 --- a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts @@ -37,7 +37,7 @@ test.describe("Proposal checks", () => { // assert to wait until the loading button is hidden await expect(page.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); currentPage = page; @@ -150,7 +150,7 @@ test.describe("Perform voting", () => { // assert to wait until the loading button is hidden await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); govActionDetailsPage = (await isBootStrapingPhase()) @@ -277,10 +277,12 @@ test.describe("Bootstrap phase", () => { await governanceActionsPage.goto(); // assert to wait until proposal cards are visible - await expect(dRepPage.getByTestId("voting-power-chips")).toBeVisible(); + await expect(dRepPage.getByTestId("voting-power-chips")).toBeVisible({ + timeout: 20_000, + }); // wait until the loading button is hidden await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); const governanceActionDetailsPage = diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts index 1389def75..77316a04f 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts @@ -178,7 +178,8 @@ test.describe("User Snap", () => { // Intercept Usersnap submit API await page.route(feedbackApiUrl, async (route) => route.fulfill({ - status: 200, + status: 403, + body: JSON.stringify({ error: "Blocked by test" }), }) ); @@ -202,7 +203,8 @@ test.describe("User Snap", () => { // Intercept Usersnap submit API await page.route(feedbackApiUrl, async (route) => route.fulfill({ - status: 200, + status: 403, + body: JSON.stringify({ error: "Blocked by test" }), }) ); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index 0a9697715..908b3ba0b 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -1,3 +1,4 @@ +import environments from "@constants/environments"; import { proposal01Wallet, proposal03Wallet, @@ -31,7 +32,7 @@ test.describe("Proposal created logged state", () => { test.use({ storageState: ".auth/proposal01.json", wallet: proposal01Wallet }); test("7B. Should access proposal creation page", async ({ page }) => { await page.goto("/"); - await page.getByTestId("propose-governance-actions-button").click(); + await page.getByTestId("proposal-discussion-link").click(); await expect(page.getByText(/proposals/i)).toHaveCount(2); }); @@ -56,7 +57,7 @@ test.describe("Proposal created logged state", () => { for (let i = 0; i < 50; i++) { const rewardAddressBech32 = ( await ShelleyWallet.generate() - ).rewardAddressBech32(0); + ).rewardAddressBech32(environments.networkId); const formFields: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, @@ -127,13 +128,14 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = - ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const stakeAddressBech32 = ShelleyWallet.fromJson( + wallet + ).rewardAddressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, false, - walletAddressBech32 + stakeAddressBech32 ); await proposalSubmissionPage.fillupForm(proposal); @@ -180,13 +182,14 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = - ShelleyWallet.fromJson(proposal01Wallet).rewardAddressBech32(0); + const rewardAddressBech32 = ShelleyWallet.fromJson( + proposal01Wallet + ).rewardAddressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, false, - walletAddressBech32 + rewardAddressBech32 ); await proposalSubmissionPage.fillupForm(proposal); @@ -351,7 +354,8 @@ test.describe("Info Proposal Draft", () => { .click(); await expect(proposalSubmissionPage.governanceActionType).toHaveText( - createProposalType + createProposalType, + { timeout: 20_000 } ); await expect(proposalSubmissionPage.titleInput).toHaveValue( proposalFormValue.prop_name