@comicrelief/component-library 7.19.2 → 7.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cypress/{integration/components/atoms/button.spec.js → e2e/components/atoms/button.cy.js} +4 -15
- package/cypress/{integration/components/atoms/buttonWithStates.spec.js → e2e/components/atoms/buttonWithStates.cy.js} +5 -11
- package/cypress/{integration/components/atoms/checkbox.spec.js → e2e/components/atoms/checkbox.cy.js} +2 -0
- package/cypress/{integration/components/atoms/confetti.spec.js → e2e/components/atoms/confetti.cy.js} +2 -8
- package/cypress/{integration/components/atoms/errorText.spec.js → e2e/components/atoms/errorText.cy.js} +1 -7
- package/cypress/{integration/components/atoms/input.spec.js → e2e/components/atoms/input.cy.js} +4 -14
- package/cypress/{integration/components/atoms/label.spec.js → e2e/components/atoms/label.cy.js} +3 -14
- package/cypress/{integration/components/atoms/link.spec.js → e2e/components/atoms/link.cy.js} +4 -21
- package/cypress/{integration/components/atoms/logo.spec.js → e2e/components/atoms/logo.cy.js} +4 -21
- package/cypress/{integration/components/atoms/pagination.spec.js → e2e/components/atoms/pagination.cy.js} +5 -28
- package/cypress/{integration/components/atoms/picture.spec.js → e2e/components/atoms/picture.cy.js} +4 -21
- package/cypress/{integration/components/atoms/radioButton.spec.js → e2e/components/atoms/radioButton.cy.js} +2 -7
- package/cypress/{integration/components/atoms/richText.spec.js → e2e/components/atoms/richText.cy.js} +2 -7
- package/cypress/{integration/components/atoms/select.spec.js → e2e/components/atoms/select.cy.js} +2 -7
- package/cypress/{integration/components/atoms/socialIcons.spec.js → e2e/components/atoms/socialIcons.cy.js} +4 -21
- package/cypress/{integration/components/atoms/text.spec.js → e2e/components/atoms/text.cy.js} +3 -14
- package/cypress/{integration/components/atoms/textArea.spec.js → e2e/components/atoms/textArea.cy.js} +2 -4
- package/cypress/{integration/components/atoms/textInputWithDrop.spec.js → e2e/components/atoms/textInputWithDrop.cy.js} +2 -4
- package/cypress/{integration/components/molecules/accordion.spec.js → e2e/components/molecules/accordion.cy.js} +2 -7
- package/cypress/{integration/components/molecules/articleTeaser.spec.js → e2e/components/molecules/articleTeaser.cy.js} +2 -7
- package/cypress/{integration/components/molecules/banner.spec.js → e2e/components/molecules/banner.cy.js} +2 -7
- package/cypress/{integration/components/molecules/box.spec.js → e2e/components/molecules/box.cy.js} +3 -11
- package/cypress/{integration/components/molecules/card.spec.js → e2e/components/molecules/card.cy.js} +3 -11
- package/cypress/{integration/components/molecules/cardDs.spec.js → e2e/components/molecules/cardDs.cy.js} +5 -30
- package/cypress/{integration/components/molecules/chip.spec.js → e2e/components/molecules/chip.cy.js} +2 -4
- package/cypress/{integration/components/molecules/countdown.spec.js → e2e/components/molecules/countdown.cy.js} +2 -4
- package/cypress/{integration/components/molecules/descriptor.spec.js → e2e/components/molecules/descriptor.cy.js} +3 -8
- package/cypress/{integration/components/molecules/doubleCopy.spec.js → e2e/components/molecules/doubleCopy.cy.js} +2 -4
- package/cypress/{integration/components/molecules/heroBanner.spec.js → e2e/components/molecules/heroBanner.cy.js} +2 -4
- package/cypress/{integration/components/molecules/infoBanner.spec.js → e2e/components/molecules/infoBanner.cy.js} +2 -4
- package/cypress/{integration/components/molecules/partnerLink.spec.js → e2e/components/molecules/partnerLink.cy.js} +2 -4
- package/cypress/{integration/components/molecules/promo.spec.js → e2e/components/molecules/promo.cy.js} +2 -4
- package/cypress/{integration/components/molecules/schoolLookup.spec.js → e2e/components/molecules/schoolLookup.cy.js} +3 -4
- package/cypress/{integration/components/molecules/searchInput.spec.js → e2e/components/molecules/searchInput.cy.js} +2 -4
- package/cypress/{integration/components/molecules/searchResult.spec.js → e2e/components/molecules/searchResult.cy.js} +5 -16
- package/cypress/{integration/components/molecules/shareButton.spec.js → e2e/components/molecules/shareButton.cy.js} +2 -4
- package/cypress/{integration/components/molecules/simpleSchoolLookup.spec.js → e2e/components/molecules/simpleSchoolLookup.cy.js} +3 -4
- package/cypress/{integration/components/molecules/singleMessage.spec.js → e2e/components/molecules/singleMessage.cy.js} +14 -49
- package/cypress/{integration/components/molecules/singleMessageDs.spec.js → e2e/components/molecules/singleMessageDs.cy.js} +6 -20
- package/cypress/{integration/components/molecules/typeahead.spec.js → e2e/components/molecules/typeahead.cy.js} +3 -4
- package/cypress/{integration/components/molecules/videoBanner.spec.js → e2e/components/molecules/videoBanner.cy.js} +4 -12
- package/cypress/{integration/components/organisms/cookieBanner.spec.js → e2e/components/organisms/cookieBanner.cy.js} +2 -4
- package/cypress/{integration/components/organisms/donate.spec.js → e2e/components/organisms/donate.cy.js} +5 -16
- package/cypress/{integration/components/organisms/emailSignUp.spec.js → e2e/components/organisms/emailSignUp.cy.js} +1 -4
- package/cypress/{integration/components/organisms/footer.spec.js → e2e/components/organisms/footer.cy.js} +2 -0
- package/cypress/{integration/components/organisms/header.spec.js → e2e/components/organisms/header.cy.js} +3 -8
- package/cypress/{integration/components/organisms/marketingPreferencesDSForm.spec.js → e2e/components/organisms/marketingPreferencesDSForm.cy.js} +44 -56
- package/cypress/{integration/components/organisms/membership.spec.js → e2e/components/organisms/membership.cy.js} +3 -8
- package/cypress.config.js +15 -0
- package/dist/components/Atoms/Link/Link.js +5 -5
- package/dist/components/Molecules/SimpleSchoolLookup/SimpleSchoolLookup.js +6 -2
- package/dist/components/Organisms/Footer/Footer.js +1 -1
- package/dist/components/Organisms/Footer/Footer.md +2 -2
- package/dist/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +2 -2
- package/dist/components/Organisms/Footer/data/data.js +2 -2
- package/dist/components/Organisms/Header/Nav/Nav.js +2 -2
- package/dist/components/Organisms/Header/data/data.js +2 -2
- package/dist/index.js +3 -3
- package/dist/utils/{whiteListed.js → allowListed.js} +4 -4
- package/dist/utils/allowListed.test.js +12 -0
- package/docs/utils.md +4 -4
- package/package.json +2 -2
- package/src/components/Atoms/Link/Link.js +5 -5
- package/src/components/Molecules/SimpleSchoolLookup/SimpleSchoolLookup.js +8 -3
- package/src/components/Organisms/Footer/Footer.js +2 -2
- package/src/components/Organisms/Footer/Footer.md +2 -2
- package/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +2 -2
- package/src/components/Organisms/Footer/data/data.js +2 -2
- package/src/components/Organisms/Header/Nav/Nav.js +2 -2
- package/src/components/Organisms/Header/data/data.js +2 -2
- package/src/index.js +1 -1
- package/src/utils/{whiteListed.js → allowListed.js} +6 -5
- package/src/utils/allowListed.test.js +9 -0
- package/cypress.json +0 -6
- package/dist/utils/whiteListed.test.js +0 -12
- package/src/utils/whiteListed.test.js +0 -9
- /package/cypress/support/{index.js → e2e.js} +0 -0
|
@@ -6,6 +6,7 @@ describe('Footer component', () => {
|
|
|
6
6
|
|
|
7
7
|
describe('props and methods section', () => {
|
|
8
8
|
beforeEach(() => {
|
|
9
|
+
cy.visit('/#footer');
|
|
9
10
|
cy.get('[data-testid="Footer-container"] button[name="rsg-usage"]')
|
|
10
11
|
.contains('Props & methods')
|
|
11
12
|
.as('propsBtn');
|
|
@@ -35,6 +36,7 @@ describe('Footer component', () => {
|
|
|
35
36
|
|
|
36
37
|
describe('Footer section', () => {
|
|
37
38
|
beforeEach(() => {
|
|
39
|
+
cy.visit('/#footer');
|
|
38
40
|
cy.get('[data-testid="Footer-example-1"]')
|
|
39
41
|
.as('container')
|
|
40
42
|
.find('[data-preview="Footer"]')
|
|
@@ -6,6 +6,7 @@ describe('Header component', () => {
|
|
|
6
6
|
|
|
7
7
|
describe('props and methods section', () => {
|
|
8
8
|
beforeEach(() => {
|
|
9
|
+
cy.visit('/#header');
|
|
9
10
|
cy.get('[data-testid="Header-container"] button[name="rsg-usage"]')
|
|
10
11
|
.contains('Props & methods')
|
|
11
12
|
.as('propsBtn');
|
|
@@ -35,6 +36,7 @@ describe('Header component', () => {
|
|
|
35
36
|
|
|
36
37
|
describe('CR Header section', () => {
|
|
37
38
|
beforeEach(() => {
|
|
39
|
+
cy.visit('/#header');
|
|
38
40
|
cy.get('[data-testid="Header-example-1"]')
|
|
39
41
|
.as('container')
|
|
40
42
|
.find('[data-preview="Header"]')
|
|
@@ -76,14 +78,11 @@ describe('Header component', () => {
|
|
|
76
78
|
.find('textarea')
|
|
77
79
|
.should('exist');
|
|
78
80
|
});
|
|
79
|
-
|
|
80
|
-
it('closes code on click', () => {
|
|
81
|
-
cy.get('@viewCodeBtn').click();
|
|
82
|
-
});
|
|
83
81
|
});
|
|
84
82
|
|
|
85
83
|
describe('CR Header with search and ESU section', () => {
|
|
86
84
|
beforeEach(() => {
|
|
85
|
+
cy.visit('/#header');
|
|
87
86
|
cy.get('[data-testid="Header-example-7"]')
|
|
88
87
|
.as('container')
|
|
89
88
|
.find('[data-preview="Header"]')
|
|
@@ -135,9 +134,5 @@ describe('Header component', () => {
|
|
|
135
134
|
.find('textarea')
|
|
136
135
|
.should('exist');
|
|
137
136
|
});
|
|
138
|
-
|
|
139
|
-
it('closes code on click', () => {
|
|
140
|
-
cy.get('@viewCodeBtn').click();
|
|
141
|
-
});
|
|
142
137
|
});
|
|
143
138
|
});
|
|
@@ -4,6 +4,7 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
4
4
|
});
|
|
5
5
|
|
|
6
6
|
beforeEach(() => {
|
|
7
|
+
cy.visit('/#!/MarketingPreferencesDSForm/1');
|
|
7
8
|
cy.window().then(win => {
|
|
8
9
|
cy.spy(win.console, 'log').as('consoleLog');
|
|
9
10
|
});
|
|
@@ -95,21 +96,21 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
95
96
|
cy.get('@default')
|
|
96
97
|
.find('#mp_permissionEmail-yes').click();
|
|
97
98
|
cy.get('@default')
|
|
98
|
-
.find('
|
|
99
|
+
.find('#mp_email')
|
|
99
100
|
.type('@an-invalid@email.com');
|
|
100
101
|
|
|
101
102
|
// Fill SMS field with an invalid value
|
|
102
103
|
cy.get('@default')
|
|
103
104
|
.find('#mp_permissionSMS-yes').click();
|
|
104
105
|
cy.get('@default')
|
|
105
|
-
.find('
|
|
106
|
+
.find('#mp_mobile')
|
|
106
107
|
.type('07777');
|
|
107
108
|
|
|
108
109
|
// Fill Phone field with an invalid value
|
|
109
110
|
cy.get('@default')
|
|
110
111
|
.find('#mp_permissionPhone-yes').click();
|
|
111
112
|
cy.get('@default')
|
|
112
|
-
.find('
|
|
113
|
+
.find('#mp_phone')
|
|
113
114
|
.type('0208');
|
|
114
115
|
|
|
115
116
|
// Fill Post fields with invalid values
|
|
@@ -117,11 +118,11 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
117
118
|
.find('#mp_permissionPost-yes').click();
|
|
118
119
|
// Address 1
|
|
119
120
|
cy.get('@default')
|
|
120
|
-
.find('
|
|
121
|
+
.find('#mp_address1')
|
|
121
122
|
.type('@');
|
|
122
123
|
// Address 2
|
|
123
124
|
cy.get('@default')
|
|
124
|
-
.find('
|
|
125
|
+
.find('#mp_address2')
|
|
125
126
|
.type('@');
|
|
126
127
|
// Address 3
|
|
127
128
|
cy.get('@default')
|
|
@@ -188,50 +189,21 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
188
189
|
});
|
|
189
190
|
|
|
190
191
|
it('check Default example with empty values', () => {
|
|
191
|
-
//
|
|
192
|
-
cy.get('@default')
|
|
193
|
-
.find('#mp_email')
|
|
194
|
-
.clear();
|
|
195
|
-
|
|
196
|
-
// Clear SMS field
|
|
197
|
-
cy.get('@default')
|
|
198
|
-
.find('#mp_mobile')
|
|
199
|
-
.clear();
|
|
200
|
-
|
|
201
|
-
// Clear Phone field
|
|
202
|
-
cy.get('@default')
|
|
203
|
-
.find(' #mp_phone')
|
|
204
|
-
.clear();
|
|
205
|
-
|
|
206
|
-
// Clear Post fields
|
|
207
|
-
// Address 1
|
|
208
|
-
cy.get('@default')
|
|
209
|
-
.find(' #mp_address1')
|
|
210
|
-
.clear();
|
|
211
|
-
// Address 2
|
|
192
|
+
// Show email field
|
|
212
193
|
cy.get('@default')
|
|
213
|
-
.find('
|
|
214
|
-
.clear();
|
|
215
|
-
|
|
216
|
-
// Address 3
|
|
217
|
-
cy.get('@default')
|
|
218
|
-
.find('#mp_address3')
|
|
219
|
-
.clear();
|
|
194
|
+
.find('#mp_permissionEmail-yes').click();
|
|
220
195
|
|
|
221
|
-
//
|
|
196
|
+
// Show SMS field
|
|
222
197
|
cy.get('@default')
|
|
223
|
-
.find('#
|
|
224
|
-
.clear();
|
|
198
|
+
.find('#mp_permissionSMS-yes').click();
|
|
225
199
|
|
|
226
|
-
//
|
|
200
|
+
// Show Phone field
|
|
227
201
|
cy.get('@default')
|
|
228
|
-
.find('#
|
|
229
|
-
.clear();
|
|
202
|
+
.find('#mp_permissionPhone-yes').click();
|
|
230
203
|
|
|
231
|
-
//
|
|
204
|
+
// Show Post fields
|
|
232
205
|
cy.get('@default')
|
|
233
|
-
.find('#
|
|
234
|
-
.clear();
|
|
206
|
+
.find('#mp_permissionPost-yes').click();
|
|
235
207
|
|
|
236
208
|
// Submit
|
|
237
209
|
cy.get('@default-submit').click();
|
|
@@ -293,27 +265,35 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
293
265
|
it('Check Default example with valid values', () => {
|
|
294
266
|
// Fill email field with an valid value
|
|
295
267
|
cy.get('@default')
|
|
296
|
-
|
|
268
|
+
.find('#mp_permissionEmail-yes').click();
|
|
269
|
+
cy.get('@default')
|
|
270
|
+
.find('#mp_email')
|
|
297
271
|
.type('a-valid@email.com');
|
|
298
272
|
|
|
299
273
|
// Fill SMS field with a valid value
|
|
300
274
|
cy.get('@default')
|
|
301
|
-
|
|
275
|
+
.find('#mp_permissionSMS-yes').click();
|
|
276
|
+
cy.get('@default')
|
|
277
|
+
.find('#mp_mobile')
|
|
302
278
|
.type('07777 123123');
|
|
303
279
|
|
|
304
280
|
// Fill Phone field with a valid value
|
|
305
281
|
cy.get('@default')
|
|
306
|
-
|
|
282
|
+
.find('#mp_permissionPhone-yes').click();
|
|
283
|
+
cy.get('@default')
|
|
284
|
+
.find('#mp_phone')
|
|
307
285
|
.type('020 7820 2000');
|
|
308
286
|
|
|
309
287
|
// Fill Post fields with valid values
|
|
310
288
|
// Address 1
|
|
311
289
|
cy.get('@default')
|
|
312
|
-
.find('
|
|
290
|
+
.find('#mp_permissionPost-yes').click();
|
|
291
|
+
cy.get('@default')
|
|
292
|
+
.find('#mp_address1')
|
|
313
293
|
.type('10 King Road');
|
|
314
294
|
// Address 2
|
|
315
295
|
cy.get('@default')
|
|
316
|
-
.find('
|
|
296
|
+
.find('#mp_address2')
|
|
317
297
|
.type('Some Area');
|
|
318
298
|
// Address 3
|
|
319
299
|
cy.get('@default')
|
|
@@ -385,7 +365,7 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
385
365
|
cy.get('@customised')
|
|
386
366
|
.find('#mp_permissionPhone-yes').click();
|
|
387
367
|
cy.get('@customised')
|
|
388
|
-
.find('
|
|
368
|
+
.find('#mp_phone')
|
|
389
369
|
.type('0208');
|
|
390
370
|
|
|
391
371
|
// Fill Post fields with invalid values
|
|
@@ -393,11 +373,11 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
393
373
|
.find('#mp_permissionPost-yes').click();
|
|
394
374
|
// Address 1
|
|
395
375
|
cy.get('@customised')
|
|
396
|
-
.find('
|
|
376
|
+
.find('#mp_address1')
|
|
397
377
|
.type('@');
|
|
398
378
|
// Address 2
|
|
399
379
|
cy.get('@customised')
|
|
400
|
-
.find('
|
|
380
|
+
.find('#mp_address2')
|
|
401
381
|
.type('@');
|
|
402
382
|
// Address 3
|
|
403
383
|
cy.get('@customised')
|
|
@@ -454,17 +434,21 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
454
434
|
it('check Customised example with empty values', () => {
|
|
455
435
|
// Clear Phone field
|
|
456
436
|
cy.get('@customised')
|
|
457
|
-
.find('
|
|
437
|
+
.find('#mp_permissionPhone-yes').click();
|
|
438
|
+
cy.get('@customised')
|
|
439
|
+
.find('#mp_phone')
|
|
458
440
|
.clear();
|
|
459
441
|
|
|
460
442
|
// Clear Post fields
|
|
461
443
|
// Address 1
|
|
462
444
|
cy.get('@customised')
|
|
463
|
-
.find('
|
|
445
|
+
.find('#mp_permissionPost-yes').click();
|
|
446
|
+
cy.get('@customised')
|
|
447
|
+
.find('#mp_address1')
|
|
464
448
|
.clear();
|
|
465
449
|
// Address 2
|
|
466
450
|
cy.get('@customised')
|
|
467
|
-
.find('
|
|
451
|
+
.find('#mp_address2')
|
|
468
452
|
.clear();
|
|
469
453
|
|
|
470
454
|
// Address 3
|
|
@@ -535,17 +519,21 @@ describe('MarketingPreferencesDSForm component', () => {
|
|
|
535
519
|
it('Check Customised example with valid values', () => {
|
|
536
520
|
// Fill Phone field with a valid value
|
|
537
521
|
cy.get('@customised')
|
|
538
|
-
.find('
|
|
522
|
+
.find('#mp_permissionPhone-yes').click();
|
|
523
|
+
cy.get('@customised')
|
|
524
|
+
.find('#mp_phone')
|
|
539
525
|
.type('020 7820 2000');
|
|
540
526
|
|
|
541
527
|
// Fill Post fields with valid values
|
|
542
528
|
// Address 1
|
|
543
529
|
cy.get('@customised')
|
|
544
|
-
.find('
|
|
530
|
+
.find('#mp_permissionPost-yes').click();
|
|
531
|
+
cy.get('@customised')
|
|
532
|
+
.find('#mp_address1')
|
|
545
533
|
.type('10 King Road');
|
|
546
534
|
// Address 2
|
|
547
535
|
cy.get('@customised')
|
|
548
|
-
.find('
|
|
536
|
+
.find('#mp_address2')
|
|
549
537
|
.type('Some Area');
|
|
550
538
|
// Address 3
|
|
551
539
|
cy.get('@customised')
|
|
@@ -6,6 +6,7 @@ describe('Membership component', () => {
|
|
|
6
6
|
|
|
7
7
|
describe('props and methods section', () => {
|
|
8
8
|
beforeEach(() => {
|
|
9
|
+
cy.visit('/#membership');
|
|
9
10
|
cy.get('[data-testid="Membership-container"] button[name="rsg-usage"]')
|
|
10
11
|
.contains('Props & methods')
|
|
11
12
|
.as('propsBtn');
|
|
@@ -35,6 +36,7 @@ describe('Membership component', () => {
|
|
|
35
36
|
|
|
36
37
|
describe('Membership form align right section', () => {
|
|
37
38
|
beforeEach(() => {
|
|
39
|
+
cy.visit('/#membership');
|
|
38
40
|
cy.get('[data-testid="Membership-example-1"]')
|
|
39
41
|
.as('container')
|
|
40
42
|
.find('[data-preview="Membership"]')
|
|
@@ -73,14 +75,11 @@ describe('Membership component', () => {
|
|
|
73
75
|
.find('textarea')
|
|
74
76
|
.should('exist');
|
|
75
77
|
});
|
|
76
|
-
|
|
77
|
-
it('closes code on click', () => {
|
|
78
|
-
cy.get('@viewCodeBtn').click();
|
|
79
|
-
});
|
|
80
78
|
});
|
|
81
79
|
|
|
82
80
|
describe('Membership form align left section', () => {
|
|
83
81
|
beforeEach(() => {
|
|
82
|
+
cy.visit('/#membership');
|
|
84
83
|
cy.get('[data-testid="Membership-example-3"]')
|
|
85
84
|
.as('container')
|
|
86
85
|
.find('[data-preview="Membership"]')
|
|
@@ -119,9 +118,5 @@ describe('Membership component', () => {
|
|
|
119
118
|
.find('textarea')
|
|
120
119
|
.should('exist');
|
|
121
120
|
});
|
|
122
|
-
|
|
123
|
-
it('closes code on click', () => {
|
|
124
|
-
cy.get('@viewCodeBtn').click();
|
|
125
|
-
});
|
|
126
121
|
});
|
|
127
122
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { defineConfig } = require('cypress')
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
chromeWebSecurity: false,
|
|
5
|
+
viewportWidth: 1000,
|
|
6
|
+
viewportHeight: 1000,
|
|
7
|
+
e2e: {
|
|
8
|
+
// We've imported your old cypress plugins here.
|
|
9
|
+
// You may want to clean this up later by importing these.
|
|
10
|
+
setupNodeEvents(on, config) {
|
|
11
|
+
return require('./cypress/plugins/index.js')(on, config)
|
|
12
|
+
},
|
|
13
|
+
baseUrl: 'http://localhost:6060',
|
|
14
|
+
},
|
|
15
|
+
})
|
|
@@ -15,7 +15,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _Link = _interopRequireWildcard(require("./Link.style"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _allowListed = _interopRequireDefault(require("../../../utils/allowListed"));
|
|
19
19
|
|
|
20
20
|
var _internalLinkHelper = require("../../../utils/internalLinkHelper");
|
|
21
21
|
|
|
@@ -45,7 +45,7 @@ var Link = function Link(_ref) {
|
|
|
45
45
|
setDocumentHost = _useState2[1];
|
|
46
46
|
/**
|
|
47
47
|
* If we haven't specifically set the target via props, check if
|
|
48
|
-
* this is an internal link OR on our
|
|
48
|
+
* this is an internal link OR on our allowList before making it a '_self' link
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ var Link = function Link(_ref) {
|
|
|
54
54
|
var currentDomain = (0, _internalLinkHelper.getDomain)(documentHost);
|
|
55
55
|
var linkDomain = (0, _internalLinkHelper.getDomain)(href); // Additional check for applications that need more control
|
|
56
56
|
|
|
57
|
-
var
|
|
57
|
+
var isallowListOverridden = rest.overrideallowList === true;
|
|
58
58
|
/**
|
|
59
59
|
* If the link has no domain supplied (likely '/' or '#')
|
|
60
60
|
* OR has the same domain as the current page, don't open
|
|
@@ -62,8 +62,8 @@ var Link = function Link(_ref) {
|
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
64
|
var isExternalLink = linkDomain !== '' && currentDomain !== linkDomain;
|
|
65
|
-
var
|
|
66
|
-
window = isExternalLink && (
|
|
65
|
+
var isallowListed = (0, _allowListed.default)(href);
|
|
66
|
+
window = isExternalLink && (isallowListOverridden || !isallowListed) ? '_blank' : '_self';
|
|
67
67
|
} else {
|
|
68
68
|
window = target === 'blank' ? '_blank' : '_self';
|
|
69
69
|
}
|
|
@@ -19,7 +19,7 @@ var _axios = _interopRequireDefault(require("axios"));
|
|
|
19
19
|
|
|
20
20
|
var _Lookup = _interopRequireDefault(require("../Lookup/Lookup"));
|
|
21
21
|
|
|
22
|
-
var _excluded = ["onSelect"];
|
|
22
|
+
var _excluded = ["onSelect", "noResultsMessage"];
|
|
23
23
|
|
|
24
24
|
var schoolFetcher = /*#__PURE__*/function () {
|
|
25
25
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query) {
|
|
@@ -94,6 +94,7 @@ var schoolToString = function schoolToString(school) {
|
|
|
94
94
|
|
|
95
95
|
var SimpleSchoolLookup = function SimpleSchoolLookup(_ref2) {
|
|
96
96
|
var onSelect = _ref2.onSelect,
|
|
97
|
+
noResultsMessage = _ref2.noResultsMessage,
|
|
97
98
|
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
98
99
|
return /*#__PURE__*/_react.default.createElement(_Lookup.default, Object.assign({
|
|
99
100
|
name: "school_lookup",
|
|
@@ -101,12 +102,15 @@ var SimpleSchoolLookup = function SimpleSchoolLookup(_ref2) {
|
|
|
101
102
|
placeholder: "Enter name or postcode...",
|
|
102
103
|
buttonText: "Find school",
|
|
103
104
|
dropdownInstruction: "Please select an organisation from the list below",
|
|
104
|
-
noResultsMessage:
|
|
105
|
+
noResultsMessage: noResultsMessage,
|
|
105
106
|
lookupHandler: schoolFetcher,
|
|
106
107
|
mapOptionToString: schoolToString,
|
|
107
108
|
onSelect: onSelect
|
|
108
109
|
}, rest));
|
|
109
110
|
};
|
|
110
111
|
|
|
112
|
+
SimpleSchoolLookup.defaultProps = {
|
|
113
|
+
noResultsMessage: 'Sorry, we could not find anything matching your search; please use the manual entry option.'
|
|
114
|
+
};
|
|
111
115
|
var _default = SimpleSchoolLookup;
|
|
112
116
|
exports.default = _default;
|
|
@@ -8,12 +8,12 @@ import footerCopy from './data/footerCopy';
|
|
|
8
8
|
<p>Standard footer</p>
|
|
9
9
|
<Footer navItems={data} footerCopy={footerCopy.copy} campaign="Comic Relief" />
|
|
10
10
|
|
|
11
|
-
<p>Overrides
|
|
11
|
+
<p>Overrides allowList functionality for external usage</p>
|
|
12
12
|
<Footer
|
|
13
13
|
navItems={data}
|
|
14
14
|
footerCopy={footerCopy.copy}
|
|
15
15
|
campaign="Comic Relief"
|
|
16
|
-
|
|
16
|
+
overrideallowList
|
|
17
17
|
/>
|
|
18
18
|
|
|
19
19
|
<p>Adding a additionalLegalLine to the top of the footer</p>
|
|
@@ -1206,7 +1206,7 @@ exports[`renders correctly 1`] = `
|
|
|
1206
1206
|
color="white"
|
|
1207
1207
|
size="s"
|
|
1208
1208
|
>
|
|
1209
|
-
Test
|
|
1209
|
+
Test allowListed external link
|
|
1210
1210
|
</span>
|
|
1211
1211
|
</a>
|
|
1212
1212
|
</li>
|
|
@@ -1226,7 +1226,7 @@ exports[`renders correctly 1`] = `
|
|
|
1226
1226
|
color="white"
|
|
1227
1227
|
size="s"
|
|
1228
1228
|
>
|
|
1229
|
-
Test non-
|
|
1229
|
+
Test non-allowListed external link
|
|
1230
1230
|
</span>
|
|
1231
1231
|
<span
|
|
1232
1232
|
className="c24"
|
|
@@ -151,13 +151,13 @@ var _default = {
|
|
|
151
151
|
type: 'ContentfulComponentLink'
|
|
152
152
|
}
|
|
153
153
|
}, {
|
|
154
|
-
title: 'Test
|
|
154
|
+
title: 'Test allowListed external link',
|
|
155
155
|
url: 'https://www.sportrelief.com',
|
|
156
156
|
internal: {
|
|
157
157
|
type: 'ContentfulComponentLink'
|
|
158
158
|
}
|
|
159
159
|
}, {
|
|
160
|
-
title: 'Test non-
|
|
160
|
+
title: 'Test non-allowListed external link',
|
|
161
161
|
url: 'https://bing.com',
|
|
162
162
|
internal: {
|
|
163
163
|
type: 'ContentfulComponentLink'
|
|
@@ -23,7 +23,7 @@ var _navHelper = _interopRequireDefault(require("../../../../utils/navHelper"));
|
|
|
23
23
|
|
|
24
24
|
var _internalLinkHelper = require("../../../../utils/internalLinkHelper");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _allowListed = _interopRequireDefault(require("../../../../utils/allowListed"));
|
|
27
27
|
|
|
28
28
|
var _chevronDown = _interopRequireDefault(require("./chevron-down.svg"));
|
|
29
29
|
|
|
@@ -103,7 +103,7 @@ var MainNav = function MainNav(_ref) {
|
|
|
103
103
|
/* Determine which field represents our url path */
|
|
104
104
|
|
|
105
105
|
var thisUrl = (0, _navHelper.default)(thisFirstChild);
|
|
106
|
-
var relNoopener = !(0,
|
|
106
|
+
var relNoopener = !(0, _allowListed.default)(thisUrl) && 'noopener';
|
|
107
107
|
var hasSubMenu = group.links && group.links.length > 1;
|
|
108
108
|
var hasPopUp = hasSubMenu ? 'true' : null;
|
|
109
109
|
thisUrl = (0, _internalLinkHelper.InternalLinkHelper)(thisUrl);
|
|
@@ -126,13 +126,13 @@ var _default = {
|
|
|
126
126
|
title: 'External Links (menu group)',
|
|
127
127
|
id: 'eaec5191-bbb3-5e8d-b966-c53fff34998a',
|
|
128
128
|
links: [{
|
|
129
|
-
title: 'Test
|
|
129
|
+
title: 'Test allowListed external link',
|
|
130
130
|
url: 'https://www.sportrelief.com',
|
|
131
131
|
internal: {
|
|
132
132
|
type: 'ContentfulComponentLink'
|
|
133
133
|
}
|
|
134
134
|
}, {
|
|
135
|
-
title: 'Test non-
|
|
135
|
+
title: 'Test non-allowListed external link',
|
|
136
136
|
url: 'https://bing.com',
|
|
137
137
|
internal: {
|
|
138
138
|
type: 'ContentfulComponentLink'
|
package/dist/index.js
CHANGED
|
@@ -35,10 +35,10 @@ Object.defineProperty(exports, "zIndex", {
|
|
|
35
35
|
return _zIndex.default;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
Object.defineProperty(exports, "
|
|
38
|
+
Object.defineProperty(exports, "allowListed", {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
get: function get() {
|
|
41
|
-
return
|
|
41
|
+
return _allowListed.default;
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "spacing", {
|
|
@@ -406,7 +406,7 @@ var _hideVisually = _interopRequireDefault(require("./theme/shared/hideVisually"
|
|
|
406
406
|
|
|
407
407
|
var _zIndex = _interopRequireDefault(require("./theme/shared/zIndex"));
|
|
408
408
|
|
|
409
|
-
var
|
|
409
|
+
var _allowListed = _interopRequireDefault(require("./utils/allowListed"));
|
|
410
410
|
|
|
411
411
|
var _spacing = _interopRequireDefault(require("./theme/shared/spacing"));
|
|
412
412
|
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var allowList = ['https://giftaid.comicrelief.com', 'https://donation.comicrelief.com', 'https://www.comicrelief.com', 'https://www.sportrelief.com', 'https://app.beapplied.com/org/comic-relief', 'stories.comicrelief.com', 'https://form.typeform.com'];
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
if (url !== undefined && url !== null &&
|
|
9
|
+
var allowListed = function allowListed(url) {
|
|
10
|
+
if (url !== undefined && url !== null && allowList.some(function (v) {
|
|
11
11
|
return url.indexOf(v) >= 0;
|
|
12
12
|
})) {
|
|
13
13
|
return true;
|
|
@@ -16,5 +16,5 @@ var whiteListed = function whiteListed(url) {
|
|
|
16
16
|
return false;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
var _default =
|
|
19
|
+
var _default = allowListed;
|
|
20
20
|
exports.default = _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _allowListed = _interopRequireDefault(require("./allowListed"));
|
|
6
|
+
|
|
7
|
+
it('link is allowListed', function () {
|
|
8
|
+
expect((0, _allowListed.default)('https://www.comicrelief.com/home')).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('link is not allowListed', function () {
|
|
11
|
+
expect((0, _allowListed.default)('https://www.google.co.uk/')).toBe(false);
|
|
12
|
+
});
|
package/docs/utils.md
CHANGED
|
@@ -5,13 +5,13 @@ _Hide Visually_
|
|
|
5
5
|
how to use in your styled component
|
|
6
6
|
`export const Component = styled.span'${hideVisually};';`
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
_allowListed_
|
|
9
9
|
|
|
10
|
-
`import {
|
|
10
|
+
`import { allowListed } from '@comicrelief/component-library';`
|
|
11
11
|
|
|
12
|
-
`
|
|
12
|
+
`allowListed(url)`
|
|
13
13
|
|
|
14
|
-
Check if a url is
|
|
14
|
+
Check if a url is allowListed. Used to check links and change link target.
|
|
15
15
|
|
|
16
16
|
_Z Index_
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comicrelief/component-library",
|
|
3
3
|
"author": "Comic Relief Engineering Team",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.21.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"jest": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"cross-env": "^7.0.3",
|
|
78
|
-
"cypress": "
|
|
78
|
+
"cypress": "13.2.0",
|
|
79
79
|
"eslint": "^7.32.0",
|
|
80
80
|
"eslint-config-airbnb": "^18.2.0",
|
|
81
81
|
"eslint-plugin-import": "^2.27.5",
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import StyledLink, { HelperText, IconWrapper } from './Link.style';
|
|
5
|
-
import
|
|
5
|
+
import allowListed from '../../../utils/allowListed';
|
|
6
6
|
import { getDomain } from '../../../utils/internalLinkHelper';
|
|
7
7
|
|
|
8
8
|
let window = '';
|
|
@@ -22,7 +22,7 @@ const Link = ({
|
|
|
22
22
|
const [documentHost, setDocumentHost] = useState('');
|
|
23
23
|
/**
|
|
24
24
|
* If we haven't specifically set the target via props, check if
|
|
25
|
-
* this is an internal link OR on our
|
|
25
|
+
* this is an internal link OR on our allowList before making it a '_self' link
|
|
26
26
|
*/
|
|
27
27
|
if (target === null) {
|
|
28
28
|
// Use our helper function to determine the raw domains to compare
|
|
@@ -30,7 +30,7 @@ const Link = ({
|
|
|
30
30
|
const linkDomain = getDomain(href);
|
|
31
31
|
|
|
32
32
|
// Additional check for applications that need more control
|
|
33
|
-
const
|
|
33
|
+
const isallowListOverridden = rest.overrideallowList === true;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* If the link has no domain supplied (likely '/' or '#')
|
|
@@ -38,9 +38,9 @@ const Link = ({
|
|
|
38
38
|
* in a new tab
|
|
39
39
|
*/
|
|
40
40
|
const isExternalLink = linkDomain !== '' && (currentDomain !== linkDomain);
|
|
41
|
-
const
|
|
41
|
+
const isallowListed = allowListed(href);
|
|
42
42
|
|
|
43
|
-
window = isExternalLink && (
|
|
43
|
+
window = isExternalLink && (isallowListOverridden || !isallowListed) ? '_blank' : '_self';
|
|
44
44
|
} else {
|
|
45
45
|
window = target === 'blank' ? '_blank' : '_self';
|
|
46
46
|
}
|