Skip to content

Commit d6e9507

Browse files
authored
Merge pull request #4035 from JosephRana11/integration-test-fixes
Frontend-Test-Updates-Fixes
2 parents 9908426 + fd84704 commit d6e9507

File tree

9 files changed

+53
-67
lines changed

9 files changed

+53
-67
lines changed

govtool/frontend/src/components/molecules/DRepDataForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const DRepDataForm = ({ control, errors, register, watch }: Props) => {
107107
subtitle={t("forms.dRepData.imageHelpfulText")}
108108
/>
109109
<UncontrolledImageInput
110-
data-testid="image-input"
110+
dataTestId="image-input"
111111
control={control}
112112
name="image"
113113
rules={Rules.IMAGE_URL}

govtool/frontend/src/components/organisms/UncontrolledImageInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const UncontrolledImageInput = <T extends FieldValues>({
7474
/>
7575
{fieldState.error && (
7676
<FormErrorMessage
77-
dataTestId={`${dataTestId}-error`}
77+
dataTestId={`invalid-${dataTestId}-error`}
7878
errorMessage={fieldState.error.message}
7979
/>
8080
)}

tests/govtool-frontend/playwright/lib/forms/dRepForm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const formErrors = {
1313
],
1414
linkDescription: "max-80-characters-error",
1515
email: "invalid-email-address-error",
16-
image: "invalid-image-url-error",
16+
image: "invalid-image-input-error",
1717
links: {
1818
url: "link-reference-description-1-error",
1919
description: "link-reference-description-1-error",
@@ -304,7 +304,7 @@ export default class DRepForm {
304304
}).not.toEqual(dRepInfo.qualifications);
305305

306306
await expect(this.form.getByTestId(formErrors.image), {
307-
message: !isImageErrorVisible && `${dRepInfo.image} is a valid image`,
307+
message: !isImageErrorVisible && `Invalid image URL or properly formatted base64-encoded image`,
308308
}).toBeVisible({
309309
timeout: 60_000,
310310
});

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class OutcomeDetailsPage {
111111
}
112112

113113
const outcomeResponse = await outcomeResponsePromise;
114-
const proposalToCheck = (await outcomeResponse.json())[0];
114+
const proposalToCheck = (await outcomeResponse.json());
115115

116116
const metricsResponse = await metricsResponsePromise;
117117

@@ -188,7 +188,7 @@ export default class OutcomeDetailsPage {
188188
filterKey === "NoConfidence"
189189
? proposalToCheck.pool_no_votes
190190
: parseInt(sPosNoConfidence.replace(/,/g, "")) * 1000000 +
191-
parseInt(proposalToCheck.pool_no_votes);
191+
parseInt(proposalToCheck.pool_no_votes);
192192

193193
const totalSposYesVotesForNoConfidence =
194194
parseInt(sPosNoConfidence.replace(/,/g, "")) * 1000000 +
@@ -295,19 +295,24 @@ export default class OutcomeDetailsPage {
295295
url: string;
296296
hash: string;
297297
}) {
298-
await this.page.route(/.*\/governance-actions\/[a-f0-9]{64}\?.*/, (route) =>
299-
route.fulfill({ body: JSON.stringify([outcomeResponse]) })
298+
let governanceActionPromise = this.page.route("**/governance-actions/*", async (route) => {
299+
if (route.request().url().includes("/governance-actions/metadata")) {
300+
await route.continue();
301+
} else {
302+
await route.fulfill({ body: JSON.stringify(outcomeResponse)});
303+
}
304+
}
300305
);
301-
302306
const outcomePage = new OutComesPage(this.page);
303307
await outcomePage.goto();
304308
await outcomePage.viewFirstOutcomes();
309+
await governanceActionPromise;
305310
const outcomeTitle = await outcomePage.title.textContent();
306311

307312
await expect(
308313
outcomePage.title,
309314
outcomeTitle.toLowerCase() !== type.toLowerCase() &&
310-
`The URL "${url}" and hash "${hash}" do not match the expected properties for type "${type}".`
315+
`The URL "${url}" and hash "${hash}" do not match the expected properties for type "${type}".`
311316
).toHaveText(type, {
312317
ignoreCase: true,
313318
timeout: 60_000,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ export default class OutComesPage {
579579

580580
const metricsResponsePromise = page.waitForResponse(
581581
(response) => response.url().includes(`/misc/network/metrics?epoch`),
582-
{ timeout: 60_000 }
582+
{ timeout: 120_000 }
583583
);
584584

585585
expect(
@@ -597,7 +597,7 @@ export default class OutComesPage {
597597
.includes(
598598
`governance-actions/${governanceTransactionHash}?index=${governanceActionIndex}`
599599
),
600-
{ timeout: 60_000 }
600+
{ timeout: 120_000 }
601601
);
602602

603603
const govActionDetailsPage = await outcomePage.viewFirstOutcomes();

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

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ test.describe("Logged in DRep", () => {
6767
)
6868
: await govActionsPage.viewFirstProposal();
6969

70-
await govActionDetailsPage.contextBtn.click();
7170
await govActionDetailsPage.contextInput.fill(faker.lorem.sentence(200));
7271
await govActionDetailsPage.confirmModalBtn.click();
7372
await page.getByRole("checkbox").click();
@@ -101,55 +100,6 @@ test.describe("Logged in DRep", () => {
101100
});
102101
});
103102

104-
test.describe("Temporary DReps", async () => {
105-
let dRepPage: Page;
106-
107-
test.beforeEach(async ({ page, browser }) => {
108-
const wallet = await walletManager.popWallet("registeredDRep");
109-
const tempDRepAuth = await createTempDRepAuth(page, wallet);
110-
dRepPage = await createNewPageWithWallet(browser, {
111-
storageState: tempDRepAuth,
112-
wallet,
113-
enableDRepSigning: true,
114-
});
115-
});
116-
117-
const verifyVoteWithMetadata = async (testInfo: any, useGovToolIPFS: boolean = false) => {
118-
test.setTimeout(testInfo.timeout + environments.txTimeOut);
119-
120-
const govActionsPage = new GovernanceActionsPage(dRepPage);
121-
await govActionsPage.goto();
122-
123-
const govActionDetailsPage = await govActionsPage.viewFirstProposal();
124-
const fakerContext = faker.lorem.sentence(200);
125-
126-
if (useGovToolIPFS) {
127-
await govActionDetailsPage.vote(fakerContext, false, true);
128-
} else {
129-
await govActionDetailsPage.vote(fakerContext);
130-
}
131-
132-
await dRepPage.reload();
133-
await dRepPage.waitForTimeout(5_000);
134-
await govActionsPage.votedTab.click();
135-
136-
const votedGovActionDetailsPage = await govActionsPage.viewFirstVotedProposal();
137-
await votedGovActionDetailsPage.currentPage.getByTestId("show-more-button").click();
138-
await votedGovActionDetailsPage.currentPage.waitForTimeout(2000);
139-
140-
const voteRationaleContext = await votedGovActionDetailsPage.currentPage.getByTestId("vote-rationale-context");
141-
await expect(voteRationaleContext).toContainText(fakerContext);
142-
};
143-
144-
test("4J. Should include metadata anchor in the vote transaction (Download and store yourself)", async ({}, testInfo) => {
145-
await verifyVoteWithMetadata(testInfo, false);
146-
});
147-
148-
test("4k. Should include metadata anchor in the vote transaction (GovTool pins data to IPFS)", async ({}, testInfo) => {
149-
await verifyVoteWithMetadata(testInfo, true);
150-
});
151-
});
152-
153103
test.describe("Check vote count", () => {
154104
test.use({ storageState: dRep01AuthFile, wallet: dRep01Wallet });
155105

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ test("4M. Should show view-all categorized governance actions", async ({
189189
const governanceActionPage = new GovernanceActionsPage(page);
190190
await governanceActionPage.goto();
191191

192-
await page.getByRole("button", { name: "Show All" }).click();
192+
await page.getByRole("link", { name: "Show All" }).click();
193193

194194
const proposalCards = await governanceActionPage.getAllProposals();
195195

tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ test.describe("Proposal checks", () => {
138138

139139
test.describe("Perform voting", () => {
140140
let govActionDetailsPage: GovernanceActionDetailsPage;
141+
let dRepPage: Page;
142+
let govActionsPage: GovernanceActionsPage;
141143

142144
test.beforeEach(async ({ page, browser }) => {
143145
test.slow(); // Due to queue in pop wallets
@@ -146,14 +148,14 @@ test.describe("Perform voting", () => {
146148

147149
const tempDRepAuth = await createTempDRepAuth(page, wallet);
148150

149-
const dRepPage = await createNewPageWithWallet(browser, {
151+
dRepPage = await createNewPageWithWallet(browser, {
150152
storageState: tempDRepAuth,
151153
wallet,
152154
enableDRepSigning: true,
153155
});
154156

155-
const govActionsPage = new GovernanceActionsPage(dRepPage);
156-
await govActionsPage.goto();
157+
govActionsPage = new GovernanceActionsPage(dRepPage);
158+
govActionsPage.goto();
157159

158160
// assert to wait until the loading button is hidden
159161
await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({
@@ -282,6 +284,36 @@ test.describe("Perform voting", () => {
282284
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes")
283285
).toBeVisible();
284286
});
287+
288+
const verifyVoteWithMetadata = async (testInfo: any, useGovToolIPFS: boolean = false) => {
289+
test.setTimeout(testInfo.timeout + environments.txTimeOut);
290+
const fakerContext = faker.lorem.sentence(200);
291+
292+
if (useGovToolIPFS) {
293+
await govActionDetailsPage.vote(fakerContext, false, true);
294+
} else {
295+
await govActionDetailsPage.vote(fakerContext);
296+
}
297+
298+
await dRepPage.reload();
299+
await dRepPage.waitForTimeout(5_000);
300+
await govActionsPage.votedTab.click();
301+
302+
const votedGovActionDetailsPage = await govActionsPage.viewFirstVotedProposal();
303+
await votedGovActionDetailsPage.currentPage.getByTestId("show-more-button").click();
304+
await votedGovActionDetailsPage.currentPage.waitForTimeout(2000);
305+
306+
const voteRationaleContext = await votedGovActionDetailsPage.currentPage.getByTestId("vote-rationale-context");
307+
await expect(voteRationaleContext).toContainText(fakerContext);
308+
};
309+
310+
test("5M_1. Should vote with Context (Download and store yourself)", async ({}, testInfo) => {
311+
await verifyVoteWithMetadata(testInfo, false);
312+
});
313+
314+
test("5M_2. Should vote with Context (GovTool pins data to IPFS)", async ({}, testInfo) => {
315+
await verifyVoteWithMetadata(testInfo, true );
316+
});
285317
});
286318

287319
test.describe("Check voting power", () => {

tests/govtool-frontend/playwright/tests/dRep.setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import kuberService from "@services/kuberService";
1212
import walletManager from "lib/walletManager";
1313
import { functionWaitedAssert } from "@helpers/waitedLoop";
1414
import { StaticWallet } from "@types";
15-
import { Logger } from "@helpers/logger";
1615

1716
const REGISTER_DREP_WALLETS_COUNT = 6;
1817
const DREP_WALLETS_COUNT = 11;

0 commit comments

Comments
 (0)