@newskit-render/core 4.20.4 → 4.20.5-alpha.1

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.
@@ -0,0 +1,1077 @@
1
+ describe('Personal details without user', () => {
2
+ beforeEach(() => {
3
+ cy.mockConsentAndVisit('/account')
4
+ })
5
+
6
+ it('Should display default fallback values', () => {
7
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Profile')
8
+ // cy.get('[data-testid="ContentListItems"]').should('have.length', 3)
9
+ cy.contains('Name')
10
+ cy.contains('Please enter your name')
11
+ cy.contains('Date of birth')
12
+ cy.contains('Please call customer service on xxxx-xxx-xxxx')
13
+ cy.contains('Display name')
14
+ cy.contains('Please enter your display name')
15
+ cy.contains(
16
+ 'Your display name is used across our websites or apps when leaving comments on articles'
17
+ )
18
+
19
+ cy.contains(
20
+ '[data-testid="ContentListIntroduction"]',
21
+ 'Log in and Security'
22
+ )
23
+ // cy.get('[data-testid="ContentListItems"]').should('have.length', 2)
24
+ cy.contains('Email')
25
+ cy.contains('[email@address]')
26
+ cy.contains('Password')
27
+ cy.contains('******************')
28
+
29
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Contact details')
30
+ // cy.get('[data-testid="ContentListItems"]').should('have.length', 3)
31
+ cy.contains('Mobile phone')
32
+ cy.contains('Please enter your mobile telephone number')
33
+ cy.contains('Landline phone')
34
+ cy.contains('Please enter your landline telephone number')
35
+ cy.contains('Address')
36
+ cy.contains('Please enter your address')
37
+ })
38
+ })
39
+
40
+ describe('Personal details with account', () => {
41
+ beforeEach(() => {
42
+ cy.GetTnlAcsSession('digital')
43
+ cy.mockConsentAndVisit('/account')
44
+ })
45
+
46
+ it('Should display logged-in user data', () => {
47
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Profile')
48
+ cy.contains('Name')
49
+ cy.contains('John Smith')
50
+ cy.contains('Date of birth')
51
+ cy.contains('10/07/1989')
52
+ // cy.contains('Display name')
53
+ // cy.contains('JohnSmithNewsUK')
54
+
55
+ cy.contains(
56
+ '[data-testid="ContentListIntroduction"]',
57
+ 'Log in and Security'
58
+ )
59
+ cy.contains('Email')
60
+ cy.contains('cmp-digi-card-20-09-22@yopmail.com') //userMap.digital
61
+ cy.contains('Password')
62
+ cy.contains('******************')
63
+
64
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Contact details')
65
+ cy.contains('Mobile phone')
66
+ cy.contains('070 0012 3456')
67
+ cy.contains('Landline phone')
68
+ cy.contains('020 7782 6000')
69
+ cy.contains('Address')
70
+ cy.contains('News UK, 1 London Bridge Street, London, SE1 9GF')
71
+ })
72
+ })
73
+
74
+ describe('Personal detail edit pages', () => {
75
+ beforeEach(() => {
76
+ cy.GetTnlAcsSession('digital')
77
+ cy.mockConsentAndVisit('/account')
78
+ })
79
+
80
+ describe('Edit name', () => {
81
+ it('Should show user first and last name', () => {
82
+ cy.get('a[href="/account/edit/name"]').should('be.visible').click()
83
+
84
+ cy.contains('Edit your name')
85
+ cy.contains('label', 'First name')
86
+ cy.get('[name="firstName"]').should('have.value', 'John')
87
+ cy.contains('label', 'Last name')
88
+ cy.get('[name="lastName"]').should('have.value', 'Smith')
89
+ cy.contains(
90
+ 'Your name will only be used when we communicate with you directly. When making comments on our websites and apps, your ‘display name’ is used to protect your identity.'
91
+ )
92
+ cy.contains('[data-testid="primary-button"]', 'Save')
93
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
94
+
95
+ // Redirects to Personal details page
96
+ cy.get('[data-testid="secondary-button"]').click()
97
+ cy.location().should((loc) => {
98
+ expect(loc.pathname).to.eq('/account')
99
+ })
100
+ })
101
+ it('Should change user first and last name', () => {
102
+ cy.get('a[href="/account/edit/name"]').should('be.visible').click()
103
+
104
+ cy.get('[name="firstName"]').clear().type('John')
105
+ cy.get('[name="lastName"]').clear().type('Smith')
106
+ cy.get('[data-testid="primary-button"]').click()
107
+
108
+ cy.contains('[data-testid="toast-container"]', 'Updating your name...')
109
+
110
+ // Redirects to Personal details page
111
+ cy.location().should((loc) => {
112
+ expect(loc.pathname).to.eq('/account')
113
+ })
114
+ cy.contains('John Smith').should('have.length', 1)
115
+ cy.contains(
116
+ '[data-testid="toast-container"]',
117
+ 'Your name has been updated'
118
+ )
119
+ })
120
+ it('Should show input validation error messages when user tries to add invalid first or last name', () => {
121
+ cy.get('a[href="/account/edit/name"]').should('be.visible').click()
122
+
123
+ cy.get('[name="firstName"]').clear()
124
+ cy.get('[data-testid="primary-button"]').click()
125
+ cy.contains('Please enter your First Name')
126
+
127
+ cy.get('[name="firstName"]').clear().type('?')
128
+ cy.get('[data-testid="primary-button"]').click()
129
+ cy.contains(
130
+ 'Your first name can’t contain special characters. Please try again.'
131
+ )
132
+
133
+ cy.get('[name="firstName"]').clear().type('John1')
134
+ cy.get('[data-testid="primary-button"]').click()
135
+ cy.contains(
136
+ 'Your first name can’t contain special characters. Please try again.'
137
+ )
138
+
139
+ cy.get('[name="lastName"]').clear()
140
+ cy.get('[data-testid="primary-button"]').click()
141
+ cy.contains('Please enter your Last Name')
142
+
143
+ cy.get('[name="lastName"]').clear().type('?')
144
+ cy.get('[data-testid="primary-button"]').click()
145
+ cy.contains(
146
+ 'Your first name can’t contain special characters. Please try again.'
147
+ )
148
+
149
+ cy.get('[name="lastName"]').clear().type('Smith1')
150
+ cy.get('[data-testid="primary-button"]').click()
151
+ cy.contains(
152
+ 'Your first name can’t contain special characters. Please try again.'
153
+ )
154
+
155
+ //TODO: Is this a legacy validation - if yes, please remove?
156
+ // cy.contains(
157
+ // 'That doesn’t look right. Please check your First Name and try again.'
158
+ // ).should('not.exist')
159
+
160
+ // Does not save the data
161
+ cy.get('[data-testid="primary-button"]').click()
162
+ cy.contains(
163
+ '[data-testid="toast-container"]',
164
+ 'Updating your name...'
165
+ ).should('not.exist')
166
+ })
167
+ it('Should show error toast when updating name if internal server error occures', () => {
168
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
169
+
170
+ cy.get('a[href="/account/edit/name"]').should('be.visible').click()
171
+
172
+ cy.get('[name="firstName"]').clear().type('John')
173
+ cy.get('[name="lastName"]').clear().type('Smith')
174
+ cy.get('[data-testid="primary-button"]').click()
175
+
176
+ cy.contains('[data-testid="toast-container"]', 'Updating your name...')
177
+ cy.contains(
178
+ '[data-testid="toast-container"]',
179
+ "Sorry, we're unable to save your name right now. Please try again or come back later."
180
+ )
181
+ })
182
+ })
183
+
184
+ describe('Edit display name', () => {
185
+ it('Should show user display name', () => {
186
+ cy.get('a[href="/account/edit/displayName"]').should('be.visible').click()
187
+
188
+ cy.contains('Edit your display name')
189
+ cy.contains('label', 'Display name')
190
+ cy.get('[name="displayName"]').should('have.value', 'JohnSmithNewsUK')
191
+ cy.contains(
192
+ 'When making comments on our websites and apps, your ‘display name’ is used to protect your identity. Your name will only be used when we communicate with you directly.'
193
+ )
194
+ cy.contains('[data-testid="primary-button"]', 'Save')
195
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
196
+
197
+ // Redirects to Personal details page
198
+ cy.get('[data-testid="secondary-button"]').click()
199
+ cy.location().should((loc) => {
200
+ expect(loc.pathname).to.eq('/account')
201
+ })
202
+ })
203
+ it('Should change user display name', () => {
204
+ cy.get('a[href="/account/edit/displayName"]').should('be.visible').click()
205
+
206
+ cy.get('[name="displayName"]').clear().type('JohnSmithNewsUK')
207
+ cy.get('[data-testid="primary-button"]').click()
208
+
209
+ cy.contains(
210
+ '[data-testid="toast-container"]',
211
+ 'Updating your display name...'
212
+ )
213
+
214
+ // Redirects to Personal details page
215
+ cy.location().should((loc) => {
216
+ expect(loc.pathname).to.eq('/account')
217
+ })
218
+ // cy.contains('JohnSmithNewsUK').should('have.length', 1)
219
+ cy.contains(
220
+ '[data-testid="toast-container"]',
221
+ 'Your display name has been updated.'
222
+ )
223
+ })
224
+ it('Should show input validation error messages when user tries to add invalid display name', () => {
225
+ cy.get('a[href="/account/edit/displayName"]').should('be.visible').click()
226
+
227
+ cy.get('[name="displayName"]').clear()
228
+ cy.get('[data-testid="primary-button"]').click()
229
+ cy.contains('Please enter your Display Name')
230
+
231
+ cy.get('[name="displayName"]').clear().type('?')
232
+ cy.get('[data-testid="primary-button"]').click()
233
+ cy.contains(
234
+ 'Your Display name can only contain alphanumeric characters, hyphens, apostrophes and spaces'
235
+ )
236
+
237
+ // Does not save the data
238
+ cy.get('[data-testid="primary-button"]').click()
239
+ cy.contains(
240
+ '[data-testid="toast-container"]',
241
+ 'Updating your name...'
242
+ ).should('not.exist')
243
+
244
+ // Accepts numeric data
245
+ cy.get('[name="displayName"]').clear().type('JohnSmithNewsUK1')
246
+ cy.get('[name="displayName"]').blur()
247
+ cy.contains(
248
+ 'Your Display name can only contain alphanumeric characters, hyphens, apostrophes and spaces'
249
+ ).should('not.exist')
250
+ })
251
+ it('Should show error toast when updating display name if internal server error occures', () => {
252
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
253
+
254
+ cy.get('a[href="/account/edit/displayName"]').should('be.visible').click()
255
+
256
+ cy.get('[name="displayName"]').clear().type('JohnSmithNewsUK')
257
+ cy.get('[data-testid="primary-button"]').click()
258
+
259
+ cy.contains(
260
+ '[data-testid="toast-container"]',
261
+ 'Updating your display name...'
262
+ )
263
+ cy.contains(
264
+ '[data-testid="toast-container"]',
265
+ "Sorry, we're unable to save your display name right now. Please try again or come back later."
266
+ )
267
+ })
268
+ })
269
+
270
+ describe('Edit email', () => {
271
+ it('Should show user email', () => {
272
+ cy.get('a[href="/account/edit/email"]').should('be.visible').click()
273
+
274
+ cy.contains('Edit your email address')
275
+ cy.contains(
276
+ "Enter the new email address below that you'd like your account to be registered with. We'll send a verification link to that email address and this process could take a few minutes."
277
+ )
278
+
279
+ cy.contains('label', 'Email address')
280
+ cy.get('[name="email"]').should(
281
+ 'have.value',
282
+ 'cmp-digi-card-20-09-22@yopmail.com'
283
+ )
284
+
285
+ cy.contains('[data-testid="primary-button"]', 'Save')
286
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
287
+
288
+ // Redirects to Personal details page
289
+ cy.get('[data-testid="secondary-button"]').click()
290
+ cy.location().should((loc) => {
291
+ expect(loc.pathname).to.eq('/account')
292
+ })
293
+ })
294
+ it('Should change user email', () => {
295
+ const currentEmail = 'cmp-digi-card-20-09-22@yopmail.com'
296
+ const notRegistredEmail = 'not-registered-email@yopmail.com'
297
+
298
+ cy.get('a[href="/account/edit/email"]').should('be.visible').click()
299
+
300
+ cy.get('[name="email"]').clear().type(notRegistredEmail)
301
+ cy.get('[data-testid="primary-button"]').click()
302
+
303
+ cy.contains('[data-testid="toast-container"]', 'Updating your email...')
304
+
305
+ // Redirects to Personal details page
306
+ cy.location().should((loc) => {
307
+ expect(loc.pathname).to.eq('/account')
308
+ })
309
+ cy.contains(notRegistredEmail).should('have.length', 1)
310
+ cy.contains(
311
+ '[data-testid="toast-container"]',
312
+ 'Your email address was successfully updated'
313
+ )
314
+
315
+ // Back to edit email page
316
+
317
+ cy.get('a[href="/account/edit/email"]')
318
+ .should('be.visible')
319
+ .click({ force: true })
320
+
321
+ // Check the message for verification link
322
+ cy.contains(
323
+ `Email sent to ${notRegistredEmail} with a verification link. If you haven't received it yet, check again later or contact customer services on xxxx-xxx-xxxx`
324
+ )
325
+
326
+ // Change email back to the previous email
327
+ cy.get('[name="email"]').clear().type(currentEmail)
328
+ cy.get('[data-testid="primary-button"]').click()
329
+ })
330
+ it('Should NOT change user email if input value is already registered mail', () => {
331
+ const alreadyRegistredEmail = 'cmp-digi-direct-20-09-22@yopmail.com'
332
+
333
+ cy.get('a[href="/account/edit/email"]').should('be.visible').click()
334
+
335
+ cy.get('[name="email"]').clear().type(alreadyRegistredEmail)
336
+ cy.get('[data-testid="primary-button"]').click()
337
+
338
+ cy.contains('[data-testid="toast-container"]', 'Updating your email...')
339
+ cy.contains(
340
+ '[data-testid="toast-container"]',
341
+ 'This email address is already in use. Try a different one or contact customer support at 1234-1234'
342
+ )
343
+ })
344
+ it('Should show input validation error messages when user tries to add invalid email', () => {
345
+ cy.get('a[href="/account/edit/email"]').should('be.visible').click()
346
+
347
+ cy.get('[name="email"]').clear()
348
+ cy.get('[data-testid="primary-button"]').click()
349
+ cy.contains('Please enter your Email address')
350
+
351
+ cy.get('[name="email"]').clear().type('invalid-email@news')
352
+ cy.get('[data-testid="primary-button"]').click()
353
+ cy.contains(
354
+ 'That doesn’t look like a valid email address. Please try again.'
355
+ )
356
+
357
+ // Does not save the data
358
+ cy.get('[data-testid="primary-button"]').click()
359
+ cy.contains(
360
+ '[data-testid="toast-container"]',
361
+ 'Updating your email...'
362
+ ).should('not.exist')
363
+ })
364
+ it('Should show error toast when updating email if internal server error occures', () => {
365
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
366
+
367
+ cy.get('a[href="/account/edit/email"]').should('be.visible').click()
368
+
369
+ cy.get('[name="email"]').clear().type('valid-email@news.co.uk')
370
+ cy.get('[data-testid="primary-button"]').click()
371
+
372
+ cy.contains('[data-testid="toast-container"]', 'Updating your email...')
373
+ cy.contains(
374
+ '[data-testid="toast-container"]',
375
+ "Sorry, we're unable to save your email right now. Please try again or come back later."
376
+ )
377
+ })
378
+ })
379
+
380
+ describe('Edit password', () => {
381
+ it('Should show user password page', () => {
382
+ cy.get('a[href="/account/edit/password"]').should('be.visible').click()
383
+
384
+ cy.contains('Reset your password')
385
+ cy.contains(
386
+ 'For added security, we’ll send a password reset link to the email address that your account is registered with.'
387
+ )
388
+ cy.contains(
389
+ 'The link can only be used once and expires after 15 minutes.'
390
+ )
391
+
392
+ cy.contains('[data-testid="primary-button"]', 'Send link')
393
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
394
+
395
+ // Redirects to Personal details page
396
+ cy.get('[data-testid="secondary-button"]').click()
397
+ cy.location().should((loc) => {
398
+ expect(loc.pathname).to.eq('/account')
399
+ })
400
+ })
401
+ it('Should reset user password', () => {
402
+ const currentEmail = 'cmp-digi-card-20-09-22@yopmail.com'
403
+
404
+ cy.get('a[href="/account/edit/password"]').should('be.visible').click()
405
+
406
+ cy.get('[data-testid="primary-button"]').click()
407
+
408
+ // cy.contains('[data-testid="toast-container"]', 'Resetting your password...')
409
+
410
+ // Redirects to Personal details page
411
+ cy.location().should((loc) => {
412
+ expect(loc.pathname).to.eq('/account')
413
+ })
414
+ cy.contains('******************').should('have.length', 1)
415
+ cy.contains(
416
+ '[data-testid="toast-container"]',
417
+ 'Email sent with a password reset link'
418
+ )
419
+
420
+ // Go back to password page
421
+ cy.get('a[href="/account/edit/password"]')
422
+ .should('be.visible')
423
+ .click({ force: true })
424
+
425
+ cy.contains(
426
+ `Email sent to ${currentEmail} with a password reset link. If you haven’t received it in a couple of minutes, you may request a new link by clicking on the button below.`
427
+ )
428
+ cy.contains('[data-testid="primary-button"]', 'Resend link')
429
+ })
430
+ it.skip('Should show error toast when resetting password if internal server error occures', () => {
431
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
432
+
433
+ cy.get('a[href="/account/edit/password"]').should('be.visible').click()
434
+
435
+ cy.get('[data-testid="primary-button"]').click()
436
+
437
+ // cy.contains('[data-testid="toast-container"]', 'Resetting your password...')
438
+ cy.contains(
439
+ '[data-testid="toast-container"]',
440
+ "Sorry, we're unable to reset your password right now. Please try again or come back later."
441
+ )
442
+ })
443
+ })
444
+
445
+ describe('Edit mobile phone', () => {
446
+ it('Should show user mobile number', () => {
447
+ cy.get('a[href="/account/edit/mobile"]').should('be.visible').click()
448
+
449
+ cy.contains('Edit your mobile number')
450
+ cy.contains('label', 'Mobile phone number')
451
+ cy.get('[name="mobileCountry"]').should('have.value', 'GB')
452
+ cy.get('.PhoneInputCountryIconImg').should(
453
+ 'have.attr',
454
+ 'alt',
455
+ 'United Kingdom'
456
+ )
457
+ cy.get('[name="mobile"]').should('have.value', '070 0012 3456')
458
+
459
+ cy.contains('[data-testid="primary-button"]', 'Save')
460
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
461
+
462
+ // Redirects to Personal details page
463
+ cy.get('[data-testid="secondary-button"]').click()
464
+ cy.location().should((loc) => {
465
+ expect(loc.pathname).to.eq('/account')
466
+ })
467
+ })
468
+ it('Should change user mobile number', () => {
469
+ cy.get('a[href="/account/edit/mobile"]').should('be.visible').click()
470
+
471
+ cy.get('[name="mobileCountry"]').select('United Kingdom')
472
+ cy.get('[name="mobile"]').clear().type('070 0012 3456')
473
+ cy.get('[data-testid="primary-button"]').click()
474
+
475
+ cy.contains(
476
+ '[data-testid="toast-container"]',
477
+ 'Updating your mobile telephone number...'
478
+ )
479
+
480
+ // Redirects to Personal details page
481
+ cy.location().should((loc) => {
482
+ expect(loc.pathname).to.eq('/account')
483
+ })
484
+ cy.contains('070 0012 3456').should('have.length', 1)
485
+ cy.contains(
486
+ '[data-testid="toast-container"]',
487
+ 'Your mobile telephone number has been updated.'
488
+ )
489
+ })
490
+ it('Should show input validation error messages when user tries to add invalid mobile number', () => {
491
+ cy.get('a[href="/account/edit/mobile"]').should('be.visible').click()
492
+
493
+ cy.get('[name="mobileCountry"]').select('Ireland')
494
+ cy.get('.PhoneInputCountryIconImg').should('have.attr', 'alt', 'Ireland')
495
+
496
+ cy.get('[name="mobile"]').clear()
497
+ cy.get('[data-testid="primary-button"]').click()
498
+ cy.contains('Please enter your mobile telephone number')
499
+
500
+ cy.get('[name="mobile"]').clear().type('stringdata?')
501
+ cy.get('[data-testid="primary-button"]').click()
502
+ cy.get('[name="mobile"]').should('have.value', '')
503
+
504
+ cy.get('[name="mobile"]').clear().type('435345')
505
+ cy.get('[data-testid="primary-button"]').click()
506
+ cy.contains(
507
+ 'That doesn’t look like a valid phone number. Please try again.'
508
+ )
509
+
510
+ // Does not save the data
511
+ cy.get('[data-testid="primary-button"]').click()
512
+ cy.contains(
513
+ '[data-testid="toast-container"]',
514
+ 'Updating your mobile telephone number...'
515
+ ).should('not.exist')
516
+ })
517
+ it('Should show error toast when updating mobile number if internal server error occures', () => {
518
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
519
+
520
+ cy.get('a[href="/account/edit/mobile"]').should('be.visible').click()
521
+
522
+ cy.get('[name="mobile"]').clear().type('070 0012 3456')
523
+ cy.get('[data-testid="primary-button"]').click()
524
+
525
+ cy.contains(
526
+ '[data-testid="toast-container"]',
527
+ 'Updating your mobile telephone number...'
528
+ )
529
+ cy.contains(
530
+ '[data-testid="toast-container"]',
531
+ "Sorry, we're unable to save your mobile telephone number right now. Please try again or come back later."
532
+ )
533
+ })
534
+ })
535
+
536
+ describe('Edit landline phone', () => {
537
+ it('Should show user landline number', () => {
538
+ cy.get('a[href="/account/edit/landline"]').should('be.visible').click()
539
+
540
+ cy.contains('Edit your landline number')
541
+ cy.contains('label', 'Landline phone number')
542
+ cy.get('[name="phoneNumberCountry"]').should('have.value', 'GB')
543
+ cy.get('.PhoneInputCountryIconImg').should(
544
+ 'have.attr',
545
+ 'alt',
546
+ 'United Kingdom'
547
+ )
548
+ cy.get('[name="phoneNumber"]').should('have.value', '020 7782 6000')
549
+
550
+ cy.contains('[data-testid="primary-button"]', 'Save')
551
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
552
+
553
+ // Redirects to Personal details page
554
+ cy.get('[data-testid="secondary-button"]').click()
555
+ cy.location().should((loc) => {
556
+ expect(loc.pathname).to.eq('/account')
557
+ })
558
+ })
559
+ it('Should change user landline number', () => {
560
+ cy.get('a[href="/account/edit/landline"]').should('be.visible').click()
561
+
562
+ cy.get('[name="phoneNumberCountry"]').select('United Kingdom')
563
+ cy.get('[name="phoneNumber"]').clear().type('020 7782 6000')
564
+ cy.get('[data-testid="primary-button"]').click()
565
+
566
+ cy.contains(
567
+ '[data-testid="toast-container"]',
568
+ 'Updating your landline telephone number...'
569
+ )
570
+
571
+ // Redirects to Personal details page
572
+ cy.location().should((loc) => {
573
+ expect(loc.pathname).to.eq('/account')
574
+ })
575
+ cy.contains('020 7782 6000').should('have.length', 1)
576
+ cy.contains(
577
+ '[data-testid="toast-container"]',
578
+ 'Your landline telephone number has been updated.'
579
+ )
580
+ })
581
+ it('Should show input validation error messages when user tries to add invalid landline number', () => {
582
+ cy.get('a[href="/account/edit/landline"]').should('be.visible').click()
583
+
584
+ cy.get('[name="phoneNumberCountry"]').select('Ireland')
585
+ cy.get('.PhoneInputCountryIconImg').should('have.attr', 'alt', 'Ireland')
586
+
587
+ cy.get('[name="phoneNumber"]').clear()
588
+ cy.get('[data-testid="primary-button"]').click()
589
+ cy.contains('Please enter your landline telephone number')
590
+
591
+ cy.get('[name="phoneNumber"]').clear().type('stringdata?')
592
+ cy.get('[data-testid="primary-button"]').click()
593
+ cy.get('[name="phoneNumber"]').should('have.value', '')
594
+
595
+ // cy.get('[name="phoneNumber"]').click().type('07777 777778')
596
+ // cy.get('[data-testid="primary-button"]').click()
597
+ // cy.contains(
598
+ // 'That doesn’t look like a valid phone number. Please try again.'
599
+ // )
600
+
601
+ // Does not save the data
602
+ cy.get('[data-testid="primary-button"]').click()
603
+ cy.contains(
604
+ '[data-testid="toast-container"]',
605
+ 'Updating your landline telephone number...'
606
+ ).should('not.exist')
607
+ })
608
+ it('Should show error toast when updating landline number if internal server error occures', () => {
609
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
610
+
611
+ cy.get('a[href="/account/edit/landline"]').should('be.visible').click()
612
+
613
+ cy.get('[name="phoneNumber"]').clear().type('020 7782 6000')
614
+ cy.get('[data-testid="primary-button"]').click()
615
+
616
+ cy.contains(
617
+ '[data-testid="toast-container"]',
618
+ 'Updating your landline telephone number...'
619
+ )
620
+ cy.contains(
621
+ '[data-testid="toast-container"]',
622
+ "Sorry, we're unable to save your landline telephone number right now. Please try again or come back later."
623
+ )
624
+ })
625
+ })
626
+
627
+ describe('Edit address', () => {
628
+ it('Should show user address', () => {
629
+ cy.get('a[href="/account/edit/address"]').should('be.visible').click()
630
+
631
+ cy.contains('Edit your address')
632
+ //LOQATE
633
+ cy.contains('Start typing your address or postcode')
634
+ cy.get('input[name="search"]').should('have.value', '')
635
+ cy.contains("Can't find your address? Enter it manually below.")
636
+ //END OF LOQATE
637
+ cy.contains('label', 'Address line 1')
638
+ cy.get('input[name="line1"]').should('have.value', 'News UK')
639
+ cy.contains('Or company name')
640
+ cy.contains('label', 'Address line 2 (optional)')
641
+ cy.get('input[name="line2"]').should(
642
+ 'have.value',
643
+ '1 London Bridge Street'
644
+ )
645
+ cy.contains('label', 'Address line 3 (optional)')
646
+ cy.get('input[name="line3"]').should('have.value', '')
647
+ cy.contains('label', 'Town/City')
648
+ cy.get('input[name="city"]').should('have.value', 'London')
649
+ cy.contains('label', 'County (optional)')
650
+ cy.get('input[name="county"]').should('have.value', '')
651
+ cy.contains('label', 'Postcode')
652
+ cy.get('input[name="postcode"]').should('have.value', 'SE1 9GF')
653
+ cy.contains('label', 'Country')
654
+ cy.get('button[name="country"]').should('contain', 'United Kingdom')
655
+
656
+ cy.contains('[data-testid="primary-button"]', 'Save')
657
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
658
+
659
+ // Redirects to Personal details page
660
+ cy.get('[data-testid="secondary-button"]').click()
661
+ cy.location().should((loc) => {
662
+ expect(loc.pathname).to.eq('/account')
663
+ })
664
+ })
665
+
666
+ it('Should change user address', () => {
667
+ cy.get('a[href="/account/edit/address"]').should('be.visible').click()
668
+
669
+ cy.get('input[name="line1"]').clear().type('News UK')
670
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
671
+ // cy.get('input[name="line3"]').clear().type('')
672
+ cy.get('input[name="city"]').clear().type('London')
673
+ // cy.get('input[name="county"]').clear().type('')
674
+ cy.get('input[name="postcode"]').clear().type('SE1 9GF')
675
+ cy.get('button[name="country"]').click()
676
+ cy.get('[data-testid="United Kingdom"]').first().click() //Why first?
677
+
678
+ cy.get('[data-testid="primary-button"]').click()
679
+
680
+ cy.contains('[data-testid="toast-container"]', 'Updating your address...')
681
+
682
+ // Redirects to Personal details page
683
+ cy.location().should((loc) => {
684
+ expect(loc.pathname).to.eq('/account')
685
+ })
686
+ cy.contains('News UK, 1 London Bridge Street, London, SE1 9GF').should(
687
+ 'have.length',
688
+ 1
689
+ )
690
+
691
+ cy.get('a[href="/account/edit/address"]')
692
+ .children()
693
+ .should('contain', 'News UK')
694
+ .and('contain', '1 London Bridge Street')
695
+ .and('contain', 'London')
696
+ .and('contain', 'SE1 9GF')
697
+
698
+ cy.contains(
699
+ '[data-testid="toast-container"]',
700
+ 'Your address was successfully updated'
701
+ )
702
+ })
703
+
704
+ it.skip('Should search for address and automatically populate it', () => {
705
+ cy.get('a[href="/account/edit/address"]').should('be.visible').click()
706
+
707
+ cy.get('input[name="line1"]').clear()
708
+ cy.get('input[name="line2"]').clear()
709
+ cy.get('input[name="line3"]').clear()
710
+ cy.get('input[name="city"]').clear()
711
+ cy.get('input[name="county"]').clear()
712
+ cy.get('input[name="postcode"]').clear()
713
+ cy.get('button[name="country"]').click() // How to clear the country?
714
+ cy.get('[data-testid="Antarctica"]').click()
715
+
716
+ cy.get('input[name="search"]').clear().type('SE1 9GF')
717
+ cy.get('.pcadescription').click({ multiple: true })
718
+ cy.contains('News UK, 1 London Bridge Street').click()
719
+
720
+ cy.get('input[name="search"]').should(
721
+ 'have.value',
722
+ 'News UK, 1 London Bridge Street, LONDON, SE1 9GF, UNITED KINGDOM'
723
+ )
724
+ cy.get('input[name="line1"]').should('have.value', 'News UK')
725
+ cy.get('input[name="line2"]').should(
726
+ 'have.value',
727
+ '1 London Bridge Street'
728
+ )
729
+ cy.get('input[name="line3"]').should('have.value', '')
730
+ cy.get('input[name="city"]').should('have.value', 'London')
731
+ cy.get('input[name="county"]').should('have.value', '')
732
+ cy.get('input[name="postcode"]').should('have.value', 'SE1 9GF')
733
+ cy.get('button[name="country"]').should('contain', 'United Kingdom')
734
+
735
+ // cy.get('[data-testid="primary-button"]').click()
736
+
737
+ cy.contains('[data-testid="toast-container"]', 'Updating your address...')
738
+
739
+ // Redirects to Personal details page
740
+ cy.location().should((loc) => {
741
+ expect(loc.pathname).to.eq('/account')
742
+ })
743
+ cy.contains('News UK, 1 London Bridge Street, London, SE1 9GF').should(
744
+ 'have.length',
745
+ 1
746
+ )
747
+
748
+ cy.contains(
749
+ '[data-testid="toast-container"]',
750
+ 'Your address was successfully updated'
751
+ )
752
+ })
753
+
754
+ it('Should show input validation error messages when user tries to add invalid address', () => {
755
+ cy.get('a[href="/account/edit/address"]').should('be.visible').click()
756
+
757
+ cy.get('input[name="line1"]').clear().blur()
758
+ cy.contains('Please enter your first line of your address')
759
+ cy.get('input[name="line2"]').clear().blur()
760
+ cy.get('input[name="line3"]').clear().blur()
761
+ cy.get('input[name="city"]').clear().blur()
762
+ cy.contains('Please enter your Town/City')
763
+ cy.get('input[name="postcode"]').clear().blur()
764
+ cy.contains('Please enter your Postcode')
765
+
766
+ //TODO: What kind of other validations exist in the form address?
767
+ // cy.contains(
768
+ // 'Your address can’t contain special characters. Please try again.'
769
+ // )
770
+
771
+ // Does not save the data
772
+ cy.get('[data-testid="primary-button"]').click()
773
+ cy.contains(
774
+ '[data-testid="toast-container"]',
775
+ 'Updating your address...'
776
+ ).should('not.exist')
777
+ })
778
+
779
+ it('Should show error toast when updating address and internal server error occures', () => {
780
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
781
+
782
+ cy.get('a[href="/account/edit/address"]').should('be.visible').click()
783
+
784
+ cy.get('input[name="line1"]').clear().type('News UK')
785
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
786
+ cy.get('input[name="city"]').clear().type('London')
787
+ cy.get('input[name="postcode"]').clear().type('SE1 9GF')
788
+ cy.get('button[name="country"]').click()
789
+ cy.get('[data-testid="United Kingdom"]').first().click() //Why first?
790
+
791
+ cy.get('[data-testid="primary-button"]').click()
792
+
793
+ cy.contains('[data-testid="toast-container"]', 'Updating your address...')
794
+ cy.contains(
795
+ '[data-testid="toast-container"]',
796
+ "Sorry, we're unable to save your address right now. Please try again or come back later."
797
+ )
798
+ })
799
+
800
+ it('Should show modal when selected country is not UK, Isle of Man, Guernsey or Jersey and user has print with vouchers subscription', () => {
801
+ cy.GetTnlAcsSession('printVouchers')
802
+ cy.mockConsentAndVisit('/account/edit/address')
803
+
804
+ cy.get('input[name="line1"]').clear().type('620 Atlantic Ave')
805
+ cy.get('input[name="line2"]').clear().type('Brooklyn')
806
+ cy.get('input[name="city"]').clear().type('New York')
807
+ cy.get('input[name="postcode"]').clear().type('11217')
808
+
809
+ cy.get('[data-testid="select-country"]').click()
810
+ cy.get('[data-testid="United Kingdom"]').should('be.visible')
811
+
812
+ cy.get('[data-testid="United States of America"]').click()
813
+
814
+ cy.contains('Save').click()
815
+
816
+ cy.get('[data-testid="modal"]')
817
+ .should('exist')
818
+ .should('have.length.of.at.most', 1)
819
+ cy.contains(
820
+ '[data-testid="introduction-title"]',
821
+ 'Address Outside Delivery Area'
822
+ ).should('exist')
823
+ cy.contains(
824
+ '[data-testid="description-block"]',
825
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
826
+ ).should('exist')
827
+ cy.contains('[data-testid="primary-button"]', 'Return to My Account')
828
+ .should('exist')
829
+ .click()
830
+ cy.contains(
831
+ '[data-testid="toast-container"]',
832
+ 'As your new address is outside of our delivery area it has not been updated.'
833
+ )
834
+ cy.url().should('eq', 'http://localhost:3000/account')
835
+ })
836
+
837
+ it('Should show modal when selected country is UK but postcode is outside delivery area and user has print subscription', () => {
838
+ cy.GetTnlAcsSession('print')
839
+ cy.mockConsentAndVisit('/account')
840
+
841
+ cy.get('a[href="/account/edit/address"]').click()
842
+
843
+ cy.get('input[name="line1"]').clear().type('Buckingham Palace')
844
+ cy.get('input[name="city"]').clear().type('London')
845
+ cy.get('input[name="postcode"]').clear().type('SW1A')
846
+
847
+ cy.contains('Save').click()
848
+
849
+ cy.get('[data-testid="modal"]')
850
+ .should('exist')
851
+ .should('have.length.of.at.most', 1)
852
+ cy.contains(
853
+ '[data-testid="introduction-title"]',
854
+ 'Address Outside Delivery Area'
855
+ ).should('exist')
856
+ cy.contains(
857
+ '[data-testid="description-block"]',
858
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
859
+ ).should('exist')
860
+ cy.contains('[data-testid="primary-button"]', 'Return to My Account')
861
+ .should('exist')
862
+ .click()
863
+ cy.contains(
864
+ '[data-testid="toast-container"]',
865
+ 'As your new address is outside of our delivery area it has not been updated.'
866
+ )
867
+ cy.url().should('eq', 'http://localhost:3000/account')
868
+ })
869
+
870
+ it('Should show modal when selected country is UK but postcode is outside delivery area and user has digi-print subscription', () => {
871
+ cy.GetTnlAcsSession('digiprint')
872
+ cy.mockConsentAndVisit('/account')
873
+
874
+ cy.get('a[href="/account/edit/address"]').click()
875
+
876
+ cy.get('input[name="line1"]').clear().type('1 London Bridge Street')
877
+ cy.get('input[name="city"]').clear().type('London')
878
+ cy.get('input[name="postcode"]').clear().type('SE1')
879
+
880
+ cy.contains('Save').click()
881
+
882
+ cy.get('[data-testid="modal"]')
883
+ .should('exist')
884
+ .should('have.length.of.at.most', 1)
885
+ cy.contains(
886
+ '[data-testid="introduction-title"]',
887
+ 'Address Outside Delivery Area'
888
+ ).should('exist')
889
+ cy.contains(
890
+ '[data-testid="description-block"]',
891
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
892
+ ).should('exist')
893
+ cy.contains('[data-testid="primary-button"]', 'Return to My Account')
894
+ .should('exist')
895
+ .click()
896
+ cy.contains(
897
+ '[data-testid="toast-container"]',
898
+ 'As your new address is outside of our delivery area it has not been updated.'
899
+ )
900
+ cy.url().should('eq', 'http://localhost:3000/account')
901
+ })
902
+
903
+ it('Should show modal when selected country is not UK, Isle of Man, Guernsey or Jersey and user has digi-print with vouchers subscription', () => {
904
+ cy.GetTnlAcsSession('digiprintVouchers')
905
+ cy.mockConsentAndVisit('/account/edit/address')
906
+
907
+ cy.get('input[name="line1"]').clear().type('620 Atlantic Ave')
908
+ cy.get('input[name="line2"]').clear().type('Brooklyn')
909
+ cy.get('input[name="city"]').clear().type('New York')
910
+ cy.get('input[name="postcode"]').clear().type('11217')
911
+
912
+ cy.get('[data-testid="select-country"]').click()
913
+ cy.get('[data-testid="United Kingdom"]').should('be.visible')
914
+
915
+ cy.get('[data-testid="United States of America"]').click()
916
+
917
+ cy.contains('Save').click()
918
+
919
+ cy.get('[data-testid="modal"]')
920
+ .should('exist')
921
+ .should('have.length.of.at.most', 1)
922
+ cy.contains(
923
+ '[data-testid="introduction-title"]',
924
+ 'Address Outside Delivery Area'
925
+ ).should('exist')
926
+ cy.contains(
927
+ '[data-testid="description-block"]',
928
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
929
+ ).should('exist')
930
+ cy.contains('[data-testid="primary-button"]', 'Return to My Account')
931
+ .should('exist')
932
+ .click()
933
+ cy.contains(
934
+ '[data-testid="toast-container"]',
935
+ 'As your new address is outside of our delivery area it has not been updated.'
936
+ )
937
+ cy.url().should('eq', 'http://localhost:3000/account')
938
+ })
939
+
940
+ it('Should not show modal when selected country is UK and user has print with vouchers subscription', () => {
941
+ cy.GetTnlAcsSession('printVouchers')
942
+ cy.mockConsentAndVisit('/account')
943
+
944
+ cy.get('a[href="/account/edit/address"]').click()
945
+
946
+ cy.get('input[name="line1"]').clear().type('2 Tuke House')
947
+ cy.get('input[name="line2"]').clear().type('Cromwell Road')
948
+ cy.get('input[name="city"]').clear().type('York')
949
+ cy.get('input[name="county"]').clear().type('North Yorkshire')
950
+ cy.get('input[name="postcode"]').clear().type('YO1 6DJ')
951
+
952
+ cy.contains('Save').click()
953
+
954
+ cy.get('[data-testid="modal"]').should('not.exist')
955
+ cy.contains(
956
+ '[data-testid="introduction-title"]',
957
+ 'Address Outside Delivery Area'
958
+ ).should('not.exist')
959
+ cy.contains(
960
+ '[data-testid="description-block"]',
961
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
962
+ ).should('not.exist')
963
+ cy.contains(
964
+ '[data-testid="primary-button"]',
965
+ 'Return to My Account'
966
+ ).should('not.exist')
967
+ cy.contains(
968
+ '[data-testid="toast-container"]',
969
+ 'Your address was successfully updated'
970
+ )
971
+ cy.url().should('eq', 'http://localhost:3000/account')
972
+ })
973
+
974
+ it('Should not show modal when selected country is UK and user has digi-print with vouchers subscription', () => {
975
+ cy.GetTnlAcsSession('digiprintVouchers')
976
+ cy.mockConsentAndVisit('/account')
977
+
978
+ cy.get('a[href="/account/edit/address"]').click()
979
+
980
+ cy.get('input[name="line1"]').clear().type('Harpercollins Publishers')
981
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
982
+ cy.get('input[name="city"]').clear().type('London')
983
+ cy.get('input[name="postcode"]').clear().type('SE1')
984
+
985
+ cy.contains('Save').click()
986
+
987
+ cy.get('[data-testid="modal"]').should('not.exist')
988
+ cy.contains(
989
+ '[data-testid="introduction-title"]',
990
+ 'Address Outside Delivery Area'
991
+ ).should('not.exist')
992
+ cy.contains(
993
+ '[data-testid="description-block"]',
994
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
995
+ ).should('not.exist')
996
+ cy.contains(
997
+ '[data-testid="primary-button"]',
998
+ 'Return to My Account'
999
+ ).should('not.exist')
1000
+ cy.contains(
1001
+ '[data-testid="toast-container"]',
1002
+ 'Your address was successfully updated'
1003
+ )
1004
+ cy.url().should('eq', 'http://localhost:3000/account')
1005
+ })
1006
+
1007
+ it('Should not show modal when selected country is UK, postcode is outside delivery area and user has digital subscription', () => {
1008
+ cy.GetTnlAcsSession('tnl')
1009
+ cy.mockConsentAndVisit('/account')
1010
+
1011
+ cy.get('a[href="/account/edit/address"]').click()
1012
+
1013
+ cy.get('input[name="line1"]').clear().type('News UK')
1014
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
1015
+ cy.get('input[name="city"]').clear().type('London')
1016
+ cy.get('input[name="postcode"]').clear().type('SE1')
1017
+
1018
+ cy.contains('Save').click()
1019
+
1020
+ cy.get('[data-testid="modal"]').should('not.exist')
1021
+ cy.contains(
1022
+ '[data-testid="introduction-title"]',
1023
+ 'Address Outside Delivery Area'
1024
+ ).should('not.exist')
1025
+ cy.contains(
1026
+ '[data-testid="description-block"]',
1027
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
1028
+ ).should('not.exist')
1029
+ cy.contains(
1030
+ '[data-testid="primary-button"]',
1031
+ 'Return to My Account'
1032
+ ).should('not.exist')
1033
+ cy.contains(
1034
+ '[data-testid="toast-container"]',
1035
+ 'Your address was successfully updated'
1036
+ )
1037
+ cy.url().should('eq', 'http://localhost:3000/account')
1038
+ })
1039
+
1040
+ it('Should not show modal when selected country is not UK, Isle of Man, Guernsey or Jersey and user has digital subscription', () => {
1041
+ cy.mockConsentAndVisit('/account')
1042
+
1043
+ cy.get('a[href="/account/edit/address"]').click()
1044
+
1045
+ cy.get('input[name="line1"]').clear().type('620 Atlantic Ave')
1046
+ cy.get('input[name="line2"]').clear().type('Brooklyn')
1047
+ cy.get('input[name="city"]').clear().type('New York')
1048
+ cy.get('input[name="postcode"]').clear().type('11217')
1049
+
1050
+ cy.get('[data-testid="select-country"]').click()
1051
+ cy.get('[data-testid="United Kingdom"]').should('be.visible')
1052
+
1053
+ cy.get('[data-testid="United States of America"]').click()
1054
+
1055
+ cy.contains('Save').click()
1056
+
1057
+ cy.get('[data-testid="modal"]').should('not.exist')
1058
+ cy.contains(
1059
+ '[data-testid="introduction-title"]',
1060
+ 'Address Outside Delivery Area'
1061
+ ).should('not.exist')
1062
+ cy.contains(
1063
+ '[data-testid="description-block"]',
1064
+ 'Unfortunately the address you entered is outside of our delivery area so cannot be updated online.'
1065
+ ).should('not.exist')
1066
+ cy.contains(
1067
+ '[data-testid="primary-button"]',
1068
+ 'Return to My Account'
1069
+ ).should('not.exist')
1070
+ cy.contains(
1071
+ '[data-testid="toast-container"]',
1072
+ 'Your address was successfully updated'
1073
+ )
1074
+ cy.url().should('eq', 'http://localhost:3000/account')
1075
+ })
1076
+ })
1077
+ })