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

ENG-3401: Remove all donationType integration and tests #429

Merged
merged 2 commits into from
Jun 25, 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
21 changes: 0 additions & 21 deletions playwright-local/tests/update/formValidation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ test.describe('Giftaid update form validation', () => {
// giftaid declaration error message
await expect(page.locator('div#field-error--giftAidClaimChoice > span')).toContainText('This field is required');

// DonationType error message
await expect(page.locator('#field-error--donationType')).toContainText('This field is required');

await page.close();
});

Expand Down Expand Up @@ -67,9 +64,6 @@ test.describe('Giftaid update form validation', () => {
// entering valid input fields should be able to submit the form
await commands.populateUpdateFormFields(page);

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// select giftaid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

Expand Down Expand Up @@ -110,9 +104,6 @@ test.describe('Giftaid update form validation', () => {

// entering valid input fields should be able to submit the form
await commands.populateUpdateFormFields(page);

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// select giftaid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();
Expand Down Expand Up @@ -162,9 +153,6 @@ test.describe('Giftaid update form validation', () => {
// entering valid input fields should be able to submit the form
await commands.populateUpdateFormFields(page);

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// select giftaid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

Expand Down Expand Up @@ -209,9 +197,6 @@ test.describe('Giftaid update form validation', () => {
// Select yes for giftaid declaration to complete the form
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

await page.locator('button[type=submit]').click();
await expect(page.locator('div > h1')).toHaveText('Thank you, test!');
});
Expand Down Expand Up @@ -292,9 +277,6 @@ test.describe('Giftaid update form validation', () => {
const town = await page.evaluate(() => document.querySelector('input#field-input--town').getAttribute('value'));
console.log('Address line 1 field value is : ', town);

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// select giftaid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

Expand All @@ -312,9 +294,6 @@ test.describe('Giftaid update form validation', () => {
await page.locator('#field-input--address3').type('ALBERT EMBANKMENT');
await page.locator('#field-input--town').type('LONDON');

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// select giftaid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ test.describe('International addresses validation on update form', () => {

// Select yes for giftaid declaration to complete the form
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// Submitting the form with valid international details
await page.locator('button[type=submit]').click();
Expand Down
3 changes: 0 additions & 3 deletions playwright-local/tests/update/validFormSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ test('Valid Giftaid Update submission', async ({ page }) => {
// Select 'Yes' for GiftAid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// Submit the form and validate the thank you message
await page.locator('button[type=submit]').click();
await expect(page.locator('div > h1')).toContainText('Thank you,\n' +
Expand Down
3 changes: 2 additions & 1 deletion playwright-staging/tests/submit/successRedirect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const { test } = require('../../browserstack');

test('Accessing success page should redirect to giftaid homepage @sanity @nightly-sanity', async ({ page }) => {
// Navigate directly to the success page and expect a redirect
await page.goto(`${process.env.BASE_URL}success`, { waitUntil: 'networkidle' });
await page.goto(`${process.env.BASE_URL}success`, { timeout: 30000 });
await page.waitForLoadState('domcontentloaded');

// Check if the expected header title is present, which indicates a successful redirect
const headerTitle = page.locator('h1.giftaid-title');
Expand Down
3 changes: 2 additions & 1 deletion playwright-staging/tests/submit/validFormSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ test('Valid giftaid submission @sanity @nightly-sanity', async ({ page }) => {
const commands = new Commands(page);

// Navigate to the giftaid page
await page.goto(`${process.env.BASE_URL}`, { waitUntil: 'networkidle' });
await page.goto(process.env.BASE_URL, { timeout: 30000 });
await page.waitForLoadState('domcontentloaded');

// Click the Giftaid checkbox
await page.click('#field-label--giftaid');
Expand Down
8 changes: 0 additions & 8 deletions playwright-staging/tests/update/formValidation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ test.describe('Giftaid Update form validation @sanity @nightly-sanity', () => {
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');
Expand Down Expand Up @@ -51,11 +50,8 @@ test.describe('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
await page.locator('#donationType>div:nth-child(3)>label').click();
await page.click('button[type=submit]'); // Submit the form

await expect(page.locator('div > h1')).toHaveText('Thank you, John!');
Expand Down Expand Up @@ -89,7 +85,6 @@ test.describe('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
Expand Down Expand Up @@ -124,7 +119,6 @@ test.describe('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: mobile });
await page.click('#giftAidClaimChoice>div:nth-child(2)>label'); // Select yes for declaration
await page.click('button[type=submit]'); // Submit the form
Expand Down Expand Up @@ -174,8 +168,6 @@ test.describe('Giftaid Update form validation @sanity @nightly-sanity', () => {
await page.locator('input#field-input--email').fill(`giftaid-update-staging-${chance.email()}`);
await page.fill('input#field-input--postcode', 'SE1 7TP');
await page.click('#giftAidClaimChoice>div:nth-child(2)>label'); // Select yes for declaration
// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();
await page.click('button[type=submit]'); // Submit the form

await expect(page.locator('div > h1')).toHaveText('Thank you, test!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ test('Validate Giftaid declaration claim selections @sanity @nightly-sanity', as
expect(await page.locator('#giftAidClaimChoice>div:nth-child(3)>input').isChecked()).toBeTruthy();
expect(await page.locator('#giftAidClaimChoice>div:nth-child(2)>input').isChecked()).toBeFalsy();

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();
expect(await page.locator('#donationType>div:nth-child(3)>input').isChecked()).toBeTruthy();
expect(await page.locator('#donationType>div:nth-child(2)>input').isChecked()).toBeFalsy();

await page.locator('button[type=submit]').click();
await expect(page.locator('div > h1')).toHaveText('Thanks for letting us know');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test.describe('International addresses validation on update form @sanity @nightl

await page.goto(process.env.BASE_URL + 'update', { timeout: 30000 });
await page.waitForLoadState('domcontentloaded');
await page.locator('.form__radio input[type="radio"][value="call centre"]').click();

// fill in all input fields
// await page.locator('input#field-input--transactionId').fill(transactionId);
Expand Down
3 changes: 0 additions & 3 deletions playwright-staging/tests/update/validFormSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ test('Valid giftaid update submission @sanity @nightly-sanity', async ({ page })
// Select 'Yes' for GiftAid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

// Select 'Online' donation type
await page.locator('#donationType>div:nth-child(3)>label').click();

// Submit the form and validate the thank you message
await page.locator('button[type=submit]').click();
await expect(page.locator('div > h1')).toContainText('Thank you, test!');
Expand Down
35 changes: 0 additions & 35 deletions src/components/Buttons/DonationTypeButtons/DonationTypeButtons.js

This file was deleted.

8 changes: 1 addition & 7 deletions src/pages/GiftAid/UpdateForm/UpdateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import PostcodeLookup from "@comicrelief/storybook/src/components/PostcodeLookup
import Form from '../../../components/Form/index';
import FormHeader from '../../../components/FormHeader/FormHeader';
import FormButton from '../../../components/Buttons/FormButton/index';
import DonationTypeButtons from '../../../components/Buttons/DonationTypeButtons/DonationTypeButtons';
import GiftAidClaimChoiceButtons from '../../../components/Buttons/GiftAidClaimChoiceButtons/GiftAidClaimChoiceButtons';
import InputFields from '../../../components/InputFields/InputFields';
import JustInTime from '../../../components/JustInTime/index';

// fields data
import { updateFormFields, donationTypeChoices, giftAidButtonChoices } from './UpdateFormFields';
import { updateFormFields, giftAidButtonChoices } from './UpdateFormFields';

// import context
import FormContext from '../../../context/FormContext';
Expand Down Expand Up @@ -40,9 +39,6 @@ function UpdateForm(props) {
useEffect(() => {
setFieldValidation(fieldValidation);
// Reset states on component unmount

// ADDING THIS EVERYWHERE TO /UPDATE NOW SO DON'T DELETE IT
// delete fieldValidation.donationType;
return () => {
setInputFieldProps([]);
}
Expand All @@ -56,8 +52,6 @@ function UpdateForm(props) {

<div className="form-fields--wrapper">

<DonationTypeButtons donationTypeChoices={donationTypeChoices} />

<h3 className="form--update__title form--update__title--giftaid text-align-centre">
Who is changing their declaration?
</h3>
Expand Down
20 changes: 0 additions & 20 deletions src/pages/GiftAid/UpdateForm/UpdateFormFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ switch(site.getSite()) {
break;
};

/*
* Donation Types
*
*/
export const DONATION_TYPES = {
SMS: 'sms',
ONLINE: 'online',
CALL_CENTRE: 'call centre',
};

/*
* Donation Type Radio Button Choices
*
*/
export const donationTypeChoices = [
{ label: 'SMS', value: DONATION_TYPES.SMS },
{ label: 'Online', value: DONATION_TYPES.ONLINE },
{ label: 'Call centre', value: DONATION_TYPES.CALL_CENTRE },
];

/*
* Default GiftAid Button
* Choices
Expand Down
21 changes: 0 additions & 21 deletions src/pages/GiftAid/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ export const getFormValues = (validation, update = false) => {
return fieldValues[key] = value;
});

// Create donation type field for Update Form
fieldValues.donationType = typeof validation.donationType !== 'undefined'
&& validation.donationType
? validation.donationType.value : DONATION_TYPES.ONLINE;

// Create name based on Form type
const name = update ? 'GiftAidUpdate' : 'GiftAid';

Expand All @@ -109,17 +104,6 @@ export const getFormValues = (validation, update = false) => {
}, fieldValues);
};


/*
* Donation Types
*
*/
const DONATION_TYPES = {
SMS: 'sms',
ONLINE: 'online',
CALL_CENTRE: 'call centre',
};

/*
* Common form variables
*
Expand Down Expand Up @@ -359,11 +343,6 @@ export const defaultUpdateFormFieldValidations = {
value: undefined,
message: '',
},
donationType: {
valid: false,
value: undefined,
message: '',
},
mobile: {
valid: true,
value: undefined,
Expand Down
5 changes: 0 additions & 5 deletions src/styles/UpdateForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ button[type="submit"].btn.btn--red {
}
}

#donationType {
// Keep the label for accessibility, just hidden as per design
.form__fieldset--label { @include visuallyhidden; }
}

.form--update__title--donation {
margin-bottom: 0;
}
Expand Down
Loading