From e3812a3a4749608e55659b1da7c74d2306e18658 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 6 Nov 2024 15:56:15 +0545 Subject: [PATCH 1/2] chore: move space validation from invalid to valid name check --- tests/govtool-frontend/playwright/lib/_mock/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/_mock/index.ts b/tests/govtool-frontend/playwright/lib/_mock/index.ts index 234f772d1..23c200604 100644 --- a/tests/govtool-frontend/playwright/lib/_mock/index.ts +++ b/tests/govtool-frontend/playwright/lib/_mock/index.ts @@ -26,11 +26,8 @@ export const invalid = { }, name: () => { - const choice = faker.number.int({ min: 1, max: 3 }); + const choice = faker.number.int({ min: 1, max: 2 }); if (choice === 1) { - // space invalid - return faker.lorem.word() + " " + faker.lorem.word(); - } else if (choice === 2) { // maximum 80 words invalid return faker.lorem.paragraphs().replace(/\s+/g, ""); } @@ -97,6 +94,13 @@ export const invalid = { }; export const valid = { + name: () => { + const choice = faker.number.int({ min: 1, max: 2 }); + if (choice === 1) { + return faker.internet.displayName(); + } + return faker.lorem.word() + " " + faker.lorem.word(); + }, username: () => { let timeStamp = Date.now(); let username = `${faker.internet.userName().toLowerCase()}_${timeStamp}`; From 2631b127718ec428721709babfc0941c50674d39 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 6 Nov 2024 15:57:30 +0545 Subject: [PATCH 2/2] chore: update dRep name validation with mockValid name --- .../tests/3-drep-registration/dRepRegistration.loggedin.spec.ts | 2 +- .../playwright/tests/3-drep-registration/editDRep.dRep.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts index 21afc8703..729b87568 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts @@ -60,7 +60,7 @@ test.describe("Validation of dRep Registration Form", () => { for (let i = 0; i < 100; i++) { await dRepRegistrationPage.validateForm({ - name: faker.internet.displayName(), + name: mockValid.name(), objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts index 95a90f0e9..656dc4714 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts @@ -27,7 +27,7 @@ test.describe("Validation of edit dRep Form", () => { for (let i = 0; i < 100; i++) { await editDRepPage.validateForm({ - name: faker.internet.displayName(), + name: mockValid.name(), objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2),