Skip to content

Commit

Permalink
Merge pull request #2081 from IntersectMBO/bugfix/bootstrap-proposal-…
Browse files Browse the repository at this point in the history
…voting-restriction

Bugfix/bootstrap-proposal-voting-restriction
  • Loading branch information
kneerose authored Sep 27, 2024
2 parents fb2eda6 + 4879c89 commit 8cba5c6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ export default class GovernanceActionDetailsPage {
readonly contextInput = this.page.getByTestId("provide-context-input");
readonly cancelModalBtn = this.page.getByTestId("cancel-modal-button");

readonly dRepYesVotes = this.page.getByTestId("submitted-votes-dReps-yes");
readonly dRepNoVotes = this.page.getByTestId("submitted-votes-dReps-no");
readonly dRepAbstainVotes = this.page.getByTestId(
"submitted-votes-dReps-abstain"
);

readonly sPosYesVotes = this.page.getByTestId("submitted-votes-sPos-yes");
readonly sPosNoVotes = this.page.getByTestId("submitted-votes-sPos-no");
readonly sPosAbstainVotes = this.page.getByTestId(
"submitted-votes-sPos-abstain"
);

readonly ccCommitteeYesVotes = this.page.getByTestId(
"submitted-votes-sPos-no"
);
readonly ccCommitteeNoVotes = this.page.getByTestId(
"submitted-votes-ccCommittee-no"
);
readonly ccCommitteeAbstainVotes = this.page.getByTestId(
"submitted-votes-ccCommittee-abstain"
);

constructor(private readonly page: Page) {}

get currentPage(): Page {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ test.describe("Check voting power", () => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

const wallet = await walletManager.popWallet("registeredDRep");
await walletManager.removeCopyWallet(wallet,"registeredDRepCopy");
await walletManager.removeCopyWallet(wallet, "registeredDRepCopy");

const tempDRepAuth = await createTempDRepAuth(page, wallet);

Expand Down Expand Up @@ -255,27 +255,31 @@ test.describe("Bootstrap phase", () => {
page,
context,
}) => {
await page.route("**/epoch/params", async (route) => {
// Fetch the original response from the server
const response = await route.fetch();
const json = await response.json();

// update protocol major version
json["protocol_major"] = 9;
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(json),
});
});

const voteBlacklistOptions = Object.keys(GrovernanceActionType).filter(
(option) => option !== BootstrapGovernanceActionType.InfoAction
);

const govActionsPage = new GovernanceActionsPage(page);
await govActionsPage.goto();

const protocolParameter = await page.evaluate(() => {
return localStorage.getItem("protocol_params");
});
const parsedProtocolParameter = JSON.parse(protocolParameter);
// update protocol_major version
parsedProtocolParameter["protocol_major"] = 9;

const updatedProtocolParameterString = JSON.stringify(
parsedProtocolParameter
);
// add updated protocol parameter
await context.addInitScript(`
localStorage.setItem('protocol_params', '${updatedProtocolParameterString}');
`);
// wait until the loading button is hidden
await expect(
page.getByRole("progressbar").getByRole("img")
).not.toBeVisible({ timeout: 10_000 });

for (const voteBlacklistOption of voteBlacklistOptions) {
const governanceActionDetailsPage =
Expand All @@ -284,9 +288,30 @@ test.describe("Bootstrap phase", () => {
);

if (governanceActionDetailsPage !== null) {
await expect(page.getByText("yes₳").first()).toBeVisible();
await expect(page.getByText("abstain₳").first()).toBeVisible();
await expect(page.getByText("no₳").first()).toBeVisible();
// dRep vote
await expect(governanceActionDetailsPage.dRepYesVotes).toBeVisible();
await expect(
governanceActionDetailsPage.dRepAbstainVotes
).toBeVisible();
await expect(governanceActionDetailsPage.dRepNoVotes).toBeVisible();

// sPos vote
await expect(governanceActionDetailsPage.sPosYesVotes).toBeVisible();
await expect(
governanceActionDetailsPage.sPosAbstainVotes
).toBeVisible();
await expect(governanceActionDetailsPage.sPosNoVotes).toBeVisible();

// ccCommittee vote
await expect(
governanceActionDetailsPage.ccCommitteeYesVotes
).toBeVisible();
await expect(
governanceActionDetailsPage.ccCommitteeAbstainVotes
).toBeVisible();
await expect(
governanceActionDetailsPage.ccCommitteeNoVotes
).toBeVisible();

await expect(
governanceActionDetailsPage.yesVoteRadio
Expand Down

0 comments on commit 8cba5c6

Please sign in to comment.