Skip to content

Commit e40a085

Browse files
ENG-2236: MP update (#375)
* 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 <krupa.pammi@gmail.com>
1 parent dae86e2 commit e40a085

9 files changed

Lines changed: 88 additions & 165 deletions

File tree

cypress/integration/submit_spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ describe('e2e test', () => {
9090
});
9191

9292
it('Verify Marketing Email Marketing preference', () => {
93-
cy.get('#field-wrapper--Email > div > #field-label--Yes--Email').check().uncheck();
94-
cy.get('#field-wrapper--Email > div > #field-label--No--Email').check().uncheck();
95-
cy.get('#field-wrapper--Email > div > #field-label--Yes--Email').check();
96-
cy.get('#field-wrapper--Email > div > #field-label--No--Email').should('not.be.checked');
93+
cy.get('#field-label--Email--Email').check().uncheck().check();
9794
cy.get('#field-input--email').should('be.visible');
9895
cy.get('button[type=submit]').click();
9996
cy.get('#field-error--email>span').should('contain', 'Please fill in your email address');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"@babel/polyfill": "^7.11.5",
77
"@comicrelief/pattern-lab": "7.58.6",
8-
"@comicrelief/storybook": "1.30.6",
8+
"@comicrelief/storybook": "1.31.0",
99
"@snyk/protect": "^1.986.0",
1010
"autoprefixer": "10.0.0",
1111
"axios": "^0.21.1",

src/pages/GiftAid/SubmitForm/marketingConsentData.js

Lines changed: 46 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@
66
*
77
*/
88
export const marketingConsentData = {
9-
Questions: [
9+
"Questions": [
1010
{
11-
id: 'permissionEmail',
12-
text: "Email me",
13-
name: "Email",
14-
options: [
11+
"id": "permissionEmail",
12+
"text": "Email me",
13+
"name": "Email",
14+
"options": [
1515
{
16-
label: 'Yes',
17-
value: 'yes',
18-
name: 'permissionEmail',
19-
hideFields: false
20-
},
21-
{
22-
label: 'No',
23-
value: 'no',
24-
name: 'permissionEmail',
25-
hideFields: false,
26-
extraInfo : "Please provide your email so we can remove it from our database, otherwise untick this option."
27-
16+
"label": "Email",
17+
"value": "yes",
18+
"name": "emailPermission",
19+
"hideFields": false,
20+
"extraInfo": "Please confirm the email address we will use to <b>email</b> you:"
2821
}
2922
],
3023
field: [
@@ -39,72 +32,54 @@ export const marketingConsentData = {
3932
]
4033
},
4134
{
42-
id: 'permissionPost',
43-
text: "Send me post",
44-
name: "Post",
45-
options: [
35+
"id": "permissionPhone",
36+
"text": "Phone me",
37+
"name": "Phone",
38+
"options": [
4639
{
47-
label: 'Yes',
48-
value: 'yes',
49-
name: 'permissionPost',
50-
},
40+
"label": "Phone",
41+
"value": "yes",
42+
"name": "phonePermission",
43+
"hideFields": false,
44+
"extraInfo": "Please confirm the telephone number we will use to <b>phone</b> you on:"
45+
46+
}
47+
],
48+
"field": [
5149
{
52-
label: 'No',
53-
value: 'no',
54-
name: 'permissionPost',
55-
extraInfo : "This will remove your provided address from our database if you have opted-in before."
50+
"id": "phoneNumber",
51+
"type": "tel",
52+
"name": "phone",
53+
"label": "Phone number",
54+
"placeholder": "",
55+
"required": true
5656
}
5757
]
5858
},
5959
{
60-
id: 'permissionPhone',
61-
text: 'Phone me',
62-
name: "Phone",
63-
options: [
64-
{
65-
label: 'Yes',
66-
value: 'yes',
67-
name: 'permissionPhone',
68-
hideFields: false
69-
},
60+
"id": "permissionPost",
61+
"text": "Send me post",
62+
"name": "Post",
63+
"options": [
7064
{
71-
label: 'No',
72-
value: 'no',
73-
name: 'permissionPhone',
74-
hideFields: false,
75-
extraInfo : "Please provide your telephone number so we can remove it from our database, otherwise untick this option."
76-
}
77-
],
78-
field: [
79-
{
80-
id: 'phone',
81-
type: 'tel',
82-
name: 'phone',
83-
label: 'Telephone number',
84-
placeholder: 'Telephone number',
85-
required: true,
65+
"label": "Post",
66+
"value": "yes",
67+
"name": "postPermission"
8668
}
8769
]
8870
},
8971
{
90-
id: 'permissionSMS',
91-
text: 'Text me',
92-
name: "SMS",
93-
options: [
94-
{
95-
label: 'Yes',
96-
value: 'yes',
97-
name: 'permissionSMS',
98-
hideFields: true
99-
},
72+
"id": "permissionSMS",
73+
"text": "Text me",
74+
"name": "SMS",
75+
"options": [
10076
{
101-
label: 'No',
102-
value: 'no',
103-
name: 'permissionSMS',
104-
hideFields: true,
105-
extraInfo : "This will remove your provided mobile number from our database if you have opted-in before."
77+
"label": "Text",
78+
"value": "yes",
79+
"name": "smsPermission",
80+
"hideFields": true
10681
}
107-
],
108-
}
82+
]
83+
},
10984
]
11085
};

src/styles/SubmitForm.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ $colour-scorpion-grey: #595959;
3232
.form__field-wrapper--background {
3333
padding: 22px 44px;
3434
.form__checkbox--inline-2-horizontal {
35-
label {
36-
padding-top: 1em;
37-
}
3835
input[type="checkbox"] + span,
3936
input[type="checkbox"] {
4037
top: 18px;

tests/feature/submit/address.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ module.exports = {
1616
client.expect.element('label#field-label--addressSelect').text.to.equal('Select your address');
1717
client.click('select#field-select--addressSelect');
1818
client.click('#field-select--addressSelect > option:nth-child(5)');
19-
client.waitForElementPresent('#field-input--address1', 1000);
20-
client.assert.value('#field-input--address1', 'COMIC RELIEF');
21-
client.assert.value('#field-input--address2', 'CAMELFORD HOUSE 87-90');
22-
client.assert.value('#field-input--address3', 'ALBERT EMBANKMENT');
23-
client.assert.value('#field-input--town', 'LONDON');
24-
client.assert.value('#field-select--country', 'GB');
25-
client.expect.element('.form__row--marketing-consent>div>div>p:nth-child(2)').text.to.equal('How would you like to hear from us?');
2619
client.click('button[type="submit"]');
2720
client.pause(5000);
2821
client.waitForElementVisible('div > h1', 2000);
@@ -46,7 +39,6 @@ module.exports = {
4639
client.setValue('#field-input--address2', 'High road');
4740
client.setValue('#field-input--address3', 'Waterloo');
4841
client.setValue('#field-input--town', 'London');
49-
client.expect.element('.form__row--marketing-consent>div>div>p:nth-child(2)').text.to.equal('How would you like to hear from us?');
5042
client.click('button[type="submit"]');
5143
client.pause(5000);
5244
client.waitForElementVisible('div > h1', 2000);

tests/feature/submit/error.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module.exports = {
55
'Verify error messages on empty giftaid submission': function (client) {
66
client.url(process.env.BASE_URL).maximizeWindow().waitForElementVisible('body', 1000);
77
client.click('button[type=submit]');
8-
client.assert.containsText('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox');
9-
client.assert.containsText('#field-error--mobile>span', 'Please fill in your mobile number');
10-
client.assert.containsText('#field-error--firstname>span', 'Please fill in your first name');
11-
client.assert.containsText('#field-error--lastname>span', 'Please fill in your last name');
12-
client.assert.containsText('#field-error--postcode>span', 'Please enter your postcode');
13-
client.assert.containsText('#field-error--addressDetails>span', 'Please fill in your address');
8+
client.assert.textContains('#field-error--giftaid>span', 'To Gift Aid your donation you need to tick the checkbox');
9+
client.assert.textContains('#field-error--mobile>span', 'Please fill in your mobile number');
10+
client.assert.textContains('#field-error--firstname>span', 'Please fill in your first name');
11+
client.assert.textContains('#field-error--lastname>span', 'Please fill in your last name');
12+
client.assert.textContains('#field-error--postcode>span', 'Please enter your postcode');
13+
client.assert.textContains('#field-error--addressDetails>span', 'Please fill in your address');
1414
client.click('a[aria-describedby=field-error--addressDetails]');
15-
client.assert.containsText('#field-error--address1>span', 'Please fill in your address line 1');
16-
client.assert.containsText('#field-error--town>span', 'Please fill in your town/city');
15+
client.assert.textContains('#field-error--address1>span', 'Please fill in your address line 1');
16+
client.assert.textContains('#field-error--town>span', 'Please fill in your town/city');
1717
client.end();
1818
},
1919

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

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

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

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

@@ -113,7 +113,7 @@ module.exports = {
113113
client.click('button[type=submit]');
114114
client.pause(2000);
115115
client.expect.element('div > h1').text.to.not.equal('Sorry!');
116-
client.assert.containsText('#field-error--town', 'Please fill in your town/city');
116+
client.assert.textContains('#field-error--town', 'Please fill in your town/city');
117117
client.end();
118118
},
119119
};

tests/feature/submit/marketingPreferencesData.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const testData = {
1919
country: 'GB',
2020
};
2121

22-
2322
module.exports = {
2423

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

4645
// marketing preferences
4746
// email
48-
client.assert.containsText('.form__field-wrapper--Email > p.form__fieldset--label', 'Email me');
4947
client.waitForElementVisible('#field-wrapper--Email', 1000);
5048
// yes for email
51-
client.click('#field-wrapper--Email>div:nth-child(2)>label');
52-
client.assert.containsText('#field-wrapper--Email>div:nth-child(1)>label', 'Yes');
53-
client.assert.containsText('label#field-label--email', 'Email address');
49+
client.click('#field-wrapper--Email>div:nth-child(1)');
5450
client.assert.elementPresent('#field-input--email');
5551
client.setValue('#field-input--email', email);
5652

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

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

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

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

7668
// submit form
7769
client.click('button[type=submit]');
@@ -104,10 +96,10 @@ module.exports = {
10496
client.assert.equal(data.transsource, 'YRW_GiftAid', 'transsource');
10597
client.assert.equal(data.transsourceurl, process.env.BASE_URL, 'transsourceurl');
10698
client.assert.equal(data.transtype, 'prefs', 'transtype');
107-
client.assert.equal(data.permissionemail, '0', 'permissionemail:no');
108-
client.assert.equal(data.permissionphone, '1', 'permissionphone:yes');
109-
client.assert.equal(data.permissionpost, '1', 'permissionpost:yes');
110-
client.assert.equal(data.permissionsms, '1', 'permissionsms:yes');
99+
client.assert.equal(data.permissionemail, '1', 'permissionemail');
100+
client.assert.equal(data.permissionphone, '1', 'permissionphone');
101+
client.assert.equal(data.permissionpost, '', 'permissionpost');
102+
client.assert.equal(data.permissionsms, '', 'permissionsms');
111103
done();
112104
})
113105
.catch((error) => {

0 commit comments

Comments
 (0)