Skip to content

Commit a3cc347

Browse files
authored
Merge pull request #3721 from IntersectMBO/develop
3rd June version (voting, delegation, pdf, outcomes)
2 parents a8e9049 + 820e0f0 commit a3cc347

27 files changed

+293
-111
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ changes.
1717
### Fixed
1818

1919
- Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490)
20+
- Fix blank screen and type error on linkReferences when navigating to edit dRep page that has no links [Issue 3714](https://github.com/IntersectMBO/govtool/issues/3714)
21+
- Fix adding two link input fields when editing the dRep form when no links are present initially [Issue 3709](https://github.com/IntersectMBO/govtool/issues/3709)
2022

2123
### Changed
2224

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
@@ -29,7 +29,7 @@
2929
"@hookform/resolvers": "^3.3.1",
3030
"@intersect.mbo/govtool-outcomes-pillar-ui": "v1.4.3",
3131
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
32-
"@intersect.mbo/pdf-ui": "0.7.0-beta-33",
32+
"@intersect.mbo/pdf-ui": "0.7.0-beta-35",
3333
"@mui/icons-material": "^5.14.3",
3434
"@mui/material": "^5.14.4",
3535
"@rollup/plugin-babel": "^6.0.4",

govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepForm.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Box } from "@mui/material";
44

55
import { useCardano } from "@context";
66
import {
7+
defaultEditDRepInfoValues,
78
useEditDRepInfoForm,
89
useGetDRepDetailsQuery,
910
useTranslation,
@@ -44,15 +45,21 @@ export const EditDRepForm = ({
4445

4546
reset({
4647
...data,
47-
objectives: data?.objectives ?? "",
48-
motivations: data?.motivations ?? "",
49-
qualifications: data?.qualifications ?? "",
50-
paymentAddress: data?.paymentAddress ?? "",
51-
image: data?.image ?? "",
52-
linkReferences: data.linkReferences ?? [getEmptyReference("Link")],
53-
identityReferences: data.identityReferences ?? [
54-
getEmptyReference("Identity"),
55-
],
48+
objectives: data?.objectives ?? defaultEditDRepInfoValues.objectives,
49+
motivations: data?.motivations ?? defaultEditDRepInfoValues.motivations,
50+
qualifications:
51+
data?.qualifications ?? defaultEditDRepInfoValues.qualifications,
52+
paymentAddress:
53+
data?.paymentAddress ?? defaultEditDRepInfoValues.paymentAddress,
54+
image: data?.image ?? defaultEditDRepInfoValues.image,
55+
linkReferences:
56+
Array.isArray(data?.linkReferences) && data.linkReferences.length > 0
57+
? data.linkReferences
58+
: defaultEditDRepInfoValues.linkReferences,
59+
identityReferences:
60+
Array.isArray(data?.identityReferences) && data.identityReferences.length > 0
61+
? data.identityReferences
62+
: defaultEditDRepInfoValues.identityReferences,
5663
});
5764
}
5865
}, [yourselfDRep, loadUserData]);
@@ -74,9 +81,3 @@ export const EditDRepForm = ({
7481
</Box>
7582
);
7683
};
77-
78-
const getEmptyReference = (type: "Link" | "Identity") => ({
79-
"@type": type,
80-
uri: "",
81-
label: "",
82-
});

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { importWallet } from "@fixtures/importWallet";
22
import { valid as mockValid } from "@mock/index";
33
import LoginPage from "@pages/loginPage";
44
import ProposalDiscussionPage from "@pages/proposalDiscussionPage";
5-
import { BrowserContext, Page } from "@playwright/test";
5+
import { BrowserContext, expect, Page } from "@playwright/test";
66
import { ProposalType, StaticWallet } from "@types";
77
import { ShelleyWallet } from "./crypto";
88
import convertBufferToHex from "./convertBufferToHex";
@@ -57,9 +57,16 @@ export async function createAuthWithUserName({
5757

5858
const proposalDiscussionPage = new ProposalDiscussionPage(page);
5959
await proposalDiscussionPage.goto();
60-
await proposalDiscussionPage.verifyIdentityBtn.click({ timeout: 15_000 });
61-
62-
await proposalDiscussionPage.setUsername(mockValid.username());
60+
await proposalDiscussionPage.verifyIdentityBtn.click({ timeout: 60_000 });
61+
try {
62+
await expect(page.getByTestId("username-input")).toBeVisible({
63+
timeout: 10_000,
64+
});
65+
await proposalDiscussionPage.setUsername(mockValid.username());
66+
} catch (error) {
67+
// Ignore error if username is already set
68+
console.log("Username is already set");
69+
}
6370

6471
await context.storageState({ path: auth });
6572
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function skipIfNotInfoAndBootstrapping(type: ProposalType) {
5050
export async function skipIfMainnet() {
5151
if (environments.networkId === 1) {
5252
await allure.description(
53-
"Ada spendable features are not available on mainnet."
53+
"Test skipped on mainnet to prevent affecting the production environment or using real ADA."
5454
);
5555
test.skip();
5656
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import environments from "../constants/environments";
22
import { ed25519 as ed } from "@noble/curves/ed25519";
33
import { bech32 } from "bech32";
44
import * as blake from "blakejs";
5-
import { rewardAddressBech32, rewardAddressRawBytes } from "./shellyWallet";
5+
import {
6+
addressBech32,
7+
addressRawBytes,
8+
rewardAddressBech32,
9+
rewardAddressRawBytes,
10+
} from "./shellyWallet";
611

712
const KEY_HASH_LENGTH = 28;
813
const ADDR_LENGTH = KEY_HASH_LENGTH * 2 + 1;
@@ -103,20 +108,15 @@ export class ShelleyWallet {
103108
}
104109

105110
addressBech32(networkId: number): string {
106-
const prefix = networkId == 0 ? "addr_test" : "addr";
107-
return bech32.encode(
108-
prefix,
109-
bech32.toWords(Buffer.from(this.addressRawBytes(networkId))),
110-
200
111-
);
111+
const stakePkh = Buffer.from(this.stakeKey.pkh).toString("hex");
112+
const paymentPkh = Buffer.from(this.paymentKey.pkh).toString("hex");
113+
return addressBech32(networkId, paymentPkh, stakePkh);
112114
}
113115

114116
addressRawBytes(networkId) {
115-
const concatenatedArray1 = new Uint8Array(ADDR_LENGTH);
116-
concatenatedArray1[0] = networkId;
117-
concatenatedArray1.set(this.paymentKey.pkh, 1);
118-
concatenatedArray1.set(this.stakeKey.pkh, KEY_HASH_LENGTH + 1);
119-
return concatenatedArray1;
117+
const stakePkh = Buffer.from(this.stakeKey.pkh).toString("hex");
118+
const paymentPkh = Buffer.from(this.paymentKey.pkh).toString("hex");
119+
return addressRawBytes(networkId, paymentPkh, stakePkh);
120120
}
121121

122122
rewardAddressRawBytes(network: number) {

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { bech32 } from "bech32";
22
import { blake2bHex } from "blakejs";
33
import convertBufferToHex from "./convertBufferToHex";
44
import { ShelleyWallet } from "./crypto";
5+
56
const KEY_HASH_LENGTH = 28;
7+
const ADDR_LENGTH = KEY_HASH_LENGTH * 2 + 1;
68

79
export default function extractDRepFromWallet(wallet: ShelleyWallet) {
810
const dRepPubKey = convertBufferToHex(wallet.dRepKey.public);
@@ -36,6 +38,36 @@ export function rewardAddressBech32(
3638
);
3739
}
3840

41+
export function addressBech32(
42+
networkId: number,
43+
paymentPkh: string,
44+
stakePkh: string
45+
): string {
46+
const prefix = networkId == 0 ? "addr_test" : "addr";
47+
return bech32.encode(
48+
prefix,
49+
bech32.toWords(
50+
Buffer.from(addressRawBytes(networkId, paymentPkh, stakePkh))
51+
),
52+
200
53+
);
54+
}
55+
56+
export function addressRawBytes(
57+
networkId: number,
58+
paymentPkh: string,
59+
stakePkh: string
60+
) {
61+
const concatenatedArray1 = new Uint8Array(ADDR_LENGTH);
62+
concatenatedArray1[0] = networkId;
63+
concatenatedArray1.set(Uint8Array.from(Buffer.from(paymentPkh, "hex")), 1);
64+
concatenatedArray1.set(
65+
Uint8Array.from(Buffer.from(stakePkh, "hex")),
66+
KEY_HASH_LENGTH + 1
67+
);
68+
return concatenatedArray1;
69+
}
70+
3971
export async function generateWallets(num: number) {
4072
return await Promise.all(
4173
Array.from({ length: num }, () =>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export default class OutcomeDetailsPage {
106106
isLoggedIn
107107
);
108108

109+
if (!govActionDetailsPage) {
110+
return;
111+
}
112+
109113
const outcomeResponse = await outcomeResponsePromise;
110114
const proposalToCheck = (await outcomeResponse.json())[0];
111115

@@ -267,7 +271,7 @@ export default class OutcomeDetailsPage {
267271
{
268272
message: `CC "Abstain" vote count checked for ${currentPageUrl}`,
269273
}
270-
).toHaveText(`Abstain Votes${proposalToCheck.pool_abstain_votes}`); //BUG missing testIds
274+
).toHaveText(`Abstain Votes${proposalToCheck.cc_abstain_votes}`); //BUG missing testIds
271275

272276
const noPercentage = 100 - parseFloat(yesPercentage.replace("%", ""));
273277
await expect(govActionDetailsPage.ccCommitteeNoVotes, {

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

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ export default class OutComesPage {
177177
await this.page.getByTestId(this.getSortTestId(sortOption)).click();
178178

179179
const response = await responsePromise;
180-
const data = await response.json();
181-
let outcomeProposalList: outcomeProposal[] = data.length != 0 ? data : null;
180+
const outcomeProposalList: outcomeProposal[] = await response.json();
182181

183182
// API validation
184183
if (outcomeProposalList.length <= 1) return;
@@ -456,10 +455,15 @@ export default class OutComesPage {
456455

457456
async searchOutcomesById(governanceActionId: string) {
458457
await this.searchInput.fill(governanceActionId);
459-
await expect(
460-
this.page.getByRole("progressbar").getByRole("img")
461-
).toBeVisible();
462458

459+
try {
460+
await expect(
461+
this.page.getByRole("progressbar").getByRole("img")
462+
).toBeVisible();
463+
} catch (error) {
464+
// Handle the case where the progress bar is not visible
465+
console.warn("Progress bar not visible, proceeding with search.");
466+
}
463467
await functionWaitedAssert(
464468
async () => {
465469
const idSearchOutcomeCards = await this.getAllOutcomes();
@@ -480,9 +484,14 @@ export default class OutComesPage {
480484

481485
async searchOutcomesByTitle(governanceActionTitle: string) {
482486
await this.searchInput.fill(governanceActionTitle);
483-
await expect(
484-
this.page.getByRole("progressbar").getByRole("img")
485-
).toBeVisible();
487+
try {
488+
await expect(
489+
this.page.getByRole("progressbar").getByRole("img")
490+
).toBeVisible();
491+
} catch (error) {
492+
// Handle the case where the progress bar is not visible
493+
console.warn("Progress bar not visible, proceeding with search.");
494+
}
486495

487496
await functionWaitedAssert(
488497
async () => {
@@ -545,17 +554,26 @@ export default class OutComesPage {
545554
{ timeout: 60_000 }
546555
);
547556

548-
const metricsResponsePromise = page.waitForResponse(
549-
(response) => response.url().includes(`/misc/network/metrics?epoch`),
550-
{ timeout: 60_000 }
551-
);
552-
553557
const outcomePage = new OutComesPage(page);
554558
await outcomePage.goto({ filter: filterKey });
555559

556560
const outcomeListResponse = await outcomeListResponsePromise;
557561
const proposals = await outcomeListResponse.json();
558562

563+
if (proposals.length === 0) {
564+
expect(true, "No proposals found!").toBeTruthy();
565+
return {
566+
govActionDetailsPage: null,
567+
outcomeResponsePromise: null,
568+
metricsResponsePromise: null,
569+
};
570+
}
571+
572+
const metricsResponsePromise = page.waitForResponse(
573+
(response) => response.url().includes(`/misc/network/metrics?epoch`),
574+
{ timeout: 60_000 }
575+
);
576+
559577
expect(
560578
proposals.length,
561579
proposals.length == 0 && "No proposals found!"

0 commit comments

Comments
 (0)