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

Fix : Report 275 failing test #2834

Merged
merged 12 commits into from
Jan 30, 2025
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
3 changes: 2 additions & 1 deletion tests/govtool-frontend/playwright/generate_wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
4 changes: 3 additions & 1 deletion tests/govtool-frontend/playwright/lib/helpers/dRep.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"];
Expand Down
5 changes: 4 additions & 1 deletion tests/govtool-frontend/playwright/lib/helpers/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ export default class ProposalSubmissionPage {
proposalType: ProposalType = ProposalType.treasury
): Promise<number> {
await this.addLinkBtn.click();
const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0);
const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(
environments.networkId
);

const proposalRequest: ProposalCreateRequest =
this.generateValidProposalFormFields(
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions tests/govtool-frontend/playwright/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type IDRep = {
status: DRepStatus;
type: string;
latestTxHash: string;
givenName: string | null;
latestRegistrationDate: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 });
});
});

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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,
});
});
});

Expand All @@ -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,
});
});
});

Expand All @@ -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 });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand All @@ -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(),
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand All @@ -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,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
});

Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
})
);

Expand All @@ -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" }),
})
);

Expand Down
Loading
Loading