Skip to content

Commit

Permalink
chore: add validation for 128-word limit on metadata anchor field only
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerose committed Oct 28, 2024
1 parent d83227f commit 0d497da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tests/govtool-frontend/playwright/lib/_mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { faker } from "@faker-js/faker";
import { generateExactLengthText } from "@helpers/string";

export const invalid = {
url: () => {
const choice = faker.number.int({ min: 1, max: 2 });
url: (isSupportedGreaterThan128Words = true) => {
const choice = isSupportedGreaterThan128Words
? 1
: faker.number.int({ min: 1, max: 2 });
if (choice === 1) {
const invalidSchemes = ["ftp", "unsupported", "unknown-scheme"];
const invalidCharacters = "<>@!#$%^&*()";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ test.describe("Validation of dRep Registration Form", () => {
await dRepRegistrationPage.registerBtn.click();

for (let i = 0; i < 100; i++) {
const invalidUrl = mockInvalid.url();
const invalidUrl = mockInvalid.url(false);

await dRepRegistrationPage.metadataUrlInput.fill(invalidUrl);
if (invalidUrl.length <= 128) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ test.describe("Validation of edit dRep Form", () => {
await editDRepPage.registerBtn.click();

for (let i = 0; i < 100; i++) {
const invalidUrl = mockInvalid.url();
const invalidUrl = mockInvalid.url(false);
await editDRepPage.metadataUrlInput.fill(invalidUrl);
if (invalidUrl.length <= 128) {
await expect(page.getByTestId("invalid-url-error")).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,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(invalid.url());
await proposalSubmissionPage.metadataUrlInput.fill(invalid.url(false));
await expect(page.getByTestId("url-input-error-text")).toBeVisible();
}

Expand Down

0 comments on commit 0d497da

Please sign in to comment.