Skip to content

Commit 390a14b

Browse files
authored
Merge pull request #2471 from IntersectMBO/bugfix/governance-dRep-vote-dependent-test
Bugfix/governance dRep vote dependent test
2 parents d0463dc + 20665ae commit 390a14b

File tree

8 files changed

+130
-109
lines changed

8 files changed

+130
-109
lines changed
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GrovernanceActionType, IProposal } from "@types";
1+
import { GovernanceActionType, IProposal } from "@types";
22
import { isBootStrapingPhase } from "./cardano";
33
import { SECURITY_RELEVANT_PARAMS_MAP } from "@constants/index";
44

@@ -12,17 +12,17 @@ export const areDRepVoteTotalsDisplayed = async (proposal: IProposal) => {
1212
);
1313
if (isInBootstrapPhase) {
1414
return !(
15-
proposal.type === GrovernanceActionType.HardFork ||
16-
(proposal.type === GrovernanceActionType.ProtocolParameterChange &&
15+
proposal.type === GovernanceActionType.HardFork ||
16+
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
1717
!isSecurityGroup)
1818
);
1919
}
2020

2121
return ![
22-
GrovernanceActionType.NoConfidence,
23-
GrovernanceActionType.NewCommittee,
24-
GrovernanceActionType.UpdatetotheConstitution,
25-
].includes(proposal.type as GrovernanceActionType);
22+
GovernanceActionType.NoConfidence,
23+
GovernanceActionType.NewCommittee,
24+
GovernanceActionType.UpdatetotheConstitution,
25+
].includes(proposal.type as GovernanceActionType);
2626
};
2727

2828
export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
@@ -34,22 +34,22 @@ export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
3434
] !== null
3535
);
3636
if (isInBootstrapPhase) {
37-
return proposal.type !== GrovernanceActionType.ProtocolParameterChange;
37+
return proposal.type !== GovernanceActionType.ProtocolParameterChange;
3838
}
3939

4040
return !(
41-
proposal.type === GrovernanceActionType.UpdatetotheConstitution ||
42-
proposal.type === GrovernanceActionType.TreasuryWithdrawal ||
43-
(proposal.type === GrovernanceActionType.ProtocolParameterChange &&
41+
proposal.type === GovernanceActionType.UpdatetotheConstitution ||
42+
proposal.type === GovernanceActionType.TreasuryWithdrawal ||
43+
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
4444
!isSecurityGroup)
4545
);
4646
};
4747

