Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7e7201b
refactor: separate user snap test and move to position 10
kneerose Feb 27, 2025
564be94
fix: handle missing report number in commit status script
kneerose Feb 27, 2025
4d18146
feat: add outcomes page and related tests for outcomes governance act…
kneerose Feb 20, 2025
0357730
fix: update Usersnap test to align with recent changes
kneerose Feb 28, 2025
a7e75d1
feat: add outcome and outcomeMetadata types
kneerose Feb 28, 2025
25e2be8
fix: update test IDs and filtering functionality
kneerose Feb 28, 2025
f7ac54b
fix: search by id and title logic
kneerose Feb 28, 2025
10a26a5
test: 9D. copy governance actionId
kneerose Feb 28, 2025
59608e9
test: 9E. display only expired governance action
kneerose Feb 28, 2025
9243555
test: 9F. add load more outcomes test
kneerose Mar 3, 2025
bb28bf6
feat: extend outcomes type with more details
kneerose Mar 3, 2025
c7218b8
refactor: enhance vote flag for both outcome and governance action
kneerose Mar 3, 2025
cee1d29
feat: add OutcomeDetailsPage class
kneerose Mar 3, 2025
5bf7da3
feat: add filtering to outcomes page and implement view details funct…
kneerose Mar 3, 2025
a8785cf
test: 9G. add verification for vote counts on outcome details page
kneerose Mar 3, 2025
b441c6d
fix: outcomes page visibility test for mobile access and improve filt…
kneerose Mar 4, 2025
996c61d
fix: add assertions for governance actions presence outcome search
kneerose Mar 4, 2025
ae158bc
Merge pull request #3093 from IntersectMBO/fix/incorrect-report-numbe…
kneerose Mar 4, 2025
decbdee
Merge pull request #3092 from IntersectMBO/refactor/separate-user-sna…
kneerose Mar 4, 2025
aca5d7a
refactor: simplify expiry date extraction logic and remove unused par…
kneerose Mar 4, 2025
87e7519
refactor : shift possible proposal visibility test from logged-in to …
kneerose Mar 4, 2025
d5bd102
refactor: enhance outcomes page navigation by filter and sort
kneerose Mar 4, 2025
3791cbd
refactor: capatilize test describe block titles
kneerose Mar 4, 2025
4430949
Merge pull request #3120 from IntersectMBO/tests/outcomes
kneerose Mar 4, 2025
9fea794
chore: update @intersect.mbo/govtool-outcomes-pillar-ui to 1.2.5
github-actions[bot] Mar 4, 2025
657af82
Merge pull request #3126 from IntersectMBO/chore/@intersect.mbo/govto…
MSzalowski Mar 4, 2025
086dc66
Merge pull request #3127 from IntersectMBO/develop
MSzalowski Mar 4, 2025
57f3500
Merge pull request #3129 from IntersectMBO/test
MSzalowski Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/scripts/set_commit_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
# Retrieve necessary variables from workflow
START_TIME=${START_TIME:-$(date +%s)}
TEST_STATUS=${TEST_STATUS:-"failure"}
REPORT_NUMBER=${REPORT_NUMBER:-1}
REPORT_NUMBER=${REPORT_NUMBER:-0}
REPORT_NAME=${REPORT_NAME:-"govtool-frontend"}
HOST_URL=${HOST_URL:-"https://govtool.cardanoapi.io"}
CONTEXT="Playwright Tests : $HOST_URL"
Expand Down Expand Up @@ -64,6 +64,12 @@ else
TARGET_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
fi

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



# Send commit status update to GitHub
Expand Down
8 changes: 4 additions & 4 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@emotion/styled": "^11.11.0",
"@emurgo/cardano-serialization-lib-asmjs": "^12.1.1",
"@hookform/resolvers": "^3.3.1",
"@intersect.mbo/govtool-outcomes-pillar-ui": "1.2.4",
"@intersect.mbo/govtool-outcomes-pillar-ui": "1.2.5",
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
"@intersect.mbo/pdf-ui": "0.6.4",
"@mui/icons-material": "^5.14.3",
Expand Down
8 changes: 4 additions & 4 deletions govtool/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1492,10 +1492,10 @@
resolved "https://registry.npmjs.org/@inquirer/type/-/type-3.0.4.tgz"
integrity sha512-2MNFrDY8jkFYc9Il9DgLsHhMzuHnOYM1+CUYVWbzu9oT0hC7V7EcYvdCKeoll/Fcci04A+ERZ9wcc7cQ8lTkIA==

