Skip to content

Commit 6ac3128

Browse files
committed
chore: check conversion for both script/ non-script drep
1 parent 3817a4a commit 6ac3128

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ export enum FullGovernanceDRepVoteActionsType {
118118

119119
export type DRepStatus = "Active" | "Inactive" | "Retired";
120120

121+
export interface PaginatedDRepResponse {
122+
page: number;
123+
pageSize: number;
124+
total: number;
125+
elements: IDRep[];
126+
}
127+
121128
export type IDRep = {
122129
isScriptBased: boolean;
123130
drepId: string;

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

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import DRepDetailsPage from "@pages/dRepDetailsPage";
77
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
88
import { expect, Locator } from "@playwright/test";
99
import { test } from "@fixtures/walletExtension";
10-
import { DRepStatus, IDRep } from "@types";
10+
import { DRepStatus, IDRep, PaginatedDRepResponse } from "@types";
1111

1212
test.beforeEach(async () => {
1313
await setAllureEpic("2. Delegation");
@@ -27,7 +27,7 @@ const statusRank: Record<DRepStatus, number> = {
2727
Retired: 3,
2828
};
2929

30-
const scripDRepId = require("../../lib/_mock/scriptDRep.json");
30+
const scripDRepId: PaginatedDRepResponse = require("../../lib/_mock/scriptDRep.json");
3131

3232
test("2K_2. Should sort DReps", async ({ page }) => {
3333
test.slow();
@@ -226,29 +226,40 @@ test.describe("DRep dependent tests", () => {
226226
});
227227
});
228228

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),
229+
Object.values(["script drep", "drep"]).forEach((type, index) => {
230+
test(`2Y_${index + 1}. Should correctly convert CIP-129/CIP-105 ${type}`, async ({
231+
page,
232+
}) => {
233+
const dRepId = scripDRepId.elements[0]["drepId"];
234+
const dRepResponse = {
235+
...scripDRepId,
236+
elements: [{ ...scripDRepId.elements[0], isScriptBased: false }],
237+
};
238+
await page.route("**/drep/list?page=0&pageSize=10&**", async (route) => {
239+
await route.fulfill({
240+
status: 200,
241+
contentType: "application/json",
242+
body: JSON.stringify(type === "drep" ? dRepResponse : scripDRepId),
243+
});
236244
});
237-
});
238245

239-
const responsePromise = page.waitForResponse(
240-
"**/drep/list?page=0&pageSize=10&**"
241-
);
246+
const responsePromise = page.waitForResponse(
247+
"**/drep/list?page=0&pageSize=10&**"
248+
);
242249

243-
const { cip129, cip105 } = convertDRep(dRepId, true);
250+
const { cip129, cip105 } = convertDRep(
251+
dRepId,
252+
type === "drep" ? false : true
253+
);
244254

245-
await page.goto(`/drep_directory/${dRepId}`);
246-
await responsePromise;
255+
await page.goto(`/drep_directory/${dRepId}`);
256+
await responsePromise;
247257

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);
258+
await expect(
259+
page.getByTestId("cip-129-drep-id-info-item-description")
260+
).toHaveText(cip129, { timeout: 60_000 });
261+
await expect(
262+
page.getByTestId("cip-105-drep-id-info-item-description")
263+
).toHaveText(cip105);
264+
});
254265
});

0 commit comments

Comments
 (0)