Skip to content

Commit d04969d

Browse files
committed
feat: check both treasury and info proposals for categorized proposals
1 parent 654a650 commit d04969d

File tree

1 file changed

+46
-20
lines changed

1 file changed

+46
-20
lines changed

tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { isBootStrapingPhase, skipIfNotHardFork } from "@helpers/cardano";
66
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
77
import ProposalDiscussionPage from "@pages/proposalDiscussionPage";
88
import { expect } from "@playwright/test";
9+
import { ProposalType } from "@types";
910

1011
const mockProposal = require("../../lib/_mock/proposal.json");
1112
const mockPoll = require("../../lib/_mock/proposalPoll.json");
1213
const mockComments = require("../../lib/_mock/proposalComments.json");
1314
const mockInfoProposedGA = require("../../lib/_mock/infoProposedGAs.json");
15+
const mockTreasuryProposal = require("../../lib/_mock/treasuryProposedGAs.json");
1416

1517
const PROPOSAL_TYPE_FILTERS = ["Info", "Treasury"];
1618
const BOOTSTRAP_PROPOSAL_TYPE_FILTERS = ["Info"];
@@ -92,27 +94,51 @@ test("8C. Should search the list of proposed governance actions.", async ({
9294
}
9395
});
9496

95-
test("8D.Should show the view-all categorized proposed governance actions.", async ({
96-
page,
97+
test("8D. Should show the view-all categorized proposed governance actions.", async ({
98+
browser,
9799
}) => {
98-
await page.route("**/api/proposals?**", async (route) => {
99-
return route.fulfill({
100-
body: JSON.stringify(mockInfoProposedGA),
101-
});
102-
});
103-
104-
const proposalDiscussionPage = new ProposalDiscussionPage(page);
105-
await proposalDiscussionPage.goto();
106-
107-
await proposalDiscussionPage.showAllBtn.click();
108-
109-
const proposalCards = await proposalDiscussionPage.getAllProposals();
110-
111-
for (const proposalCard of proposalCards) {
112-
await expect(
113-
proposalCard.getByTestId("governance-action-type")
114-
).toBeVisible();
115-
}
100+
await Promise.all(
101+
Object.entries({
102+
[ProposalType.info]: mockInfoProposedGA,
103+
[ProposalType.treasury]: mockTreasuryProposal,
104+
}).map(async ([proposalType, mockData]) => {
105+
const govActionTypeId = proposalType === ProposalType.info ? 1 : 2;
106+
const requestUrl = `**/api/proposals?filters[$and][0][gov_action_type_id]=${govActionTypeId}&**`;
107+
let requestHandled = false;
108+
109+
const context = await browser.newContext();
110+
const page = await context.newPage();
111+
112+
await page.route(requestUrl, async (route) => {
113+
if (!requestHandled) {
114+
requestHandled = true;
115+
return route.fulfill({
116+
body: JSON.stringify(mockData),
117+
});
118+
}
119+
return route.continue();
120+
});
121+
122+
const proposalDiscussionPage = new ProposalDiscussionPage(page);
123+
await proposalDiscussionPage.goto();
124+
125+
const showAllButton = page.getByTestId("show-all-button");
126+
127+
if (proposalType === ProposalType.treasury) {
128+
await showAllButton.nth(1).click();
129+
} else {
130+
await showAllButton.first().click();
131+
}
132+
133+
const proposalCards = await proposalDiscussionPage.getAllProposals();
134+
135+
for (const proposalCard of proposalCards) {
136+
await expect(
137+
proposalCard.getByTestId("governance-action-type")
138+
).toHaveText(proposalType, { timeout: 20_000 });
139+
}
140+
})
141+
);
116142
});
117143

118144
test("8H. Should disable proposal interaction on a disconnected state.", async ({

0 commit comments

Comments
 (0)