Skip to content
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
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/molecules/DRepDataForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const DRepDataForm = ({ control, errors, register, watch }: Props) => {
subtitle={t("forms.dRepData.imageHelpfulText")}
/>
<UncontrolledImageInput
data-testid="image-input"
dataTestId="image-input"
control={control}
name="image"
rules={Rules.IMAGE_URL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const UncontrolledImageInput = <T extends FieldValues>({
/>
{fieldState.error && (
<FormErrorMessage
dataTestId={`${dataTestId}-error`}
dataTestId={`invalid-${dataTestId}-error`}
errorMessage={fieldState.error.message}
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions tests/govtool-frontend/playwright/lib/forms/dRepForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const formErrors = {
],
linkDescription: "max-80-characters-error",
email: "invalid-email-address-error",
image: "invalid-image-url-error",
image: "invalid-image-input-error",
links: {
url: "link-reference-description-1-error",
description: "link-reference-description-1-error",
Expand Down Expand Up @@ -304,7 +304,7 @@ export default class DRepForm {
}).not.toEqual(dRepInfo.qualifications);

await expect(this.form.getByTestId(formErrors.image), {
message: !isImageErrorVisible && `${dRepInfo.image} is a valid image`,
message: !isImageErrorVisible && `Invalid image URL or properly formatted base64-encoded image`,
}).toBeVisible({
timeout: 60_000,
});
Expand Down
17 changes: 11 additions & 6 deletions tests/govtool-frontend/playwright/lib/pages/outcomeDetailsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class OutcomeDetailsPage {
}

const outcomeResponse = await outcomeResponsePromise;
const proposalToCheck = (await outcomeResponse.json())[0];
const proposalToCheck = (await outcomeResponse.json());

const metricsResponse = await metricsResponsePromise;

Expand Down Expand Up @@ -188,7 +188,7 @@ export default class OutcomeDetailsPage {
filterKey === "NoConfidence"
? proposalToCheck.pool_no_votes
: parseInt(sPosNoConfidence.replace(/,/g, "")) * 1000000 +
parseInt(proposalToCheck.pool_no_votes);
parseInt(proposalToCheck.pool_no_votes);

const totalSposYesVotesForNoConfidence =
parseInt(sPosNoConfidence.replace(/,/g, "")) * 1000000 +
Expand Down Expand Up @@ -295,19 +295,24 @@ export default class OutcomeDetailsPage {
url: string;
hash: string;
}) {
await this.page.route(/.*\/governance-actions\/[a-f0-9]{64}\?.*/, (route) =>
route.fulfill({ body: JSON.stringify([outcomeResponse]) })
let governanceActionPromise = this.page.route("**/governance-actions/*", async (route) => {
if (route.request().url().includes("/governance-actions/metadata")) {
await route.continue();
} else {
await route.fulfill({ body: JSON.stringify(outcomeResponse)});
}
}
);

const outcomePage = new OutComesPage(this.page);
await outcomePage.goto();
await outcomePage.viewFirstOutcomes();
await governanceActionPromise;
const outcomeTitle = await outcomePage.title.textContent();

await expect(
outcomePage.title,
outcomeTitle.toLowerCase() !== type.toLowerCase() &&
`The URL "${url}" and hash "${hash}" do not match the expected properties for type "${type}".`
`The URL "${url}" and hash "${hash}" do not match the expected properties for type "${type}".`
).toHaveText(type, {
ignoreCase: true,
timeout: 60_000,
Expand Down
4 changes: 2 additions & 2 deletions tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ export default class OutComesPage {

const metricsResponsePromise = page.waitForResponse(
(response) => response.url().includes(`/misc/network/metrics?epoch`),
{ timeout: 60_000 }
{ timeout: 120_000 }
);

expect(
Expand All @@ -597,7 +597,7 @@ export default class OutComesPage {
.includes(
`governance-actions/${governanceTransactionHash}?index=${governanceActionIndex}`
),
{ timeout: 60_000 }
{ timeout: 120_000 }
);

const govActionDetailsPage = await outcomePage.viewFirstOutcomes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ test.describe("Logged in DRep", () => {
)
: await govActionsPage.viewFirstProposal();

await govActionDetailsPage.contextBtn.click();
await govActionDetailsPage.contextInput.fill(faker.lorem.sentence(200));
await govActionDetailsPage.confirmModalBtn.click();
await page.getByRole("checkbox").click();
Expand Down Expand Up @@ -101,55 +100,6 @@ test.describe("Logged in DRep", () => {
});
});

test.describe("Temporary DReps", async () => {
let dRepPage: Page;

test.beforeEach(async ({ page, browser }) => {
const wallet = await walletManager.popWallet("registeredDRep");
const tempDRepAuth = await createTempDRepAuth(page, wallet);
dRepPage = await createNewPageWithWallet(browser, {
storageState: tempDRepAuth,
wallet,
enableDRepSigning: true,
});
});

const verifyVoteWithMetadata = async (testInfo: any, useGovToolIPFS: boolean = false) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

const govActionsPage = new GovernanceActionsPage(dRepPage);
await govActionsPage.goto();

const govActionDetailsPage = await govActionsPage.viewFirstProposal();
const fakerContext = faker.lorem.sentence(200);

if (useGovToolIPFS) {
await govActionDetailsPage.vote(fakerContext, false, true);
} else {
await govActionDetailsPage.vote(fakerContext);
}

await dRepPage.reload();
await dRepPage.waitForTimeout(5_000);
await govActionsPage.votedTab.click();

const votedGovActionDetailsPage = await govActionsPage.viewFirstVotedProposal();
await votedGovActionDetailsPage.currentPage.getByTestId("show-more-button").click();
await votedGovActionDetailsPage.currentPage.waitForTimeout(2000);

const voteRationaleContext = await votedGovActionDetailsPage.currentPage.getByTestId("vote-rationale-context");
await expect(voteRationaleContext).toContainText(fakerContext);
};

test("4J. Should include metadata anchor in the vote transaction (Download and store yourself)", async ({}, testInfo) => {
await verifyVoteWithMetadata(testInfo, false);
});

test("4k. Should include metadata anchor in the vote transaction (GovTool pins data to IPFS)", async ({}, testInfo) => {
await verifyVoteWithMetadata(testInfo, true);
});
});

test.describe("Check vote count", () => {
test.use({ storageState: dRep01AuthFile, wallet: dRep01Wallet });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ test("4M. Should show view-all categorized governance actions", async ({
const governanceActionPage = new GovernanceActionsPage(page);
await governanceActionPage.goto();

await page.getByRole("button", { name: "Show All" }).click();
await page.getByRole("link", { name: "Show All" }).click();

const proposalCards = await governanceActionPage.getAllProposals();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ test.describe("Proposal checks", () => {

test.describe("Perform voting", () => {
let govActionDetailsPage: GovernanceActionDetailsPage;
let dRepPage: Page;
let govActionsPage: GovernanceActionsPage;

test.beforeEach(async ({ page, browser }) => {
test.slow(); // Due to queue in pop wallets
Expand All @@ -146,14 +148,14 @@ test.describe("Perform voting", () => {

const tempDRepAuth = await createTempDRepAuth(page, wallet);

const dRepPage = await createNewPageWithWallet(browser, {
dRepPage = await createNewPageWithWallet(browser, {
storageState: tempDRepAuth,
wallet,
enableDRepSigning: true,
});

const govActionsPage = new GovernanceActionsPage(dRepPage);
await govActionsPage.goto();
govActionsPage = new GovernanceActionsPage(dRepPage);
govActionsPage.goto();

// assert to wait until the loading button is hidden
await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({
Expand Down Expand Up @@ -282,6 +284,36 @@ test.describe("Perform voting", () => {
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes")
).toBeVisible();
});

const verifyVoteWithMetadata = async (testInfo: any, useGovToolIPFS: boolean = false) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);
const fakerContext = faker.lorem.sentence(200);

if (useGovToolIPFS) {
await govActionDetailsPage.vote(fakerContext, false, true);
} else {
await govActionDetailsPage.vote(fakerContext);
}

await dRepPage.reload();
await dRepPage.waitForTimeout(5_000);
await govActionsPage.votedTab.click();

const votedGovActionDetailsPage = await govActionsPage.viewFirstVotedProposal();
await votedGovActionDetailsPage.currentPage.getByTestId("show-more-button").click();
await votedGovActionDetailsPage.currentPage.waitForTimeout(2000);

const voteRationaleContext = await votedGovActionDetailsPage.currentPage.getByTestId("vote-rationale-context");
await expect(voteRationaleContext).toContainText(fakerContext);
};

test("5M_1. Should vote with Context (Download and store yourself)", async ({}, testInfo) => {
await verifyVoteWithMetadata(testInfo, false);
});

test("5M_2. Should vote with Context (GovTool pins data to IPFS)", async ({}, testInfo) => {
await verifyVoteWithMetadata(testInfo, true );
});
});

test.describe("Check voting power", () => {
Expand Down
1 change: 0 additions & 1 deletion tests/govtool-frontend/playwright/tests/dRep.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kuberService from "@services/kuberService";
import walletManager from "lib/walletManager";
import { functionWaitedAssert } from "@helpers/waitedLoop";
import { StaticWallet } from "@types";
import { Logger } from "@helpers/logger";

const REGISTER_DREP_WALLETS_COUNT = 6;
const DREP_WALLETS_COUNT = 11;
Expand Down