Skip to content

Commit 31a3821

Browse files
authored
Merge pull request #2834 from IntersectMBO/fix/report-275-failing-test
Fix : Report 275 failing test
2 parents 8127b6b + 3393376 commit 31a3821

File tree

15 files changed

+89
-44
lines changed

15 files changed

+89
-44
lines changed

tests/govtool-frontend/playwright/generate_wallets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ function saveWallets(wallets: ShelleyWallet[]): void {
1515
const jsonWallets = [];
1616
for (let i = 0; i < wallets.length; i++) {
1717
const dRepId = extractDRepFromWallet(wallets[i]);
18+
const networkId = process.env.NETWORK === "mainnet" ? 1 : 0;
1819

1920
jsonWallets.push({
2021
...wallets[i].json(),
21-
address: wallets[i].addressBech32(0), // testnet
22+
address: wallets[i].addressBech32(networkId),
2223
dRepId,
2324
});
2425
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
22
import { Page } from "@playwright/test";
3+
import { IDRep } from "@types";
34
import { bech32 } from "bech32";
5+
import * as crypto from "crypto";
46

57
export async function fetchFirstActiveDRepDetails(page: Page) {
68
let dRepGivenName: string;
@@ -12,7 +14,7 @@ export async function fetchFirstActiveDRepDetails(page: Page) {
1214
const response = await route.fetch();
1315
const json = await response.json();
1416
const elements = json["elements"].filter(
15-
(element) => element["givenName"] != null
17+
(element: IDRep) => element.givenName != null && !element.isScriptBased
1618
);
1719
dRepGivenName =
1820
elements[Math.floor(Math.random() * elements.length)]["givenName"];

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as fs from "fs";
88
import { ShelleyWallet } from "./crypto";
99
import { calculateImageSHA256 } from "./dRep";
1010
import { imageObject } from "@types";
11+
import environments from "@constants/environments";
1112

1213
export async function downloadMetadata(download: Download): Promise<{
1314
name: string;
@@ -22,7 +23,9 @@ export async function downloadMetadata(download: Download): Promise<{
2223

2324
async function calculateMetadataHash() {
2425
try {
25-
const paymentAddress = (await ShelleyWallet.generate()).addressBech32(0);
26+
const paymentAddress = (await ShelleyWallet.generate()).addressBech32(
27+
environments.networkId
28+
);
2629
const imageUrl = faker.image.avatarGitHub();
2730
const imageSHA256 = (await calculateImageSHA256(imageUrl)) || "";
2831
const imageObject: imageObject = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default class GovernanceActionsPage {
159159

160160
await expect(
161161
this.page.getByRole("progressbar").getByRole("img")
162-
).toBeHidden({ timeout: 10_000 });
162+
).toBeHidden({ timeout: 20_000 });
163163

164164
// Frontend validation
165165
for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ export default class ProposalSubmissionPage {
348348
proposalType: ProposalType = ProposalType.treasury
349349
): Promise<number> {
350350
await this.addLinkBtn.click();
351-
const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0);
351+
const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(
352+
environments.networkId
353+
);
352354

353355
const proposalRequest: ProposalCreateRequest =
354356
this.generateValidProposalFormFields(
@@ -374,7 +376,9 @@ export default class ProposalSubmissionPage {
374376
const proposalFormValue = this.generateValidProposalFormFields(
375377
proposalType,
376378
true,
377-
ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32(0)
379+
ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32(
380+
environments.networkId
381+
)
378382
);
379383
await this.fillupForm(proposalFormValue);
380384

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export type IDRep = {
110110
status: DRepStatus;
111111
type: string;
112112
latestTxHash: string;
113+
givenName: string | null;
113114
latestRegistrationDate: string;
114115
};
115116

tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ test("2N. Should show DRep information on details page", async ({
3939
const objectives = faker.lorem.paragraph(2);
4040
const motivations = faker.lorem.paragraph(2);
4141
const qualifications = faker.lorem.paragraph(2);
42-
const paymentAddress = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0);
42+
const paymentAddress = ShelleyWallet.fromJson(wallet).addressBech32(
43+
environments.networkId
44+
);
4345
const linksReferenceLinks: LinkType[] = [
4446
{
4547
url: faker.internet.url(),

tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ test.describe("Change delegation", () => {
102102
page
103103
.getByTestId(`${dRepIdFirst}-delegated-card`)
104104
.getByTestId(`${dRepIdFirst}-copy-id-button`)
105-
).toHaveText(dRepIdFirst, { timeout: 20_000 });
105+
).toHaveText(`(CIP-105) ${dRepIdFirst}`, { timeout: 20_000 });
106106

107107
// verify delegation
108108
await dRepDirectoryPage.delegateToDRep(dRepIdSecond);
@@ -113,7 +113,7 @@ test.describe("Change delegation", () => {
113113
page
114114
.getByTestId(`${dRepIdSecond}-delegated-card`)
115115
.getByTestId(`${dRepIdSecond}-copy-id-button`)
116-
).toHaveText(dRepIdSecond, { timeout: 20_000 });
116+
).toHaveText(`(CIP-105) ${dRepIdSecond}`, { timeout: 20_000 });
117117
});
118118
});
119119

@@ -149,7 +149,9 @@ test.describe("Register DRep state", () => {
149149
await waitForTxConfirmation(dRepPage);
150150

151151
// Checks in dashboard
152-
await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible();
152+
await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({
153+
timeout: 20_000,
154+
});
153155
await expect(
154156
dRepPage.getByTestId("register-as-sole-voter-button")
155157
).not.toBeVisible();
@@ -168,7 +170,9 @@ test.describe("Register DRep state", () => {
168170
).toBeVisible({ timeout: 15_000 });
169171
await dRepPage.getByTestId("confirm-modal-button").click();
170172
await waitForTxConfirmation(dRepPage);
171-
await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible();
173+
await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({
174+
timeout: 20_000,
175+
});
172176

173177
const dRepDirectoryPage = new DRepDirectoryPage(dRepPage);
174178
await dRepDirectoryPage.goto();
@@ -260,9 +264,9 @@ test.describe("Abstain delegation", () => {
260264

261265
const balance = await kuberService.getBalance(adaHolder03Wallet.address);
262266

263-
await expect(
264-
page.getByText(`You have delegated ₳${balance}`)
265-
).toBeVisible();
267+
await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({
268+
timeout: 20_000,
269+
});
266270
});
267271
});
268272

@@ -287,9 +291,9 @@ test.describe("No confidence delegation", () => {
287291
await waitForTxConfirmation(page);
288292

289293
const balance = await kuberService.getBalance(adaHolder04Wallet.address);
290-
await expect(
291-
page.getByText(`You have delegated ₳${balance}`)
292-
).toBeVisible();
294+
await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({
295+
timeout: 20_000,
296+
});
293297
});
294298
});
295299

@@ -314,13 +318,13 @@ test.describe("Delegated ADA visibility", () => {
314318
);
315319
await expect(
316320
page.getByText(`You have delegated ₳ ${adaHolderVotingPower}`)
317-
).toBeVisible();
321+
).toBeVisible({ timeout: 20_000 });
318322

319323
await page.goto("/");
320324
await expect(
321325
page.getByText(
322326
`Your Voting Power of ₳${adaHolderVotingPower} is Delegated to`
323327
)
324-
).toBeVisible();
328+
).toBeVisible({ timeout: 20_000 });
325329
});
326330
});

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ test.describe("Logged in DReps", () => {
2929
}) => {
3030
await page.goto("/");
3131

32-
await expect(page.getByTestId("voting-power-chips")).toBeVisible();
32+
await expect(page.getByTestId("voting-power-chips")).toBeVisible({
33+
timeout: 20_000,
34+
});
3335

3436
await expect(
3537
page.getByTestId("dRep-id-display-card-dashboard")
36-
).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 });
38+
).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 });
3739

