Skip to content

Commit

Permalink
ENG-2236: MP update (#375)
Browse files Browse the repository at this point in the history
* SB update, style fix needed for new updates

* Update tests

* Update field config

* test: update nightwatch tests with new MP changes

---------

Co-authored-by: Krupa Pammi <[email protected]>
  • Loading branch information
AndyEPhipps and KrupaPammi authored Feb 16, 2023
1 parent dae86e2 commit e40a085
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 165 deletions.
5 changes: 1 addition & 4 deletions cypress/integration/submit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ describe('e2e test', () => {
});

it('Verify Marketing Email Marketing preference', () => {
cy.get('#field-wrapper--Email > div > #field-label--Yes--Email').check().uncheck();
cy.get('#field-wrapper--Email > div > #field-label--No--Email').check().uncheck();
cy.get('#field-wrapper--Email > div > #field-label--Yes--Email').check();
cy.get('#field-wrapper--Email > div > #field-label--No--Email').should('not.be.checked');
cy.get('#field-label--Email--Email').check().uncheck().check();
cy.get('#field-input--email').should('be.visible');
cy.get('button[type=submit]').click();
cy.get('#field-error--email>span').should('contain', 'Please fill in your email address');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@babel/polyfill": "^7.11.5",
"@comicrelief/pattern-lab": "7.58.6",
"@comicrelief/storybook": "1.30.6",
"@comicrelief/storybook": "1.31.0",
"@snyk/protect": "^1.986.0",
"autoprefixer": "10.0.0",
"axios": "^0.21.1",
Expand Down
117 changes: 46 additions & 71 deletions src/pages/GiftAid/SubmitForm/marketingConsentData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@
*
*/
export const marketingConsentData = {
Questions: [
"Questions": [
{
id: 'permissionEmail',
text: "Email me",
name: "Email",
options: [
"id": "permissionEmail",
"text": "Email me",
"name": "Email",
"options": [
{
label: 'Yes',
value: 'yes',
name: 'permissionEmail',
hideFields: false
},
{
label: 'No',
value: 'no',
name: 'permissionEmail',
hideFields: false,
extraInfo : "Please provide your email so we can remove it from our database, otherwise untick this option."

"label": "Email",
"value": "yes",
"name": "emailPermission",
"hideFields": false,
"extraInfo": "Please confirm the email address we will use to <b>email</b> you:"
}
],
field: [
Expand All @@ -39,72 +32,54 @@ export const marketingConsentData = {
]
},
{
id: 'permissionPost',
text: "Send me post",
name: "Post",
options: [
"id": "permissionPhone",
"text": "Phone me",
"name": "Phone",
"options": [
{
label: 'Yes',
value: 'yes',
name: 'permissionPost',
},
"label": "Phone",
"value": "yes",
"name": "phonePermission",
"hideFields": false,
"extraInfo": "Please confirm the telephone number we will use to <b>phone</b> you on:"

}
],
"field": [
{
label: 'No',
value: 'no',
name: 'permissionPost',
extraInfo : "This will remove your provided address from our database if you have opted-in before."
"id": "phoneNumber",
"type": "tel",
"name": "phone",
"label": "Phone number",
"placeholder": "",
"required": true
}
]
},
{
id: 'permissionPhone',
text: 'Phone me',
name: "Phone",
options: [
{
label: 'Yes',
value: 'yes',
name: 'permissionPhone',
hideFields: false
},
"id": "permissionPost",
"text": "Send me post",
"name": "Post",
"options": [
{
label: 'No',
value: 'no',
name: 'permissionPhone',
hideFields: false,
extraInfo : "Please provide your telephone number so we can remove it from our database, otherwise untick this option."
}
],
field: [
{
id: 'phone',
type: 'tel',
name: 'phone',
label: 'Telephone number',
placeholder: 'Telephone number',
required: true,
"label": "Post",
"value": "yes",
"name": "postPermission"
}
]
},
{
id: 'permissionSMS',
text: 'Text me',
name: "SMS",
options: [
{
label: 'Yes',
value: 'yes',
name: 'permissionSMS',
hideFields: true
},
"id": "permissionSMS",
"text": "Text me",
"name": "SMS",
"options": [
{
label: 'No',
value: 'no',
name: 'permissionSMS',
hideFields: true,
extraInfo : "This will remove your provided mobile number from our database if you have opted-in before."
"label": "Text",
"value": "yes",
"name": "smsPermission",
"hideFields": true
}
],
}
]
},
]
};
3 changes: 0 additions & 3 deletions src/styles/SubmitForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ $colour-scorpion-grey: #595959;
.form__field-wrapper--background {
padding: 22px 44px;
.form__checkbox--inline-2-horizontal {
label {
padding-top: 1em;
}
input[type="checkbox"] + span,
input[type="checkbox"] {
top: 18px;
Expand Down
8 changes: 0 additions & 8 deletions tests/feature/submit/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ module.exports = {
client.expect.element('label#field-label--addressSelect').text.to.equal('Select your address');
client.click('select#field-select--addressSelect');
client.click('#field-select--addressSelect > option:nth-child(5)');
client.waitForElementPresent('#field-input--address1', 1000);
client.assert.value('#field-input--address1', 'COMIC RELIEF');
client.assert.value('#field-input--address2', 'CAMELFORD HOUSE 87-90');
client.assert.value('#field-input--address3', 'ALBERT EMBANKMENT');
client.assert.value('#field-input--town', 'LONDON');
client.assert.value('#field-select--country', 'GB');
client.expect.element('.form__row--marketing-consent>div>div>p:nth-child(2)').text.to.equal('How would you like to hear from us?');
client.click('button[type="submit"]');
client.pause(5000);
client.waitForElementVisible('div > h1', 2000);
Expand All @@ -46,7 +39,6 @@ module.exports = {
client.setValue('#field-input--address2', 'High road');
client.setValue('#field-input--address3', 'Waterloo');
client.setValue('#field-input--town', 'London');
client.expect.element('.form__row--marketing-consent>div>div>p:nth-child(2)').text.to.equal('How would you like to hear from us?');
client.click('button[type="submit"]');
client.pause(5000);
client.waitForElementVisible('div > h1', 2000);
Expand Down
26 changes: 13 additions & 13 deletions tests/feature/submit/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module.exports = {
'Verify error messages on empty giftaid submission': function (client) {
client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000);
client.click('button[type=submit]');
client.assert.containsText('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox');
client.assert.containsText('#field-error--mobile>span', 'Please fill in your mobile number');
client.assert.containsText('#field-error--firstname>span', 'Please fill in your first name');
client.assert.containsText('#field-error--lastname>span', 'Please fill in your last name');
client.assert.containsText('#field-error--postcode>span', 'Please enter your postcode');
client.assert.containsText('#field-error--addressDetails>span', 'Please fill in your address');
client.assert.textContains('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox');
client.assert.textContains('#field-error--mobile>span', 'Please fill in your mobile number');
client.assert.textContains('#field-error--firstname>span', 'Please fill in your first name');
client.assert.textContains('#field-error--lastname>span', 'Please fill in your last name');
client.assert.textContains('#field-error--postcode>span', 'Please enter your postcode');
client.assert.textContains('#field-error--addressDetails>span', 'Please fill in your address');
client.click('a[aria-describedby=field-error--addressDetails]');
client.assert.containsText('#field-error--address1>span', 'Please fill in your address line 1');
client.assert.containsText('#field-error--town>span', 'Please fill in your town/city');
client.assert.textContains('#field-error--address1>span', 'Please fill in your address line 1');
client.assert.textContains('#field-error--town>span', 'Please fill in your town/city');
client.end();
},

Expand Down Expand Up @@ -47,7 +47,7 @@ module.exports = {
client.click('button[type=submit]');
client.pause(2000);
client.expect.element('div > h1').text.to.not.equal('Sorry!');
client.assert.containsText('#field-error--mobile>span', 'Please fill in your mobile number');
client.assert.textContains('#field-error--mobile>span', 'Please fill in your mobile number');
client.end();
},

Expand All @@ -64,7 +64,7 @@ module.exports = {
client.click('button[type=submit]');
client.pause(2000);
client.expect.element('div > h1').text.to.not.equal('Sorry!');
client.assert.containsText('#field-error--firstname', 'Please fill in your first name');
client.assert.textContains('#field-error--firstname', 'Please fill in your first name');
client.end();
},

Expand All @@ -81,7 +81,7 @@ module.exports = {
client.click('button[type=submit]');
client.pause(2000);
client.expect.element('div > h1').text.to.not.equal('Sorry!');
client.assert.containsText('#field-error--lastname', 'Please fill in your last name');
client.assert.textContains('#field-error--lastname', 'Please fill in your last name');
client.end();
},

Expand All @@ -95,7 +95,7 @@ module.exports = {
client.click('button[type=submit]');
client.pause(2000);
client.expect.element('div > h1').text.to.not.equal('Sorry!');
client.assert.containsText('#field-error--postcode', 'Please enter your postcode');
client.assert.textContains('#field-error--postcode', 'Please enter your postcode');
client.end();
},

Expand All @@ -113,7 +113,7 @@ module.exports = {
client.click('button[type=submit]');
client.pause(2000);
client.expect.element('div > h1').text.to.not.equal('Sorry!');
client.assert.containsText('#field-error--town', 'Please fill in your town/city');
client.assert.textContains('#field-error--town', 'Please fill in your town/city');
client.end();
},
};
24 changes: 8 additions & 16 deletions tests/feature/submit/marketingPreferencesData.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const testData = {
country: 'GB',
};


module.exports = {

'@tags': ['sanity', 'submit', 'marketingPreferencesData'],
Expand All @@ -45,33 +44,26 @@ module.exports = {

// marketing preferences
// email
client.assert.containsText('.form__field-wrapper--Email > p.form__fieldset--label', 'Email me');
client.waitForElementVisible('#field-wrapper--Email', 1000);
// yes for email
client.click('#field-wrapper--Email>div:nth-child(2)>label');
client.assert.containsText('#field-wrapper--Email>div:nth-child(1)>label', 'Yes');
client.assert.containsText('label#field-label--email', 'Email address');
client.click('#field-wrapper--Email>div:nth-child(1)');
client.assert.elementPresent('#field-input--email');
client.setValue('#field-input--email', email);

// yes for Post
client.assert.containsText('.form__field-wrapper--Post > p.form__fieldset--label', 'Send me post');
client.waitForElementVisible('#field-wrapper--Post', 1000);
client.click('#field-wrapper--Post div:nth-child(1) > label');
client.click('#field-wrapper--Post div:nth-child(1)');

// Phone - accepts both mobile & telephone numbers
client.assert.containsText('.form__field-wrapper--Phone > p', 'Phone me');
client.waitForElementVisible('#field-wrapper--Phone', 1000);

// Yes option
client.click('#field-wrapper--Phone div:nth-child(1) > label');
client.assert.containsText('#field-wrapper--Phone div:nth-child(1) > label', 'Yes');
client.click('#field-wrapper--Phone div:nth-child(1)');
client.setValue('input#field-input--phone', testData.phone);

// SMS
client.assert.containsText('.form__field-wrapper--SMS > p', 'Text me');
client.waitForElementVisible('#field-wrapper--SMS', 1000);
client.click('#field-wrapper--SMS div:nth-child(1) > label');
client.click('#field-wrapper--SMS div:nth-child(1)');

// submit form
client.click('button[type=submit]');
Expand Down Expand Up @@ -104,10 +96,10 @@ module.exports = {
client.assert.equal(data.transsource, 'YRW_GiftAid', 'transsource');
client.assert.equal(data.transsourceurl, process.env.BASE_URL, 'transsourceurl');
client.assert.equal(data.transtype, 'prefs', 'transtype');
client.assert.equal(data.permissionemail, '0', 'permissionemail:no');
client.assert.equal(data.permissionphone, '1', 'permissionphone:yes');
client.assert.equal(data.permissionpost, '1', 'permissionpost:yes');
client.assert.equal(data.permissionsms, '1', 'permissionsms:yes');
client.assert.equal(data.permissionemail, '1', 'permissionemail');
client.assert.equal(data.permissionphone, '1', 'permissionphone');
client.assert.equal(data.permissionpost, '', 'permissionpost');
client.assert.equal(data.permissionsms, '', 'permissionsms');
done();
})
.catch((error) => {
Expand Down
Loading

0 comments on commit e40a085

Please sign in to comment.