Skip to content

Commit 086dc66

Browse files
authored
Merge pull request #3127 from IntersectMBO/develop
chore: update @intersect.mbo/govtool-outcomes-pillar-ui to 1.2.5
2 parents 9e1651e + 657af82 commit 086dc66

File tree

19 files changed

+1241
-386
lines changed

19 files changed

+1241
-386
lines changed

.github/scripts/set_commit_status.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99
# Retrieve necessary variables from workflow
1010
START_TIME=${START_TIME:-$(date +%s)}
1111
TEST_STATUS=${TEST_STATUS:-"failure"}
12-
REPORT_NUMBER=${REPORT_NUMBER:-1}
12+
REPORT_NUMBER=${REPORT_NUMBER:-0}
1313
REPORT_NAME=${REPORT_NAME:-"govtool-frontend"}
1414
HOST_URL=${HOST_URL:-"https://govtool.cardanoapi.io"}
1515
CONTEXT="Playwright Tests : $HOST_URL"
@@ -64,6 +64,12 @@ else
6464
TARGET_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
6565
fi
6666

67+
if [[ "$REPORT_NUMBER" == 0 ]]; then
68+
DESCRIPTION="⚠️ Test execution failed due to missing report number"
69+
TEST_STATUS="error"
70+
TARGET_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
71+
fi
72+
6773

6874

6975
# Send commit status update to GitHub

govtool/frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

govtool/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@emotion/styled": "^11.11.0",
2828
"@emurgo/cardano-serialization-lib-asmjs": "^12.1.1",
2929
"@hookform/resolvers": "^3.3.1",
30-
"@intersect.mbo/govtool-outcomes-pillar-ui": "1.2.4",
30+
"@intersect.mbo/govtool-outcomes-pillar-ui": "1.2.5",
3131
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
3232
"@intersect.mbo/pdf-ui": "0.6.4",
3333
"@mui/icons-material": "^5.14.3",

govtool/frontend/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,10 +1492,10 @@
14921492
resolved "https://registry.npmjs.org/@inquirer/type/-/type-3.0.4.tgz"
14931493
integrity sha512-2MNFrDY8jkFYc9Il9DgLsHhMzuHnOYM1+CUYVWbzu9oT0hC7V7EcYvdCKeoll/Fcci04A+ERZ9wcc7cQ8lTkIA==
14941494

1495-
"@intersect.mbo/[email protected].4":
1496-
version "1.2.4"
1497-
resolved "https://registry.npmjs.org/@intersect.mbo/govtool-outcomes-pillar-ui/-/govtool-outcomes-pillar-ui-1.2.4.tgz"
1498-
integrity sha512-MQdbU2cQ4l5lUab+5WmugwzbgSrujnGoA6gZO297y2l/ZxAtX/PNjxm//F+G5CJuupl1lYEhRoo/WGE87oUOng==
1495+
"@intersect.mbo/[email protected].5":
1496+
version "1.2.5"
1497+
resolved "https://registry.npmjs.org/@intersect.mbo/govtool-outcomes-pillar-ui/-/govtool-outcomes-pillar-ui-1.2.5.tgz"
1498+
integrity sha512-z0QDUZKj262vvNCtjr2L8ILgeub8da3ryhMhgLJpuxuO1zfEBUhTuwUPkRuLBE1Gf52TW/AfgmR2qXANsjY4/Q==
14991499
dependencies:
15001500
"@fontsource/poppins" "^5.0.14"
15011501
"@intersect.mbo/intersectmbo.org-icons-set" "^1.0.8"

