@newskit-render/core 4.26.3-alpha.1 → 4.26.3-alpha.2

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,434 @@
1
+ describe('Subscription and billing details without user', () => {
2
+ beforeEach(() => {
3
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
4
+ })
5
+
6
+ it('Should show no subscription view without account', () => {
7
+ cy.contains('You don’t have a subscription')
8
+ cy.contains('Start a subscription and get access to all benefits.')
9
+ cy.contains('a', 'View subscription options').should(
10
+ 'have.attr',
11
+ 'href',
12
+ '/title-storefront'
13
+ )
14
+ })
15
+
16
+ it('Should show no subscription view for user without subscription', () => {
17
+ cy.GetAcsSession('noSub')
18
+
19
+ cy.contains('You don’t have a subscription')
20
+ cy.contains('Start a subscription and get access to all benefits.')
21
+ cy.get('[data-testid="primary-button"]')
22
+ .should('have.attr', 'href', '/title-storefront')
23
+ .contains('View subscription options')
24
+ })
25
+ })
26
+
27
+ describe('Subscription and billing details for newly registered user', () => {
28
+ it('Should show pending activation view', () => {
29
+ cy.GetAcsSession('withSub')
30
+ cy.mockConsent()
31
+ cy.visitAndOverrideNextData(
32
+ '/account/subscription-and-billing',
33
+ 'props.pageProps.user.subscriptions[0].status',
34
+ 'Pending Activation'
35
+ )
36
+ cy.contains('Your subscription is being activated')
37
+ cy.contains(
38
+ 'Your membership is being set up at the moment, so you can’t access your subscription and billing details yet.'
39
+ )
40
+ cy.contains(
41
+ 'Setting up your account can take a couple of hours, so please come back and try again later.'
42
+ )
43
+ })
44
+ })
45
+
46
+ describe('Subscription and billing details for user with expired subscription', () => {
47
+ it('Should show expired subscription view', () => {
48
+ const date = new Date(Date.now() - 24 * 35 * 3600 * 1000)
49
+
50
+ cy.GetAcsSession('expiredSub')
51
+ cy.mockConsent()
52
+ cy.visitAndOverrideNextData(
53
+ '/account/subscription-and-billing',
54
+ 'props.pageProps.user.subscriptions[0].serviceCancellationDate',
55
+ date.toISOString()
56
+ )
57
+
58
+ cy.contains('You’ve previously had a subscription that has now expired')
59
+ cy.contains(
60
+ `On ${date.toLocaleDateString(
61
+ 'en-GB'
62
+ )} your Digital subscription expired. You can re-subscribe by confirming a few details or view other packages that are available.`
63
+ )
64
+ cy.get('[data-testid="primary-button"]')
65
+ .should('have.attr', 'href', '/title-re-subscribe')
66
+ .contains('Re-subscribe')
67
+
68
+ cy.get('[data-testid="secondary-button"]')
69
+ .should('have.attr', 'href', '/title-subscription-options')
70
+ .contains('View subscription options')
71
+ })
72
+ })
73
+
74
+ describe('Subscription and billing details for user with VIP/free subscription', () => {
75
+ it('Should show no payment details view', () => {
76
+ cy.GetAcsSession('withSub')
77
+ cy.mockConsent()
78
+ cy.visitAndOverrideNextData(
79
+ '/account/subscription-and-billing',
80
+ 'props.pageProps.user.subscriptions[0].billingDetails.paymentMethod.type',
81
+ null
82
+ )
83
+ cy.contains(
84
+ 'There are no payment details associated with this type of account'
85
+ )
86
+ })
87
+ })
88
+
89
+ describe('Subscription and billing details for Digital user', () => {
90
+ beforeEach(() => {
91
+ cy.GetTnlAcsSession('digitalCard')
92
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
93
+ })
94
+
95
+ it('Should display page header and description', () => {
96
+ cy.contains('Subscription & Billing')
97
+ cy.contains(
98
+ 'All your subscription details, including payment info and transactions.'
99
+ )
100
+ })
101
+
102
+ it('Should display Subscription details section', () => {
103
+ cy.contains(
104
+ '[data-testid="ContentListIntroduction"]',
105
+ 'Subscription details'
106
+ )
107
+ cy.contains('Type')
108
+ cy.contains('Digital')
109
+ cy.contains('Price')
110
+ cy.contains('£25.99')
111
+ cy.contains('Customer number')
112
+ cy.contains('4AAA039263007')
113
+ cy.contains(
114
+ 'Your customer number is your unique identifier and may be asked when contacting us'
115
+ )
116
+ cy.contains('Start date')
117
+ cy.contains('20/09/2022')
118
+ cy.contains('Benefits')
119
+ cy.contains(
120
+ 'Short description of subscription type, including product access'
121
+ )
122
+ })
123
+
124
+ it('Should display Cancellation link', () => {
125
+ cy.contains('Cancel subscription')
126
+ cy.get('a[href="/account/cancellation"]').should('be.visible').click()
127
+ cy.location().should((loc) => {
128
+ expect(loc.pathname).to.eq('/account/cancellation')
129
+ })
130
+ cy.contains('Please tell us why you want to cancel')
131
+ })
132
+
133
+ it('Should display Billing details section', () => {
134
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Billing details')
135
+ cy.contains('Payment method')
136
+ cy.get('[data-testid="visa-icon"]').should('exist')
137
+ cy.contains('************1111')
138
+ cy.contains('expiry date 03/30')
139
+ })
140
+
141
+ it('Should display Invoice history section', () => {
142
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
143
+ cy.contains('Digital pack')
144
+ cy.contains('20 Sept 2022')
145
+ cy.contains('Paid')
146
+ cy.get('a[data-testid="download-button"]')
147
+ .should('have.attr', 'href', '#')
148
+ .contains('View')
149
+ })
150
+
151
+ it('Should NOT display Your deliveries section', () => {
152
+ cy.contains(
153
+ '[data-testid="ContentListIntroduction"]',
154
+ 'Your deliveries'
155
+ ).should('not.exist')
156
+ })
157
+ })
158
+
159
+ describe('Subscription and billing details for Print user', () => {
160
+ beforeEach(() => {
161
+ cy.GetTnlAcsSession('print')
162
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
163
+ })
164
+
165
+ it('Should display page header and description', () => {
166
+ cy.contains('Subscription & Billing')
167
+ cy.contains(
168
+ 'All your subscription details, including payment info and transactions.'
169
+ )
170
+ })
171
+
172
+ it('Should display Subscription details section', () => {
173
+ cy.contains(
174
+ '[data-testid="ContentListIntroduction"]',
175
+ 'Subscription details'
176
+ )
177
+ cy.contains('Type')
178
+ cy.contains('Print')
179
+ cy.contains('Price')
180
+ cy.contains('£10.83')
181
+ cy.contains('Customer number')
182
+ cy.contains('4AAA039261011')
183
+ cy.contains(
184
+ 'Your customer number is your unique identifier and may be asked when contacting us'
185
+ )
186
+ cy.contains('Start date')
187
+ cy.contains('20/09/2022')
188
+ cy.contains('Benefits')
189
+ cy.contains(
190
+ 'Short description of subscription type, including product access'
191
+ )
192
+ })
193
+
194
+ it('Should display Cancellation link', () => {
195
+ cy.contains('Cancel subscription')
196
+ cy.get('a[href="/account/cancellation"]').should('be.visible').click()
197
+ cy.location().should((loc) => {
198
+ expect(loc.pathname).to.eq('/account/cancellation')
199
+ })
200
+ cy.contains('Please tell us why you want to cancel')
201
+ })
202
+
203
+ it('Should display Billing details section', () => {
204
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Billing details')
205
+ cy.contains('Payment method')
206
+ cy.get('[data-testid="visa-icon"]').should('exist')
207
+ cy.contains('************1111')
208
+ cy.contains('expiry date 01/28')
209
+ cy.contains('Billing postcode')
210
+ cy.contains('SE1 9GF')
211
+ })
212
+
213
+ it('Should display Your deliveries section', () => {
214
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Your deliveries')
215
+ cy.contains('Address')
216
+ cy.contains('Buckingham Palace, London, SW1A 1AA')
217
+ cy.contains('Delivery instructions')
218
+ cy.contains('On my doorstep')
219
+ cy.contains('Holiday Stops')
220
+ cy.contains(
221
+ 'You can pause your print delivery at any time by adding a Holiday Stop to your account. Holiday Stops need to be booked before 16:00 GMT the day before you want to pause delivery.'
222
+ )
223
+
224
+ cy.contains(
225
+ 'Your contact address will be used for any of your deliveries. This can be managed via Personal details'
226
+ )
227
+ })
228
+
229
+ it('Should display Invoice history section', () => {
230
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
231
+ cy.contains('Print pack')
232
+ cy.contains('24 Apr 2023')
233
+ cy.contains('Paid')
234
+ cy.get('a[data-testid="download-button"]')
235
+ .should('have.attr', 'href', '#')
236
+ .contains('View')
237
+ })
238
+
239
+ it('Should display Your deliveries section for users with vouchers', () => {
240
+ cy.GetTnlAcsSession('printVouchers')
241
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
242
+
243
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Your deliveries')
244
+ cy.contains('Address')
245
+ cy.contains('2 Tuke House, Cromwell Road, York, YO1 6DJ, North Yorkshire')
246
+ cy.contains('Delivery instructions')
247
+ cy.contains('On my doorstep')
248
+ cy.contains('Holiday Stops')
249
+ cy.contains(
250
+ 'You can pause your print delivery at any time by adding a Holiday Stop to your account. Holiday Stops need to be booked before 16:00 GMT the day before you want to pause delivery.'
251
+ )
252
+ cy.contains('Your vouchers')
253
+ cy.contains(
254
+ 'If your voucher booklet hasn’t arrived within three days of your booklet start date, or you have any issues regarding your vouchers, please contact us.'
255
+ )
256
+ cy.contains('Voucher booklet start date')
257
+ cy.contains('17/03/24')
258
+ cy.contains(
259
+ 'Your contact address will be used for any of your deliveries. This can be managed via Personal details'
260
+ )
261
+ })
262
+ })
263
+
264
+ describe('Subscription and billing details for Digi-Print user', () => {
265
+ beforeEach(() => {
266
+ cy.GetTnlAcsSession('digiprint')
267
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
268
+ })
269
+ // Same as Print user
270
+
271
+ it('Should display Subscription details section', () => {
272
+ cy.contains(
273
+ '[data-testid="ContentListIntroduction"]',
274
+ 'Subscription details'
275
+ )
276
+ cy.contains('Type')
277
+ cy.contains('Digi-Print')
278
+ //...rest is same as Print user
279
+ })
280
+
281
+ it('Should display Invoice history section', () => {
282
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
283
+ cy.contains('Digi-Print pack')
284
+ cy.contains('12 Nov 2023')
285
+ cy.contains('Paid')
286
+ cy.get('a[data-testid="download-button"]')
287
+ .should('have.attr', 'href', '#')
288
+ .contains('View')
289
+ })
290
+ })
291
+
292
+ describe('Subscription and billing details for Paypal user', () => {
293
+ beforeEach(() => {
294
+ cy.GetAcsSession('paypalSub')
295
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
296
+ })
297
+ // Same as Digital user
298
+
299
+ it('Should display Billing details section', () => {
300
+ cy.contains('[data-testid="ContentListIntroduction"]', 'Billing details')
301
+ cy.contains('Payment method')
302
+ cy.get('[data-testid="paypal-icon"]').should('exist')
303
+ cy.contains('cmp.paypal.user.verified.test@news.co.uk')
304
+ })
305
+
306
+ it('Should show inline banner for Paypal subscription', () => {
307
+ cy.get('a[href="/account/payment"]').should('be.visible').click()
308
+ cy.contains(
309
+ '[data-testid="Zuora-inline"]',
310
+ 'To update your Paypal credentials, please speak to one of our advisors on xxxx-xxx-xxxx or add a new payment method via credit/debit card using the form below.'
311
+ )
312
+ })
313
+ })
314
+
315
+ describe('Subscription and billing edit pages', () => {
316
+ describe('Edit delivery instructions', () => {
317
+ beforeEach(() => {
318
+ cy.GetTnlAcsSession('print')
319
+ cy.mockConsentAndVisit('/account/subscription-and-billing')
320
+ })
321
+
322
+ it('Should show user current delivery instructions', () => {
323
+ cy.get('a[href="/account/edit/delivery-instructions"]')
324
+ .should('be.visible')
325
+ .click()
326
+
327
+ cy.contains('Delivery instructions')
328
+ cy.contains('Where should we leave your Newspaper?')
329
+ cy.contains('Through my letterbox')
330
+ cy.get('input[value="Through my letterbox"]').should(
331
+ 'not.have.attr',
332
+ 'checked'
333
+ )
334
+ cy.contains('On my doorstep')
335
+ cy.get('input[value="On my doorstep"]').should('have.attr', 'checked')
336
+ cy.contains('On my porch')
337
+ cy.get('input[value="On my porch"]').should('not.have.attr', 'checked')
338
+ cy.contains('Other (Please state)')
339
+ cy.get('input[value="Other (Please state)"]').should(
340
+ 'not.have.attr',
341
+ 'checked'
342
+ )
343
+
344
+ cy.contains('[data-testid="primary-button"]', 'Save')
345
+ cy.contains('[data-testid="secondary-button"]', 'Cancel')
346
+
347
+ // Redirects to Subscription and billing page
348
+ cy.get('[data-testid="secondary-button"]').click()
349
+ cy.location().should((loc) => {
350
+ expect(loc.pathname).to.eq('/account/subscription-and-billing')
351
+ })
352
+ })
353
+
354
+ it('Should change user delivery instructions', () => {
355
+ cy.get('a[href="/account/edit/delivery-instructions"]')
356
+ .should('be.visible')
357
+ .click()
358
+
359
+ cy.contains('Through my letterbox').click()
360
+
361
+ // mock sussesful api call
362
+ cy.intercept('POST', '/api/account/mutate', {
363
+ statusCode: 200,
364
+ body: { data: { updateUserSubscription: { success: true } } },
365
+ })
366
+
367
+ cy.get('[data-testid="primary-button"]').click()
368
+ cy.contains(
369
+ '[data-testid="toast-container"]',
370
+ 'Updating your delivery instructions...'
371
+ )
372
+
373
+ // Redirects to Subscription and billing page
374
+ cy.location().should((loc) => {
375
+ expect(loc.pathname).to.eq('/account/subscription-and-billing')
376
+ })
377
+ cy.contains(
378
+ '[data-testid="toast-container"]',
379
+ 'Your delivery instructions were succesfully updated. This may take up to 48hrs to come into effect.'
380
+ )
381
+ // cy.contains('Through my letterbox').should('have.length', 1)
382
+ })
383
+
384
+ it('Should add custom delivery instructions', () => {
385
+ cy.get('a[href="/account/edit/delivery-instructions"]')
386
+ .should('be.visible')
387
+ .click()
388
+
389
+ cy.contains('Other (Please state)').click()
390
+ cy.contains('You have 70 characters remaining')
391
+ cy.contains(
392
+ 'Please note that if you choose a delivery location that is not secure we cannot be liable for lost or stolen newspapers.'
393
+ )
394
+
395
+ cy.get('textarea[name="other"]').clear()
396
+ cy.get('[data-testid="primary-button"]').click()
397
+ cy.contains('Please enter your delivery instructions.')
398
+
399
+ cy.get('textarea[name="other"]').clear()
400
+ cy.get('textarea[name="other"]').type(
401
+ 'This is more than seventy Characters. Lorem ipsum dolor sit amet, consectetur.'
402
+ )
403
+ cy.contains('You have 0 characters remaining')
404
+ //If hitting Save, field will be updated
405
+
406
+ cy.get('textarea[name="other"]').clear()
407
+ cy.get('textarea[name="other"]').type('Ring the bell')
408
+
409
+ // mock sussesful api call
410
+ cy.intercept('POST', '/api/account/mutate', {
411
+ statusCode: 200,
412
+ body: { data: { updateUserSubscription: { success: true } } },
413
+ })
414
+
415
+ cy.get('[data-testid="primary-button"]').click()
416
+ cy.contains(
417
+ '[data-testid="toast-container"]',
418
+ 'Updating your delivery instructions...'
419
+ )
420
+
421
+ // Redirects to Subscription and billing page
422
+ cy.location().should((loc) => {
423
+ expect(loc.pathname).to.eq('/account/subscription-and-billing')
424
+ })
425
+ cy.contains(
426
+ '[data-testid="toast-container"]',
427
+ 'Your delivery instructions were succesfully updated. This may take up to 48hrs to come into effect.'
428
+ )
429
+ // cy.contains('Ring the bell').should('have.length', 1)
430
+ })
431
+ })
432
+
433
+ // describe('Edit holiday stops', () => {}) // check holiday-stops.cy.js
434
+ })
@@ -17,3 +17,8 @@ export const paymentFailureTerminatedNotice = {
17
17
  active: true,
18
18
  startDate: new Date(Date.now() - 24 * 35 * 3600 * 1000).toISOString(),
19
19
  }
