Skip to content

Commit 3817a4a

Browse files
committed
test: add mock data and tests for converting script DRep to CIP-129/CIP-105
1 parent a6ca482 commit 3817a4a

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"page": 0,
3+
"pageSize": 10,
4+
"total": 1,
5+
"elements": [
6+
{
7+
"isScriptBased": true,
8+
"drepId": "429b12461640cefd3a4a192f7c531d8f6c6d33610b727f481eb22d39",
9+
"view": "drep1g2d3y3skgr806wj2ryhhc5ca3akx6vmppde87jq7kgknjmv589e",
10+
"url": null,
11+
"metadataHash": null,
12+
"deposit": 500000000,
13+
"votingPower": 83414740266257,
14+
"status": "Active",
15+
"type": "SoleVoter",
16+
"latestTxHash": "8de2a5f9074679de947549ea36c3980496503ffc40f0cbce5ce1ee3df66306e9",
17+
"latestRegistrationDate": "2024-11-20T01:59:20Z",
18+
"metadataError": null,
19+
"paymentAddress": null,
20+
"givenName": null,
21+
"objectives": null,
22+
"motivations": null,
23+
"qualifications": null,
24+
"imageUrl": null,
25+
"imageHash": null
26+
}
27+
]
28+
}

tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import environments from "@constants/environments";
22
import { setAllureEpic } from "@helpers/allure";
33
import { skipIfNotHardFork } from "@helpers/cardano";
4-
import { fetchFirstActiveDRepDetails } from "@helpers/dRep";
4+
import { convertDRep, fetchFirstActiveDRepDetails } from "@helpers/dRep";
55
import { functionWaitedAssert } from "@helpers/waitedLoop";
66
import DRepDetailsPage from "@pages/dRepDetailsPage";
77
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
@@ -27,6 +27,8 @@ const statusRank: Record<DRepStatus, number> = {
2727
Retired: 3,
2828
};
2929

30+
const scripDRepId = require("../../lib/_mock/scriptDRep.json");
31+
3032
test("2K_2. Should sort DReps", async ({ page }) => {
3133
test.slow();
3234

@@ -223,3 +225,30 @@ test.describe("DRep dependent tests", () => {
223225
expect(copiedTextDRepDirectory).toEqual(dRepId);
224226
});
225227
});
228+
229+
test("2Y. Should correctly convert CIP-129/CIP-105 script dRep", async ({ page }) => {
230+
const dRepId = scripDRepId.elements[0]["drepId"];
231+
await page.route("**/drep/list?page=0&pageSize=10&**", async (route) => {
232+
await route.fulfill({
233+
status: 200,
234+
contentType: "application/json",
235+
body: JSON.stringify(scripDRepId),
236+
});
237+
});
238+
239+
const responsePromise = page.waitForResponse(
240+
"**/drep/list?page=0&pageSize=10&**"
241+
);
242+
243+
const { cip129, cip105 } = convertDRep(dRepId, true);
244+
245+
await page.goto(`/drep_directory/${dRepId}`);
246+
await responsePromise;
247+
248+
await expect(
249+
page.getByTestId("cip-129-drep-id-info-item-description")
250+
).toHaveText(cip129, { timeout: 60_000 });
251+
await expect(
252+
page.getByTestId("cip-105-drep-id-info-item-description")
253+
).toHaveText(cip105);
254+
});

0 commit comments

Comments
 (0)