"@intersect.mbo/govtool-outcomes-pillar-ui@1.2.4":
version "1.2.4"
resolved "https://registry.npmjs.org/@intersect.mbo/govtool-outcomes-pillar-ui/-/govtool-outcomes-pillar-ui-1.2.4.tgz"
integrity sha512-MQdbU2cQ4l5lUab+5WmugwzbgSrujnGoA6gZO297y2l/ZxAtX/PNjxm//F+G5CJuupl1lYEhRoo/WGE87oUOng==
"@intersect.mbo/govtool-outcomes-pillar-ui@1.2.5":
version "1.2.5"
resolved "https://registry.npmjs.org/@intersect.mbo/govtool-outcomes-pillar-ui/-/govtool-outcomes-pillar-ui-1.2.5.tgz"
integrity sha512-z0QDUZKj262vvNCtjr2L8ILgeub8da3ryhMhgLJpuxuO1zfEBUhTuwUPkRuLBE1Gf52TW/AfgmR2qXANsjY4/Q==
dependencies:
"@fontsource/poppins" "^5.0.14"
"@intersect.mbo/intersectmbo.org-icons-set" "^1.0.8"
Expand Down
8 changes: 8 additions & 0 deletions tests/govtool-frontend/playwright/lib/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export const guardrailsScript = {

export const guardrailsScriptHash =
"914d97d63e2b7113465739faddd82362b1deaeedbcc4d01016c35c6e";

export const outcomeStatusType = [
"Expired",
"Not Ratified",
"Ratified",
"Enacted",
"Live",
];
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const monthNames = [
];

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

if (match) {
const day = parseInt(match[1]);
const month = match[3];
const year = parseInt(match[4]);
const month = match[2];
const year = parseInt(match[3]);

return new Date(year, monthNames.indexOf(month), day);
} else {
Expand Down
105 changes: 83 additions & 22 deletions tests/govtool-frontend/playwright/lib/helpers/featureFlag.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,112 @@
import { GovernanceActionType, IProposal } from "@types";
import {
GovernanceActionType,
IProposal,
outcomeProposal,
outcomeType,
} from "@types";
import { isBootStrapingPhase } from "./cardano";
import { SECURITY_RELEVANT_PARAMS_MAP } from "@constants/index";

export const areDRepVoteTotalsDisplayed = async (proposal: IProposal) => {
const getProposalType = (
type: keyof typeof outcomeType,
fallback: GovernanceActionType,
proposal: IProposal | outcomeProposal
) =>
"proposal_params" in proposal
? Object.keys(outcomeType).find(
(key) => outcomeType[key] === outcomeType[type]
)
: fallback;

export const areDRepVoteTotalsDisplayed = async (
proposal: IProposal | outcomeProposal
) => {
const isInBootstrapPhase = await isBootStrapingPhase();
const isSecurityGroup = Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
(paramKey) =>
proposal.protocolParams?.[
paramKey as keyof typeof proposal.protocolParams
] !== null
(paramKey) => {
const params =
"protocolParams" in proposal
? proposal.protocolParams
: proposal.proposal_params;
return params?.[paramKey as keyof typeof params] !== null;
}
);

if (isInBootstrapPhase) {
const HardForkInitiation = getProposalType(
"HardForkInitiation",
GovernanceActionType.HardFork,
proposal
);

const ProtocolParameterChange = getProposalType(
"ParameterChange",
GovernanceActionType.ProtocolParameterChange,
proposal
);

return !(
proposal.type === GovernanceActionType.HardFork ||
(proposal.type === GovernanceActionType.ProtocolParameterChange &&
!isSecurityGroup)
proposal.type === HardForkInitiation ||
(proposal.type === ProtocolParameterChange && !isSecurityGroup)
);
}

return true;
};

export const areSPOVoteTotalsDisplayed = async (proposal: IProposal) => {
export const areSPOVoteTotalsDisplayed = async (
proposal: IProposal | outcomeProposal
) => {
const isInBootstrapPhase = await isBootStrapingPhase();
const isSecurityGroup = Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
(paramKey) =>
proposal.protocolParams?.[
paramKey as keyof typeof proposal.protocolParams
] !== null
(paramKey) => {
const params =
"protocolParams" in proposal
? proposal.protocolParams
: proposal.proposal_params;
return params?.[paramKey as keyof typeof params] !== null;
}
);

const ProtocolParameterChange = getProposalType(
"ParameterChange",
GovernanceActionType.ProtocolParameterChange,
proposal
);
const UpdatetotheConstitution = getProposalType(
"NewConstitution",
GovernanceActionType.UpdatetotheConstitution,
proposal
);
const TreasuryWithdrawal = getProposalType(
"TreasuryWithdrawals",
GovernanceActionType.TreasuryWithdrawal,
proposal
);

if (isInBootstrapPhase) {
return proposal.type !== GovernanceActionType.ProtocolParameterChange;
return proposal.type !== ProtocolParameterChange;
}

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

export const areCCVoteTotalsDisplayed = (
governanceActionType: GovernanceActionType
proposal: IProposal | outcomeProposal
) => {
return ![
const NoConfidence = getProposalType(
"NoConfidence",
GovernanceActionType.NoConfidence,
proposal
);
const NewCommittee = getProposalType(
"NewCommittee",
GovernanceActionType.NewCommittee,
].includes(governanceActionType);
proposal
);
return ![NewCommittee, NoConfidence].includes(proposal.type);
};
22 changes: 16 additions & 6 deletions tests/govtool-frontend/playwright/lib/helpers/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ export function extractProposalIdFromUrl(url: string) {
return parseInt(url.split("/").pop());
}

export function generateExactLengthText(characterLength:number) {
let text = '';
export function generateExactLengthText(characterLength: number) {
let text = "";

// Keep generating paragraphs until we exceed the required length
while (text.length < characterLength) {
text += faker.lorem.paragraphs(10);
text += faker.lorem.paragraphs(10);
}

// Truncate to the exact number of characters needed
return text.substring(0, characterLength);
}
}

export function toCamelCase(str: string) {
return str
.toLowerCase()
.split(" ")
.map((word, index) =>
index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)
)
.join("");
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class GovernanceActionsPage {
await waitedLoop(async () => {
return (
(await this.page.locator('[data-testid$="-card"]').count()) > 0 ||
this.page.getByText("No results for the search.")
(await this.page.getByText("No results for the search.").isVisible())
);
});
return this.page.locator('[data-testid$="-card"]').all();
Expand Down
62 changes: 62 additions & 0 deletions tests/govtool-frontend/playwright/lib/pages/outcomeDetailsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import environments from "@constants/environments";
import { Page, Response } from "@playwright/test";
import { outcomeProposal } from "@types";

export default class OutcomeDetailsPage {
readonly dRepYesVotes = this.page.getByTestId("submitted-votes-dReps-yes");
readonly dRepNoVotes = this.page.getByTestId("submitted-votes-dReps-no");
readonly dRepNotVoted = this.page.getByTestId(
"submitted-votes-dReps-notVoted"
);
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-ccCommittee-yes"
);
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 {
return this.page;
}

async goto(proposalId: string) {
await this.page.goto(
`${environments.frontendUrl}/outcomes/governance_actions/${proposalId}`
);
}

async getDRepTotalAbstainVoted(
proposal: outcomeProposal,
metricsResponses: Response
): Promise<number | undefined> {
const alwaysAbstainVotingPower = await metricsResponses
.json()
.then((res) => res.alwaysAbstainVotingPower);
if (
alwaysAbstainVotingPower &&
typeof alwaysAbstainVotingPower === "number"
) {
const totalAbstainVoted =
alwaysAbstainVotingPower + parseInt(proposal.abstain_votes);

return totalAbstainVoted;
} else {
return parseInt(proposal.abstain_votes);
}
}
}
Loading