20
+
21
+ export const serviceCancellationDate = new Date(Date.now() + 20 * 30 * 3600 * 1000).toISOString()
22
+
23
+
24
+
@@ -8,7 +8,7 @@ import {
8
8
  } from './consentValues'
9
9
  import { userMap } from './users'
10
10
 
11
- const setConentLocalStorage = () => {
11
+ const setConsentLocalStorage = () => {
12
12
  localStorage.setItem('_sp_local_state', JSON.stringify(_sp_local_state))
13
13
  localStorage.setItem(
14
14
  '_sp_user_consent_7377',
@@ -22,13 +22,13 @@ const setConentLocalStorage = () => {
22
22
 
23
23
  Cypress.Commands.add('mockConsentAndVisit', (url) => {
24
24
  cy.setCookie('consentUUID', consentUUIDValue)
25
- setConentLocalStorage()
25
+ setConsentLocalStorage()
26
26
  cy.visit(url)
27
27
  })
28
28
 
29
29
  Cypress.Commands.add('mockConsent', () => {
30
30
  cy.setCookie('consentUUID', consentUUIDValue)
31
- setConentLocalStorage()
31
+ setConsentLocalStorage()
32
32
  })
33
33
 
34
34
  Cypress.Commands.add('GetAcsSession', (user = 'default') => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "4.26.3-alpha.1",
3
+ "version": "4.26.3-alpha.2",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -44,12 +44,12 @@
44
44
  "@newrelic/winston-enricher": "4.0.1",
45
45
  "@newskit-render/api": "^1.11.0",
46
46
  "@newskit-render/auth": "^1.8.0",
47
- "@newskit-render/checkout": "^3.9.26-alpha.0",
47
+ "@newskit-render/checkout": "^3.9.26-alpha.1",
48
48
  "@newskit-render/feature-flags": "^1.7.0",
49
49
  "@newskit-render/feed": "^1.8.7",
50
- "@newskit-render/my-account": "^7.48.2-alpha.1",
51
- "@newskit-render/shared-components": "^4.23.5-alpha.0",
52
- "@newskit-render/standalone-components": "^3.20.19-alpha.0",
50
+ "@newskit-render/my-account": "^7.48.2-alpha.2",
51
+ "@newskit-render/shared-components": "^4.23.5-alpha.1",
52
+ "@newskit-render/standalone-components": "^3.20.19-alpha.1",
53
53
  "@newskit-render/validation": "^1.17.0",
54
54
  "cross-fetch": "3.1.5",
55
55
  "graphql": "16.6.0",
@@ -1,12 +0,0 @@
1
- describe('SkipToContent', () => {
2
- beforeEach(() => {
3
- cy.GetAcsSession()
4
- cy.mockConsentAndVisit('/account')
5
- })
6
-
7
- it('should take the user to the beginning of the main area', () => {
8
- cy.get('[data-testid="skip-to-content"]').focus()
9
- cy.get('[data-testid="skip-to-content"]').click()
10
- cy.focused().should('have.id', 'main')
11
- })
12
- })