Skip to content

Commit

Permalink
Merge pull request #2471 from IntersectMBO/bugfix/governance-dRep-vot…
Browse files Browse the repository at this point in the history
…e-dependent-test

Bugfix/governance dRep vote dependent test
  • Loading branch information
kneerose authored Dec 5, 2024
2 parents d0463dc + 20665ae commit 390a14b
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 109 deletions.
30 changes: 15 additions & 15 deletions tests/govtool-frontend/playwright/lib/helpers/featureFlag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GrovernanceActionType, IProposal } from "@types";
import { GovernanceActionType, IProposal } from "@types";
import { isBootStrapingPhase } from "./cardano";
import { SECURITY_RELEVANT_PARAMS_MAP } from "@constants/index";

Expand All @@ -12,17 +12,17 @@ export const areDRepVoteTotalsDisplayed = async (proposal: IProposal) => {
);
if (isInBootstrapPhase) {
return !(
proposal.type === GrovernanceActionType.HardFork ||
(proposal.type === GrovernanceActionType.ProtocolParameterChange &&
proposal.type === GovernanceActionType.HardFork ||
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
!isSecurityGroup)
);
}

return ![
GrovernanceActionType.NoConfidence,
GrovernanceActionType.NewCommittee,
GrovernanceActionType.UpdatetotheConstitution,
].includes(proposal.type as GrovernanceActionType);
GovernanceActionType.NoConfidence,
GovernanceActionType.NewCommittee,
GovernanceActionType.UpdatetotheConstitution,
].includes(proposal.type as GovernanceActionType);
};

export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
Expand All @@ -34,22 +34,22 @@ export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
] !== null
);
if (isInBootstrapPhase) {
return proposal.type !== GrovernanceActionType.ProtocolParameterChange;
return proposal.type !== GovernanceActionType.ProtocolParameterChange;
}

return !(
proposal.type === GrovernanceActionType.UpdatetotheConstitution ||
proposal.type === GrovernanceActionType.TreasuryWithdrawal ||
(proposal.type === GrovernanceActionType.ProtocolParameterChange &&
proposal.type === GovernanceActionType.UpdatetotheConstitution ||
proposal.type === GovernanceActionType.TreasuryWithdrawal ||
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
!isSecurityGroup)
);
};

