Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/metadata anchor ipfs validation #1909

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ export const valid = {

return username;
},

url: () => {
const choice = faker.number.int({ min: 1, max: 2 });
// Generate a random CID using a UUID
const prefix = "Qm";
const randomBase58 = faker.string.alphanumeric(44); // 44 characters to follow the Qm prefix
const randomCID = prefix + randomBase58;

if (choice === 1) {
return faker.internet.url();
}
return `ipfs://${randomCID}`;
},

metadata: (paymentAddress: string) => ({
"@context": {
CIP100:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { faker } from "@faker-js/faker";
import { test } from "@fixtures/walletExtension";
import { setAllureEpic } from "@helpers/allure";
import { ShelleyWallet } from "@helpers/crypto";
import { invalid as mockInvalid } from "@mock/index";
import { invalid as mockInvalid, valid as mockValid } from "@mock/index";
import DRepRegistrationPage from "@pages/dRepRegistrationPage";
import { expect } from "@playwright/test";

Expand Down Expand Up @@ -94,7 +94,7 @@ test.describe("Validation of dRep Registration Form", () => {
await dRepRegistrationPage.registerBtn.click();

for (let i = 0; i < 100; i++) {
await dRepRegistrationPage.metadataUrlInput.fill(faker.internet.url());
await dRepRegistrationPage.metadataUrlInput.fill(mockValid.url());
await expect(page.getByTestId("invalid-url-error")).toBeHidden();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { faker } from "@faker-js/faker";
import { test } from "@fixtures/walletExtension";
import { setAllureEpic } from "@helpers/allure";
import { ShelleyWallet } from "@helpers/crypto";
import { invalid as mockInvalid } from "@mock/index";
import { invalid as mockInvalid, valid as mockValid } from "@mock/index";
import EditDRepPage from "@pages/editDRepPage";
import { expect } from "@playwright/test";

Expand Down Expand Up @@ -78,7 +78,7 @@ test.describe("Validation of edit dRep Form", () => {
await editDRepPage.registerBtn.click();

for (let i = 0; i < 100; i++) {
await editDRepPage.metadataUrlInput.fill(faker.internet.url());
await editDRepPage.metadataUrlInput.fill(mockValid.url());
await expect(page.getByTestId("invalid-url-error")).toBeHidden();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { test } from "@fixtures/proposal";
import { setAllureEpic } from "@helpers/allure";
import { ShelleyWallet } from "@helpers/crypto";
import { createNewPageWithWallet } from "@helpers/page";
import { invalid } from "@mock/index";
import { invalid, valid as mockValid } from "@mock/index";
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
import ProposalSubmissionPage from "@pages/proposalSubmissionPage";
import { expect } from "@playwright/test";
Expand Down Expand Up @@ -239,9 +239,7 @@ test.describe("Proposal created logged state", () => {
}) => {
test.slow(); // Brute-force testing with 100 random data
for (let i = 0; i < 50; i++) {
await proposalSubmissionPage.metadataUrlInput.fill(
faker.internet.url()
);
await proposalSubmissionPage.metadataUrlInput.fill(mockValid.url());
await expect(page.getByTestId("url-input-error-text")).toBeHidden();
}
});
Expand Down
Loading