3840
const governanceActionsPage = new GovernanceActionsPage(page);
3941

@@ -57,7 +59,7 @@ test.describe("Logged in DReps", () => {
5759
// Add an assertion to prevent clicking on "View Your dRep Details".
5860
await expect(
5961
page.getByTestId("dRep-id-display-card-dashboard")
60-
).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 });
62+
).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 });
6163

6264
await page.getByTestId("view-drep-details-button").click();
6365
await page.getByTestId("edit-drep-data-button").click();
@@ -70,7 +72,9 @@ test.describe("Logged in DReps", () => {
7072
objectives: faker.lorem.paragraph(2),
7173
motivations: faker.lorem.paragraph(2),
7274
qualifications: faker.lorem.paragraph(2),
73-
paymentAddress: (await ShelleyWallet.generate()).addressBech32(0),
75+
paymentAddress: (await ShelleyWallet.generate()).addressBech32(
76+
environments.networkId
77+
),
7478
linksReferenceLinks: [
7579
{
7680
url: faker.internet.url(),
@@ -199,7 +203,9 @@ test.describe("Temporary DReps", () => {
199203

200204
await waitForTxConfirmation(dRepPage);
201205

202-
await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible();
206+
await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible({
207+
timeout: 20_000,
208+
});
203209

204210
await expect(dRepPage.getByTestId("dRep-id-display")).not.toBeVisible();
205211

@@ -227,7 +233,9 @@ test.describe("Temporary DReps", () => {
227233

228234
const dRepRegistrationPage = new DRepRegistrationPage(dRepPage);
229235
await dRepRegistrationPage.goto();
230-
await dRepRegistrationPage.register({ name: faker.person.firstName() });
236+
await dRepRegistrationPage.registerWithoutTxConfirmation({
237+
name: faker.person.firstName(),
238+
});
231239
await dRepRegistrationPage.registrationSuccessModal
232240
.getByTestId("confirm-modal-button")
233241
.click();
@@ -236,5 +244,11 @@ test.describe("Temporary DReps", () => {
236244
/in progress/i,
237245
{ timeout: 20_000 }
238246
);
247+
248+
await waitForTxConfirmation(dRepPage);
249+
250+
await expect(dRepPage.getByTestId("d-rep-in-progress")).not.toBeVisible({
251+
timeout: 20_000,
252+
});
239253
});
240254
});

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index";
77
import { skipIfNotHardFork } from "@helpers/cardano";
88
import DRepRegistrationPage from "@pages/dRepRegistrationPage";
99
import { expect } from "@playwright/test";
10+
import environments from "@constants/environments";
1011

1112
test.use({
1213
storageState: ".auth/user01.json",
@@ -64,7 +65,9 @@ test.describe("Validation of dRep Registration Form", () => {
6465
objectives: faker.lorem.paragraph(2),
6566
motivations: faker.lorem.paragraph(2),
6667
qualifications: faker.lorem.paragraph(2),
67-
paymentAddress: (await ShelleyWallet.generate()).addressBech32(0),
68+
paymentAddress: (await ShelleyWallet.generate()).addressBech32(
69+
environments.networkId
70+
),
6871
linksReferenceLinks: [
6972
{
7073
url: faker.internet.url(),

0 commit comments

Comments
 (0)