Skip to content

Commit 1b1f195

Browse files
committed
tests: add tests for invalid live voting metadata error behaviour
1 parent ad04d61 commit 1b1f195

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage";
1010
import GovernanceActionsPage from "@pages/governanceActionsPage";
1111
import { expect } from "@playwright/test";
1212
import { test } from "@fixtures/walletExtension";
13-
import { GovernanceActionType, IProposal } from "@types";
13+
import { GovernanceActionType, IProposal, PaginatedLiveProposal } from "@types";
1414
import { injectLogger } from "@helpers/page";
1515
import removeAllSpaces from "@helpers/removeAllSpaces";
1616
import { functionWaitedAssert } from "@helpers/waitedLoop";
1717
import extractExpiryDateFromText from "@helpers/extractExpiryDateFromText";
18+
import { InvalidMetadata } from "@constants/index";
1819

1920
test.beforeEach(async () => {
2021
await setAllureEpic("4. Proposal visibility");
2122
await skipIfNotHardFork();
2223
});
2324

24-
const infoTypeProposal = require("../../lib/_mock/infoTypeProposal.json");
25+
const infoTypeProposal: PaginatedLiveProposal = require("../../lib/_mock/infoTypeProposal.json");
2526

2627
const filterOptionNames = [
2728
"Protocol Parameter Change",
@@ -298,3 +299,37 @@ test("4K. Should display correct vote counts on governance details page for disc
298299
})
299300
);
300301
});
302+
303+
test.describe("Invalid Live voting Metadata", () => {
304+
InvalidMetadata.forEach(({ type, reason, url, hash }, index) => {
305+
test(`4P_${index + 1}: Should display ${type} message in live voting when ${reason}`, async ({
306+
page,
307+
}) => {
308+
const proposal: IProposal = {
309+
...infoTypeProposal.elements[0],
310+
url,
311+
metadataHash: hash,
312+
};
313+
const liveProposalResponse: PaginatedLiveProposal = {
314+
...infoTypeProposal,
315+
elements: [proposal],
316+
};
317+
318+
await page.route("**/proposal/list?**", async (route) =>
319+
route.fulfill({
320+
body: JSON.stringify(liveProposalResponse),
321+
})
322+
);
323+
324+
const governanceActionPage = new GovernanceActionsPage(page);
325+
await governanceActionPage.goto();
326+
await governanceActionPage.viewFirstProposal();
327+
328+
await expect(page.getByRole("heading", { name: type })).toBeVisible({
329+
timeout: 60_000,
330+
});
331+
await expect(page.getByText("Learn more")).toBeVisible();
332+
await expect(page.getByTestId("external-modal-button")).toBeVisible();
333+
});
334+
});
335+
});

0 commit comments

Comments
 (0)