tests/govtool-frontend/playwright/lib/constants/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ export const guardrailsScript = {
2323

2424
export const guardrailsScriptHash =
2525
"914d97d63e2b7113465739faddd82362b1deaeedbcc4d01016c35c6e";
26+
27+
export const outcomeStatusType = [
28+
"Expired",
29+
"Not Ratified",
30+
"Ratified",
31+
"Enacted",
32+
"Live",
33+
];

tests/govtool-frontend/playwright/lib/helpers/extractExpiryDateFromText.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const monthNames = [
1414
];
1515

1616
export default function extractExpiryDateFromText(text: string): Date | null {
17-
const regex = /(\d{1,2})(st|nd|rd|th) ([\w]{3}) (\d{4})/;
17+
const regex = /(\d{1,2})(?:st|nd|rd|th)? (\w{3}) (\d{4})/;
1818
const match = text.match(regex);
1919

2020
if (match) {
2121
const day = parseInt(match[1]);
22-
const month = match[3];
23-
const year = parseInt(match[4]);
22+
const month = match[2];
23+
const year = parseInt(match[3]);
2424

2525
return new Date(year, monthNames.indexOf(month), day);
2626
} else {
Lines changed: 83 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,112 @@
1-
import { GovernanceActionType, IProposal } from "@types";
1+
import {
2+
GovernanceActionType,
3+
IProposal,
4+
outcomeProposal,
5+
outcomeType,
6+
} from "@types";
27
import { isBootStrapingPhase } from "./cardano";
38
import { SECURITY_RELEVANT_PARAMS_MAP } from "@constants/index";
49

5-
export const areDRepVoteTotalsDisplayed = async (proposal: IProposal) => {
10+
const getProposalType = (
11+
type: keyof typeof outcomeType,
12+
fallback: GovernanceActionType,
13+
proposal: IProposal | outcomeProposal
14+
) =>
15+
"proposal_params" in proposal
16+
? Object.keys(outcomeType).find(
17+
(key) => outcomeType[key] === outcomeType[type]
18+
)
19+
: fallback;
20+
21+
export const areDRepVoteTotalsDisplayed = async (
22+
proposal: IProposal | outcomeProposal
23+
) => {
624
const isInBootstrapPhase = await isBootStrapingPhase();
725
const isSecurityGroup = Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
8-
(paramKey) =>
9-
proposal.protocolParams?.[
10-
paramKey as keyof typeof proposal.protocolParams
11-
] !== null
26+
(paramKey) => {
27+
const params =
28+
"protocolParams" in proposal
29+
? proposal.protocolParams
30+
: proposal.proposal_params;
31+
return params?.[paramKey as keyof typeof params] !== null;
32+
}
1233
);
34+
1335
if (isInBootstrapPhase) {
36+
const HardForkInitiation = getProposalType(
37+
"HardForkInitiation",
38+
GovernanceActionType.HardFork,
39+
proposal
40+
);
41+
42+
const ProtocolParameterChange = getProposalType(
43+
"ParameterChange",
44+
GovernanceActionType.ProtocolParameterChange,
45+
proposal
46+
);
47+
1448
return !(
15-
proposal.type === GovernanceActionType.HardFork ||
16-
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
17-
!isSecurityGroup)
49+
proposal.type === HardForkInitiation ||
50+
(proposal.type === ProtocolParameterChange && !isSecurityGroup)
1851
);
1952
}
2053

2154
return true;
2255
};
2356

24-
export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
57+
export const areSPOVoteTotalsDisplayed = async (
58+
proposal: IProposal | outcomeProposal
59+
) => {
2560
const isInBootstrapPhase = await isBootStrapingPhase();
2661
const isSecurityGroup = Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
27-
(paramKey) =>
28-
proposal.protocolParams?.[
29-
paramKey as keyof typeof proposal.protocolParams
30-
] !== null
62+
(paramKey) => {
63+
const params =
64+
"protocolParams" in proposal
65+
? proposal.protocolParams
66+
: proposal.proposal_params;
67+
return params?.[paramKey as keyof typeof params] !== null;
68+
}
3169
);
70+
71+
const ProtocolParameterChange = getProposalType(
72+
"ParameterChange",
73+
GovernanceActionType.ProtocolParameterChange,
74+
proposal
75+
);
76+
const UpdatetotheConstitution = getProposalType(
77+
"NewConstitution",
78+
GovernanceActionType.UpdatetotheConstitution,
79+
proposal
80+
);
81+
const TreasuryWithdrawal = getProposalType(
82+
"TreasuryWithdrawals",
83+
GovernanceActionType.TreasuryWithdrawal,
84+
proposal
85+
);
86+
3287
if (isInBootstrapPhase) {
33-
return proposal.type !== GovernanceActionType.ProtocolParameterChange;
88+
return proposal.type !== ProtocolParameterChange;
3489
}
3590

3691
return !(
37-
proposal.type === GovernanceActionType.UpdatetotheConstitution ||
38-
proposal.type === GovernanceActionType.TreasuryWithdrawal ||
39-
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
40-
!isSecurityGroup)
92+
proposal.type === UpdatetotheConstitution ||
93+
proposal.type === TreasuryWithdrawal ||
94+
(proposal.type === ProtocolParameterChange && !isSecurityGroup)
4195
);
4296
};
4397