export const areCCVoteTotalsDisplayed = async (
governanceActionType: GrovernanceActionType
export const areCCVoteTotalsDisplayed = (
governanceActionType: GovernanceActionType
) => {
return ![
GrovernanceActionType.NoConfidence,
GrovernanceActionType.NewCommittee,
GovernanceActionType.NoConfidence,
GovernanceActionType.NewCommittee,
].includes(governanceActionType);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import removeAllSpaces from "@helpers/removeAllSpaces";
import { Locator, Page, expect } from "@playwright/test";
import { GrovernanceActionType, IProposal } from "@types";
import {
FullGovernanceDRepVoteActionsType,
GovernanceActionType,
IProposal,
} from "@types";
import environments from "lib/constants/environments";
import GovernanceActionDetailsPage from "./governanceActionDetailsPage";
import { getEnumKeyByValue } from "@helpers/enum";
Expand Down Expand Up @@ -47,8 +51,22 @@ export default class GovernanceActionsPage {
return new GovernanceActionDetailsPage(this.page);
}

async viewFirstDRepVoteEnabledGovernanceAction(): Promise<GovernanceActionDetailsPage> {
for (const governanceAction of Object.keys(
FullGovernanceDRepVoteActionsType
)) {
const result = await this.viewFirstProposalByGovernanceAction(
governanceAction as GovernanceActionType
);
if (result) {
return result;
}
}
return null;
}

async viewFirstProposalByGovernanceAction(
governanceAction: GrovernanceActionType
governanceAction: GovernanceActionType
): Promise<GovernanceActionDetailsPage> {
const proposalCard = this.page
.getByTestId(`govaction-${governanceAction}-card`)
Expand Down Expand Up @@ -121,15 +139,15 @@ export default class GovernanceActionsPage {
async sortAndValidate(
sortOption: string,
validationFn: (p1: IProposal, p2: IProposal) => boolean,
filterKeys = Object.keys(GrovernanceActionType)
filterKeys = Object.keys(GovernanceActionType)
) {
const responsesPromise = Promise.all(
filterKeys.map((filterKey) =>
this.page.waitForResponse((response) =>
response
.url()
.includes(
`&type[]=${GrovernanceActionType[filterKey]}&sort=${sortOption}`
`&type[]=${GovernanceActionType[filterKey]}&sort=${sortOption}`
)
)
)
Expand Down Expand Up @@ -165,7 +183,7 @@ export default class GovernanceActionsPage {
for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) {
const proposals = proposalsByType[0] as IProposal[];
const filterOptionKey = getEnumKeyByValue(
GrovernanceActionType,
GovernanceActionType,
proposals[0].type
);

Expand Down
2 changes: 1 addition & 1 deletion tests/govtool-frontend/playwright/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export enum ProposalType {
treasury = "Treasury",
}

export enum GrovernanceActionType {
export enum GovernanceActionType {
ProtocolParameterChange = "ParameterChange",
InfoAction = "InfoAction",
TreasuryWithdrawal = "TreasuryWithdrawals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import GovernanceActionsPage from "@pages/governanceActionsPage";
import { expect } from "@playwright/test";
import walletManager from "lib/walletManager";
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
import { GrovernanceActionType } from "@types";
import { GovernanceActionType } from "@types";

test.beforeEach(async () => {
await setAllureEpic("3. DRep registration");
Expand All @@ -37,12 +37,12 @@ test.describe("Logged in DReps", () => {
const governanceActionsPage = new GovernanceActionsPage(page);

await governanceActionsPage.goto();

await expect(page.getByText(/info action/i).first()).toBeVisible();

const governanceActionDetailsPage =
await governanceActionsPage.viewFirstProposalByGovernanceAction(
GrovernanceActionType.InfoAction
GovernanceActionType.InfoAction
);

await expect(governanceActionDetailsPage.voteBtn).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index";
import {
BootstrapGovernanceActionType,
FullGovernanceDRepVoteActionsType,
GrovernanceActionType,
GovernanceActionType,
IProposal,
} from "@types";
import walletManager from "lib/walletManager";
Expand Down Expand Up @@ -57,11 +57,16 @@ test.describe("Logged in DRep", () => {
const govActionsPage = new GovernanceActionsPage(page);
await govActionsPage.goto();

// assert to wait until the loading button is hidden
await expect(page.getByTestId("to-vote-tab")).toBeVisible({
timeout: 15_000,
});

govActionDetailsPage = (await isBootStrapingPhase())
? await govActionsPage.viewFirstProposalByGovernanceAction(
GrovernanceActionType.InfoAction
GovernanceActionType.InfoAction
)
: await govActionsPage.viewFirstProposal();
: await govActionsPage.viewFirstDRepVoteEnabledGovernanceAction();

await govActionDetailsPage.contextBtn.click();
await govActionDetailsPage.contextInput.fill(faker.lorem.sentence(200));
Expand Down Expand Up @@ -207,9 +212,7 @@ test.describe("Check vote count", () => {

// check ccCommittee votes
if (
areCCVoteTotalsDisplayed(
proposalToCheck.type as GrovernanceActionType
)
areCCVoteTotalsDisplayed(proposalToCheck.type as GovernanceActionType)
) {
await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText(
`${proposalToCheck.ccYesVotes}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage";
import GovernanceActionsPage from "@pages/governanceActionsPage";
import { expect, test } from "@playwright/test";
import { GrovernanceActionType, IProposal } from "@types";
import { GovernanceActionType, IProposal } from "@types";

test.beforeEach(async () => {
await setAllureEpic("4. Proposal visibility");
Expand Down Expand Up @@ -39,9 +39,9 @@ test("4K. Should display correct vote counts on governance details page for disc
page,
browser,
}) => {
const responsesPromise = Object.keys(GrovernanceActionType).map((filterKey) =>
const responsesPromise = Object.keys(GovernanceActionType).map((filterKey) =>
page.waitForResponse((response) =>
response.url().includes(`&type[]=${GrovernanceActionType[filterKey]}`)
response.url().includes(`&type[]=${GovernanceActionType[filterKey]}`)
)
);

Expand Down Expand Up @@ -98,7 +98,7 @@ test("4K. Should display correct vote counts on governance details page for disc

// check ccCommittee votes
if (
areCCVoteTotalsDisplayed(proposalToCheck.type as GrovernanceActionType)
areCCVoteTotalsDisplayed(proposalToCheck.type as GovernanceActionType)
) {
await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText(
`${proposalToCheck.ccYesVotes}`
Expand Down
Loading

0 comments on commit 390a14b

Please sign in to comment.