-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a5f881
commit 09c8474
Showing
1 changed file
with
5 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,22 @@ const { v4: uuidv4 } = require('uuid'); | |
const Chance = require('chance'); | ||
const chance = new Chance(); | ||
|
||
test.describe.only('Giftaid Update form validation @sanity @nightly-sanity', () => { | ||
test.describe('Giftaid Update form validation @sanity @nightly-sanity', () => { | ||
let commands; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
commands = new Commands(page); | ||
// Navigate to the Giftaid Update form | ||
await page.goto(`${process.env.BASE_URL}update`, { timeout: 30000 }); | ||
await page.waitForLoadState('domcontentloaded'); | ||
await page.locator('.form__radio input[type="radio"][value="online"]').click(); | ||
}); | ||
|
||
test('empty input fields should show error messages', async ({ page }) => { | ||
// Submit the form without filling out any fields | ||
await page.click('button[type=submit]'); | ||
|
||
// Check for the error messages associated with each field | ||
await expect(page.locator('div#field-error--donationType > span')).toHaveText('This field is required'); | ||
await expect(page.locator('div#field-error--firstname > span')).toHaveText('Please fill in your first name'); | ||
await expect(page.locator('div#field-error--lastname > span')).toHaveText('Please fill in your last name'); | ||
await expect(page.locator('div#field-error--email > span')).toHaveText('Please fill in your email address'); | ||
|
@@ -51,6 +51,7 @@ test.describe.only('Giftaid Update form validation @sanity @nightly-sanity', () | |
|
||
// Test for a valid first name | ||
await page.fill('#field-input--firstname', ''); // clear firstname field | ||
await page.locator('.form__radio input[type="radio"][value="online"]').click(); | ||
await commands.populateUpdateFormFields(page, { firstName: 'John' }); | ||
await page.click('#giftAidClaimChoice>div:nth-child(2)>label'); // Select yes for declaration | ||
// Select 'Online' donation type | ||
|
@@ -88,6 +89,7 @@ test.describe.only('Giftaid Update form validation @sanity @nightly-sanity', () | |
// Test for a valid email | ||
const validEmail = '[email protected]'; | ||
await page.fill('input#field-input--email', ''); // clear email field | ||
await page.locator('.form__radio input[type="radio"][value="sms"]').click(); | ||
await commands.populateUpdateFormFields(page, { email: validEmail }); | ||
await page.click('#giftAidClaimChoice>div:nth-child(3)>label'); // Select no for declaration | ||
await page.click('button[type=submit]'); // Submit the form | ||
|
@@ -115,6 +117,7 @@ test.describe.only('Giftaid Update form validation @sanity @nightly-sanity', () | |
|
||
// Validate correct mobile number | ||
await page.locator('#field-input--mobile').fill(''); // Ensure the field is cleared and filled with valid data | ||
await page.locator('.form__radio input[type="radio"][value="call centre"]').click(); | ||
await commands.populateUpdateFormFields(page, { mobile: '07123456789' }); | ||
await page.click('#giftAidClaimChoice>div:nth-child(2)>label'); // Select yes for declaration | ||
await page.click('button[type=submit]'); // Submit the form | ||
|