4498
export const areCCVoteTotalsDisplayed = (
45-
governanceActionType: GovernanceActionType
99+
proposal: IProposal | outcomeProposal
46100
) => {
47-
return ![
101+
const NoConfidence = getProposalType(
102+
"NoConfidence",
48103
GovernanceActionType.NoConfidence,
104+
proposal
105+
);
106+
const NewCommittee = getProposalType(
107+
"NewCommittee",
49108
GovernanceActionType.NewCommittee,
50-
].includes(governanceActionType);
109+
proposal
110+
);
111+
return ![NewCommittee, NoConfidence].includes(proposal.type);
51112
};

tests/govtool-frontend/playwright/lib/helpers/string.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ export function extractProposalIdFromUrl(url: string) {
44
return parseInt(url.split("/").pop());
55
}
66

7-
export function generateExactLengthText(characterLength:number) {
8-
let text = '';
9-
7+
export function generateExactLengthText(characterLength: number) {
8+
let text = "";
9+
1010
// Keep generating paragraphs until we exceed the required length
1111
while (text.length < characterLength) {
12-
text += faker.lorem.paragraphs(10);
12+
text += faker.lorem.paragraphs(10);
1313
}
14-
14+
1515
// Truncate to the exact number of characters needed
1616
return text.substring(0, characterLength);
17-
}
17+
}
18+
19+
export function toCamelCase(str: string) {
20+
return str
21+
.toLowerCase()
22+
.split(" ")
23+
.map((word, index) =>
24+
index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)
25+
)
26+
.join("");
27+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default class GovernanceActionsPage {
9999
await waitedLoop(async () => {
100100
return (
101101
(await this.page.locator('[data-testid$="-card"]').count()) > 0 ||
102-
this.page.getByText("No results for the search.")
102+
(await this.page.getByText("No results for the search.").isVisible())
103103
);
104104
});
105105
return this.page.locator('[data-testid$="-card"]').all();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import environments from "@constants/environments";
2+
import { Page, Response } from "@playwright/test";
3+
import { outcomeProposal } from "@types";
4+
5+
export default class OutcomeDetailsPage {
6+
readonly dRepYesVotes = this.page.getByTestId("submitted-votes-dReps-yes");
7+
readonly dRepNoVotes = this.page.getByTestId("submitted-votes-dReps-no");
8+
readonly dRepNotVoted = this.page.getByTestId(
9+
"submitted-votes-dReps-notVoted"
10+
);
11+
readonly dRepAbstainVotes = this.page.getByTestId(
12+
"submitted-votes-dReps-abstain"
13+
);
14+
15+
readonly sPosYesVotes = this.page.getByTestId("submitted-votes-sPos-yes");
16+
readonly sPosNoVotes = this.page.getByTestId("submitted-votes-sPos-no");
17+
readonly sPosAbstainVotes = this.page.getByTestId(
18+
"submitted-votes-sPos-abstain"
19+
);
20+
21+
readonly ccCommitteeYesVotes = this.page.getByTestId(
22+
"submitted-votes-ccCommittee-yes"
23+
);
24+
readonly ccCommitteeNoVotes = this.page.getByTestId(
25+
"submitted-votes-ccCommittee-no"
26+
);
27+
readonly ccCommitteeAbstainVotes = this.page.getByTestId(
28+
"submitted-votes-ccCommittee-abstain"
29+
);
30+
31+
constructor(private readonly page: Page) {}
32+
33+
get currentPage(): Page {
34+
return this.page;
35+
}
36+
37+
async goto(proposalId: string) {
38+
await this.page.goto(
39+
`${environments.frontendUrl}/outcomes/governance_actions/${proposalId}`
40+
);
41+
}
42+
43+
async getDRepTotalAbstainVoted(
44+
proposal: outcomeProposal,
45+
metricsResponses: Response
46+
): Promise<number | undefined> {
47+
const alwaysAbstainVotingPower = await metricsResponses
48+
.json()
49+
.then((res) => res.alwaysAbstainVotingPower);
50+
if (
51+
alwaysAbstainVotingPower &&
52+
typeof alwaysAbstainVotingPower === "number"
53+
) {
54+
const totalAbstainVoted =
55+
alwaysAbstainVotingPower + parseInt(proposal.abstain_votes);
56+
57+
return totalAbstainVoted;
58+
} else {
59+
return parseInt(proposal.abstain_votes);
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)