Skip to content

Commit ad04d61

Browse files
committed
tests: add invalid metadata error behavior tests
1 parent 4284399 commit ad04d61

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[
2+
{
3+
"id": "320",
4+
"tx_hash": "833382b22ebd07bb7dee60001cfdce78ede3b8397b1027daeb7996f61c072bde",
5+
"index": "0",
6+
"type": "InfoAction",
7+
"description": {
8+
"data": {
9+
"tag": "InfoAction"
10+
}
11+
},
12+
"expiry_date": "2025-02-27T00:01:04.000Z",
13+
"expiration": 856,
14+
"time": "2025-01-27T16:15:21.000Z",
15+
"epoch_no": 825,
16+
"url": "https://bit.ly/3zCH2HL",
17+
"data_hash": "99a19b124ceb89bbd92354e8d11f913d1aec7280ce19ac4c1c6cc72f0ea91884",
18+
"proposal_params": null,
19+
"title": null,
20+
"abstract": null,
21+
"motivation": null,
22+
"rationale": null,
23+
"yes_votes": "0",
24+
"no_votes": "14333625476330",
25+
"abstain_votes": "0",
26+
"pool_yes_votes": "0",
27+
"pool_no_votes": "0",
28+
"pool_abstain_votes": "0",
29+
"cc_yes_votes": "0",
30+
"cc_no_votes": "0",
31+
"cc_abstain_votes": "0",
32+
"prev_gov_action_index": null,
33+
"prev_gov_action_tx_hash": null,
34+
"status": {
35+
"ratified_epoch": null,
36+
"enacted_epoch": null,
37+
"dropped_epoch": 857,
38+
"expired_epoch": 856
39+
}
40+
}
41+
]

tests/govtool-frontend/playwright/lib/constants/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { faker } from "@faker-js/faker";
2+
import { InvalidMetadataType } from "@types";
3+
14
export const SECURITY_RELEVANT_PARAMS_MAP: Record<string, string> = {
25
maxBlockBodySize: "max_block_size",
36
maxTxSize: "max_tx_size",
@@ -31,3 +34,24 @@ export const outcomeStatusType = [
3134
"Enacted",
3235
"Live",
3336
];
37+
38+
export const InvalidMetadata: InvalidMetadataType[] = [
39+
{
40+
type: "Data Formatted Incorrectly",
41+
reason: "metadata is not in the correct format.",
42+
url: "https://bit.ly/3zCH2HL",
43+
hash: "1111111111111111111111111111111111111111111111111111111111111111",
44+
},
45+
{
46+
type: "Data Missing",
47+
reason: "metadata URL could not be found.",
48+
url: faker.internet.url() + "/test.jsonld",
49+
hash: "99a19b124ceb89bbd92354e8d11f913d1aec7280ce19ac4c1c6cc72f0ea91884",
50+
},
51+
{
52+
type: "Data Not Verifiable",
53+
reason: "metadata hash and URL do not match.",
54+
url: "https://metadata-govtool.cardanoapi.io/data/data.jsonld",
55+
hash: "e71bf6171adda3754a87fff5c2d8d9e404eb3366428a5be13f7e76357a39004f",
56+
},
57+
];

tests/govtool-frontend/playwright/lib/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ export type KuberValue = {
99
[policyId: string]: Record<string, BigInt | number> | BigInt | number;
1010
};
1111

12+
export interface PaginatedLiveProposal {
13+
page: number;
14+
pageSize: number;
15+
total: number;
16+
elements: IProposal[];
17+
}
18+
1219
export interface IProposal {
1320
id: string;
1421
txHash: string;
@@ -302,3 +309,10 @@ interface outcomeMetadataBody {
302309
rationale: string;
303310
title: string;
304311
}
312+
313+
export interface InvalidMetadataType {
314+
type: string;
315+
reason: string;
316+
url: string;
317+
hash: string;
318+
}

tests/govtool-frontend/playwright/tests/9-outcomes/outcomes.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { InvalidMetadata } from "@constants/index";
12
import { test } from "@fixtures/walletExtension";
23
import { correctVoteAdaFormat } from "@helpers/adaFormat";
34
import { setAllureEpic } from "@helpers/allure";
@@ -15,6 +16,8 @@ import OutComesPage from "@pages/outcomesPage";
1516
import { expect, Page } from "@playwright/test";
1617
import { outcomeMetadata, outcomeProposal, outcomeType } from "@types";
1718

19+
const invalidOutcomeProposals = require("../../lib/_mock/outcome.json");
20+
1821
test.beforeEach(async () => {
1922
await setAllureEpic("9. Outcomes");
2023
await skipIfNotHardFork();
@@ -400,3 +403,30 @@ test("9G. Should display correct vote counts on outcome details page", async ({
400403
})
401404
);
402405
});
406+
407+
test.describe("Invalid Outcome Metadata", () => {
408+
InvalidMetadata.forEach(({ type, reason, url, hash }, index) => {
409+
test(`9H_${index + 1}: Should display "${type}" message in outcomes when ${reason}`, async ({
410+
page,
411+
}) => {
412+
const outcomeResponse = {
413+
...invalidOutcomeProposals[0],
414+
url,
415+
data_hash: hash,
416+
};
417+
418+
await page.route(/.*\/governance-actions\/[a-f0-9]{64}\?.*/, (route) =>
419+
route.fulfill({ body: JSON.stringify([outcomeResponse]) })
420+
);
421+
422+
const outcomePage = new OutComesPage(page);
423+
await outcomePage.goto();
424+
await outcomePage.viewFirstOutcomes();
425+
426+
await expect(page.getByRole("heading", { name: type })).toBeVisible({
427+
timeout: 60_000,
428+
});
429+
await expect(page.getByText("Learn more")).toBeVisible();
430+
});
431+
});
432+
});

0 commit comments

Comments
 (0)