Skip to content

Commit

Permalink
chore: add 128 words validation on invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerose committed Oct 28, 2024
1 parent 6509cd8 commit 68320f9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tests/govtool-frontend/playwright/lib/_mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import { generateExactLengthText } from "@helpers/string";

export const invalid = {
url: () => {
const invalidSchemes = ["ftp", "unsupported", "unknown-scheme"];
const invalidCharacters = "<>@!#$%^&*()";
const invalidTlds = [".invalid", ".example", ".test"];

const scheme =
invalidSchemes[Math.floor(Math.random() * invalidSchemes.length)];
const invalidChar =
invalidCharacters[Math.floor(Math.random() * invalidCharacters.length)];
const invalidTld =
invalidTlds[Math.floor(Math.random() * invalidTlds.length)];

const randomDomain = `example${invalidChar}domain${invalidTld}`;
return `${scheme}://${randomDomain}`;
const choice = faker.number.int({ min: 1, max: 2 });
if (choice === 1) {
const invalidSchemes = ["ftp", "unsupported", "unknown-scheme"];
const invalidCharacters = "<>@!#$%^&*()";
const invalidTlds = [".invalid", ".example", ".test"];

const scheme =
invalidSchemes[Math.floor(Math.random() * invalidSchemes.length)];
const invalidChar =
invalidCharacters[Math.floor(Math.random() * invalidCharacters.length)];
const invalidTld =
invalidTlds[Math.floor(Math.random() * invalidTlds.length)];

const randomDomain = `example${invalidChar}domain${invalidTld}`;
return `${scheme}://${randomDomain}`;
}
// max 128 words invalid
return faker.internet.url() + faker.lorem.paragraphs(2).replace(/\s+/g, "");
},

name: () => {
Expand Down

0 comments on commit 68320f9

Please sign in to comment.