48-
export const areCCVoteTotalsDisplayed = async (
49-
governanceActionType: GrovernanceActionType
48+
export const areCCVoteTotalsDisplayed = (
49+
governanceActionType: GovernanceActionType
5050
) => {
5151
return ![
52-
GrovernanceActionType.NoConfidence,
53-
GrovernanceActionType.NewCommittee,
52+
GovernanceActionType.NoConfidence,
53+
GovernanceActionType.NewCommittee,
5454
].includes(governanceActionType);
5555
};

tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import removeAllSpaces from "@helpers/removeAllSpaces";
22
import { Locator, Page, expect } from "@playwright/test";
3-
import { GrovernanceActionType, IProposal } from "@types";
3+
import {
4+
FullGovernanceDRepVoteActionsType,
5+
GovernanceActionType,
6+
IProposal,
7+
} from "@types";
48
import environments from "lib/constants/environments";
59
import GovernanceActionDetailsPage from "./governanceActionDetailsPage";
610
import { getEnumKeyByValue } from "@helpers/enum";
@@ -47,8 +51,22 @@ export default class GovernanceActionsPage {
4751
return new GovernanceActionDetailsPage(this.page);
4852
}
4953

54+
async viewFirstDRepVoteEnabledGovernanceAction(): Promise<GovernanceActionDetailsPage> {
55+
for (const governanceAction of Object.keys(
56+
FullGovernanceDRepVoteActionsType
57+
)) {
58+
const result = await this.viewFirstProposalByGovernanceAction(
59+
governanceAction as GovernanceActionType
60+
);
61+
if (result) {
62+
return result;
63+
}
64+
}
65+
return null;
66+
}
67+
5068
async viewFirstProposalByGovernanceAction(
51-
governanceAction: GrovernanceActionType
69+
governanceAction: GovernanceActionType
5270
): Promise<GovernanceActionDetailsPage> {
5371
const proposalCard = this.page
5472
.getByTestId(`govaction-${governanceAction}-card`)
@@ -121,15 +139,15 @@ export default class GovernanceActionsPage {
121139
async sortAndValidate(
122140
sortOption: string,
123141
validationFn: (p1: IProposal, p2: IProposal) => boolean,
124-
filterKeys = Object.keys(GrovernanceActionType)
142+
filterKeys = Object.keys(GovernanceActionType)
125143
) {
126144
const responsesPromise = Promise.all(
127145
filterKeys.map((filterKey) =>
128146
this.page.waitForResponse((response) =>
129147
response
130148
.url()
131149
.includes(
132-
`&type[]=${GrovernanceActionType[filterKey]}&sort=${sortOption}`
150+
`&type[]=${GovernanceActionType[filterKey]}&sort=${sortOption}`
133151
)
134152
)
135153
)
@@ -165,7 +183,7 @@ export default class GovernanceActionsPage {
165183
for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) {
166184
const proposals = proposalsByType[0] as IProposal[];
167185
const filterOptionKey = getEnumKeyByValue(
168-
GrovernanceActionType,
186+
GovernanceActionType,
169187
proposals[0].type
170188
);
171189

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export enum ProposalType {
7474
treasury = "Treasury",
7575
}
7676

77-
export enum GrovernanceActionType {
77+
export enum GovernanceActionType {
7878
ProtocolParameterChange = "ParameterChange",
7979
InfoAction = "InfoAction",
8080
TreasuryWithdrawal = "TreasuryWithdrawals",

tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import GovernanceActionsPage from "@pages/governanceActionsPage";
1313
import { expect } from "@playwright/test";
1414
import walletManager from "lib/walletManager";
1515
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
16-
import { GrovernanceActionType } from "@types";
16+
import { GovernanceActionType } from "@types";
1717

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

3939
await governanceActionsPage.goto();
40-
40+
4141
await expect(page.getByText(/info action/i).first()).toBeVisible();
4242

4343
const governanceActionDetailsPage =
4444
await governanceActionsPage.viewFirstProposalByGovernanceAction(
45-
GrovernanceActionType.InfoAction
45+
GovernanceActionType.InfoAction
4646
);
4747

4848
await expect(governanceActionDetailsPage.voteBtn).toBeVisible();

tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index";
1616
import {
1717
BootstrapGovernanceActionType,
1818
FullGovernanceDRepVoteActionsType,
19-
GrovernanceActionType,
19+
GovernanceActionType,
2020
IProposal,
2121
} from "@types";
2222
import walletManager from "lib/walletManager";
@@ -57,11 +57,16 @@ test.describe("Logged in DRep", () => {
5757
const govActionsPage = new GovernanceActionsPage(page);
5858
await govActionsPage.goto();
5959

60+
// assert to wait until the loading button is hidden
61+
await expect(page.getByTestId("to-vote-tab")).toBeVisible({
62+
timeout: 15_000,
63+
});
64+
6065
govActionDetailsPage = (await isBootStrapingPhase())
6166
? await govActionsPage.viewFirstProposalByGovernanceAction(
62-
GrovernanceActionType.InfoAction
67+
GovernanceActionType.InfoAction
6368
)
64-
: await govActionsPage.viewFirstProposal();
69+
: await govActionsPage.viewFirstDRepVoteEnabledGovernanceAction();
6570

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

208213
// check ccCommittee votes
209214
if (
210-
areCCVoteTotalsDisplayed(
211-
proposalToCheck.type as GrovernanceActionType
212-
)
215+
areCCVoteTotalsDisplayed(proposalToCheck.type as GovernanceActionType)
213216
) {
214217
await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText(
215218
`${proposalToCheck.ccYesVotes}`

tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage";
1010
import GovernanceActionsPage from "@pages/governanceActionsPage";
1111
import { expect, test } from "@playwright/test";
12-
import { GrovernanceActionType, IProposal } from "@types";
12+
import { GovernanceActionType, IProposal } from "@types";
1313

1414
test.beforeEach(async () => {
1515
await setAllureEpic("4. Proposal visibility");
@@ -39,9 +39,9 @@ test("4K. Should display correct vote counts on governance details page for disc
3939
page,
4040
browser,
4141
}) => {
42-
const responsesPromise = Object.keys(GrovernanceActionType).map((filterKey) =>
42+
const responsesPromise = Object.keys(GovernanceActionType).map((filterKey) =>
4343
page.waitForResponse((response) =>
44-
response.url().includes(`&type[]=${GrovernanceActionType[filterKey]}`)
44+
response.url().includes(`&type[]=${GovernanceActionType[filterKey]}`)
4545
)
4646
);
4747

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

9999
// check ccCommittee votes
100100
if (
101-
areCCVoteTotalsDisplayed(proposalToCheck.type as GrovernanceActionType)
101+
areCCVoteTotalsDisplayed(proposalToCheck.type as GovernanceActionType)
102102
) {
103103
await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText(
104104
`${proposalToCheck.ccYesVotes}`

0 commit comments

Comments
 (0)