@newskit-render/core 1.14.1 → 1.24.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.
Files changed (49) hide show
  1. package/.eslintignore +5 -1
  2. package/.eslintrc +1 -1
  3. package/CHANGELOG.md +212 -0
  4. package/Dockerfile +1 -1
  5. package/__tests__/pages/[articleSlug].test.tsx +1 -1
  6. package/__tests__/pages/__snapshots__/home.test.tsx.snap +175 -324
  7. package/__tests__/pages/home.test.tsx +1 -0
  8. package/applitools.config.js +9 -0
  9. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +279 -517
  10. package/components/footer/__snapshots__/index.test.tsx.snap +7 -11
  11. package/components/header/index.test.tsx +1 -1
  12. package/components/header/index.tsx +60 -30
  13. package/components/section/__tests__/ArticleSlice.test.tsx +32 -24
  14. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +30 -50
  15. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +205 -358
  16. package/cypress/config/config.e2e.json +14 -0
  17. package/cypress/config/config.visual.json +8 -0
  18. package/cypress/e2e/account/SkipToContent.spec.js +12 -0
  19. package/cypress/e2e/account/accessibility.spec.js +69 -0
  20. package/cypress/e2e/account/account-page.spec.js +339 -0
  21. package/cypress/e2e/account/commenting-notifications.spec.js +44 -0
  22. package/cypress/e2e/account/main-api.spec.js +93 -0
  23. package/cypress/e2e/account/payment-page.spec.js +42 -0
  24. package/cypress/{integration → e2e/core}/home-page.spec.js +0 -0
  25. package/cypress/plugins/index.js +31 -0
  26. package/cypress/support/commands.js +48 -25
  27. package/cypress/support/index.js +2 -0
  28. package/cypress/visual/account/visual-regression.spec.js +31 -0
  29. package/helpers/a11y.ts +8 -6
  30. package/helpers/mocks/articleMock.ts +8 -4
  31. package/helpers/mocks/getRadioPostMock.ts +4 -2
  32. package/helpers/mocks/getUniversalArticleMock.ts +8 -4
  33. package/infrastructure/.circleci/config.yml +3 -3
  34. package/package.json +61 -55
  35. package/pages/[section]/[articleId]/[articleSlug].tsx +1 -0
  36. package/pages/[section]/index.tsx +1 -0
  37. package/pages/_app.tsx +44 -13
  38. package/pages/_document.tsx +27 -14
  39. package/pages/checkout/account-creation/index.tsx +9 -1
  40. package/pages/index.tsx +1 -0
  41. package/public/MyAccount/no-subscription.svg +15 -0
  42. package/public/MyAccount/previous-subscription.svg +15 -0
  43. package/public/MyAccount/primary-navigation-logo-white.svg +6 -0
  44. package/public/prebid.min.js +1 -0
  45. package/temp/_document.tsx +1 -1
  46. package/theme/colours.json +4 -0
  47. package/theme/render-custom-theme.ts +5 -2
  48. package/tsconfig.json +4 -1
  49. package/helpers/articleUtil.ts +0 -4
@@ -0,0 +1,14 @@
1
+ {
2
+ "baseUrl": "http://localhost:3000",
3
+ "video": false,
4
+ "screenshotOnRunFailure": true,
5
+ "defaultCommandTimeout": 50000,
6
+ "chromeWebSecurity": false,
7
+ "integrationFolder": "./cypress/e2e",
8
+ "retries": 1,
9
+ "env": {
10
+ "E2E_BASE_URL": "http://localhost:3000/api/account",
11
+ "MAIN_GRAPHQL_URL": "https://main-graphql.staging.newsapis.co.uk/graphql",
12
+ "MAIN_COOKIE_NAME": "acs_ngn"
13
+ }
14
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "visual",
3
+ "baseUrl": "http://localhost:3000",
4
+ "video": false,
5
+ "screenshotOnRunFailure": false,
6
+ "defaultCommandTimeout": 20000,
7
+ "integrationFolder": "./cypress/visual"
8
+ }
@@ -0,0 +1,12 @@
1
+ // describe('SkipToContent', () => {
2
+ // beforeEach(() => {
3
+ // cy.setCookie('nukt_sp_consent', 'JABCDEFGHI')
4
+ // cy.setCookie('consentUUID', '28cfcd1e-6916-4488-9d84-54f2618eaa14')
5
+ // cy.visit('/account')
6
+ // })
7
+
8
+ // it('should take the user to the beginning of the main area', () => {
9
+ // cy.get('[data-testid="skip-to-content"]').focus().click()
10
+ // cy.focused().should('have.id', 'main')
11
+ // })
12
+ // })
@@ -0,0 +1,69 @@
1
+ function terminalLog(violations) {
2
+ cy.task(
3
+ 'log',
4
+ `${violations.length} accessibility violation${
5
+ violations.length === 1 ? '' : 's'
6
+ } ${violations.length === 1 ? 'was' : 'were'} detected`
7
+ )
8
+ // pluck specific keys to keep the table readable
9
+ const violationData = violations.map(
10
+ ({ id, impact, description, nodes }) => ({
11
+ id,
12
+ impact,
13
+ description,
14
+ nodes: nodes.length,
15
+ })
16
+ )
17
+
18
+ cy.task('table', violationData)
19
+ }
20
+
21
+ const pages = [
22
+ {
23
+ url: '/account',
24
+ name: 'Personal Details',
25
+ skip: { skipFailures: true }, // error being caused by newskit update - https://nidigitalsolutions.jira.com/browse/PPDSC-1864 - removed once fixed
26
+ },
27
+ { url: '/account/edit/name', name: 'Name form', skip: null },
28
+ { url: '/account/edit/displayName', name: 'Display Name form', skip: null },
29
+ { url: '/account/edit/email', name: 'Email form', skip: null },
30
+ { url: '/account/edit/password', name: 'Password form', skip: null },
31
+ // error being caused by not handling new accounts without a phone - https://nidigitalsolutions.jira.com/browse/PPDSR-537 - remove once fixed
32
+ // { url: '/account/edit/mobile', name: 'Mobile phone form', skip: false },
33
+ // { url: '/account/edit/landline', name: 'Landline phone form', skip: false },
34
+ {
35
+ url: '/account/edit/address',
36
+ name: 'Address form',
37
+ skip: { skipFailures: true }, // error being caused by Loqate, ignore at this time
38
+ },
39
+ {
40
+ url: '/account/subscription-and-billing',
41
+ name: 'Subscription and Billing',
42
+ skip: { skipFailures: true }, // error being caused by newskit update - https://nidigitalsolutions.jira.com/browse/PPDSC-1864 - removed once fixed
43
+ },
44
+ {
45
+ url: '/account/payment',
46
+ name: 'Payment form',
47
+ skip: { skipFailures: true }, // error being caused by Stripe, ignore at this time
48
+ },
49
+ {
50
+ url: '/account/newsletters-and-alerts',
51
+ name: 'Newsletters and Alerts',
52
+ skip: { skipFailures: true }, // error being caused by newskit update - https://nidigitalsolutions.jira.com/browse/PPDSC-1864 - removed once fixed
53
+ },
54
+ {
55
+ url: '/account/edit/commenting-notifications',
56
+ name: 'Commenting Notifications form',
57
+ skip: null,
58
+ },
59
+ ]
60
+
61
+ describe('Page accessibility', () => {
62
+ pages.forEach(({ url, name, skip }) => {
63
+ it(`Should pass a11y tests: ${name}`, () => {
64
+ cy.mockConsentAndVisit(url)
65
+ cy.injectAxe()
66
+ cy.checkA11y(null, null, terminalLog, skip)
67
+ })
68
+ })
69
+ })
@@ -0,0 +1,339 @@
1
+ describe('My account personal details', () => {
2
+ beforeEach(() => {
3
+ cy.GetAcsSession()
4
+ cy.mockConsentAndVisit('/account')
5
+ })
6
+
7
+ it('Should Display Personal details page', () => {
8
+ cy.get('[data-testid="ContentListIntroduction"]').should('have.length', 3)
9
+ cy.get('[data-testid="ContentListItems"]').should('have.length', 3)
10
+ })
11
+
12
+ it('Should go to edit page and change first name', () => {
13
+ cy.get('a[href="/account/edit/name"]')
14
+ .should('be.visible')
15
+ .click({ force: true })
16
+ cy.get('[name="firstName"]').clear().type('John')
17
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
18
+ cy.contains('[data-testid="toast-container"]', 'Updating your name...')
19
+
20
+ // Redirects to Personal details page
21
+ cy.contains('John').should('have.length', 1)
22
+ cy.contains('[data-testid="toast-container"]', 'Your name has been updated')
23
+ })
24
+
25
+ it('Should show error toast when updating name', () => {
26
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
27
+ cy.get('a[href="/account/edit/name"]')
28
+ .should('be.visible')
29
+ .click({ force: true })
30
+ cy.get('[name="firstName"]').clear().type('John')
31
+ cy.get('[name="lastName"]').clear().type('Cena')
32
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
33
+ cy.contains('[data-testid="toast-container"]', 'Updating your name...')
34
+
35
+ cy.contains(
36
+ '[data-testid="toast-container"]',
37
+ "Sorry, we're unable to save your name right now. Please try again or come back later."
38
+ )
39
+ })
40
+
41
+ it('Should go to edit page and change last name', () => {
42
+ cy.get('a[href="/account/edit/name"]')
43
+ .should('be.visible')
44
+ .click({ force: true })
45
+ cy.get('[name="lastName"]').clear().type('Smith')
46
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
47
+ cy.contains('[data-testid="toast-container"]', 'Updating your name...')
48
+
49
+ // Redirects to Personal details page
50
+ cy.contains('Smith').should('have.length', 1)
51
+ cy.contains('[data-testid="toast-container"]', 'Your name has been updated')
52
+ })
53
+
54
+ it('Should go to the edit Name page, add invalid value and expect error labels', () => {
55
+ cy.get('a[href="/account/edit/name"]')
56
+ .should('be.visible')
57
+ .click({ force: true })
58
+ cy.get('[name="firstName"]').clear().type('?')
59
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
60
+
61
+ cy.contains(
62
+ 'Your first name can’t contain special characters. Please try again.'
63
+ )
64
+
65
+ cy.get('[name="firstName"]').clear()
66
+ cy.get('[name="lastName"]').clear().type('Henry 8')
67
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
68
+
69
+ cy.contains(
70
+ 'That doesn’t look right. Please check your First Name and try again.'
71
+ ).should('not.exist')
72
+
73
+ cy.contains('Please enter your First Name')
74
+
75
+ cy.contains(
76
+ 'Your last name can’t contain special characters. Please try again.'
77
+ )
78
+ })
79
+
80
+ it('Should go to edit page and change display name ', () => {
81
+ cy.get('a[href="/account/edit/displayName"]')
82
+ .should('be.visible')
83
+ .click({ force: true })
84
+ cy.get('[name="displayName"]').clear().type('NKDN')
85
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
86
+ cy.contains(
87
+ '[data-testid="toast-container"]',
88
+ 'Updating your display name...'
89
+ )
90
+ // Redirects to Personal details page
91
+ cy.contains(
92
+ '[data-testid="toast-container"]',
93
+ 'Your display name has been updated.'
94
+ )
95
+ })
96
+
97
+ it('Should show error toast when updating display name', () => {
98
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
99
+ cy.get('a[href="/account/edit/displayName"]')
100
+ .should('be.visible')
101
+ .click({ force: true })
102
+ cy.get('[name="displayName"]').clear().type('Rock')
103
+ cy.get('[data-testid="primary-button"]')
104
+ .scrollIntoView()
105
+ .click({ force: true })
106
+ cy.contains(
107
+ '[data-testid="toast-container"]',
108
+ 'Updating your display name...'
109
+ )
110
+ cy.contains(
111
+ '[data-testid="toast-container"]',
112
+ "Sorry, we're unable to save your display name right now. Please try again or come back later."
113
+ )
114
+ })
115
+
116
+ it('Should show error message when display name is empty', () => {
117
+ cy.get('a[href="/account/edit/displayName"]')
118
+ .should('be.visible')
119
+ .click({ force: true })
120
+ cy.get('[name="displayName"]').clear()
121
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
122
+ cy.contains('Please enter your Display Name')
123
+ })
124
+
125
+ it('Should go back to Personal Details on clicking cancel button', () => {
126
+ cy.get('a[href="/account/edit/displayName"]')
127
+ .should('be.visible')
128
+ .click({ force: true })
129
+ cy.get('[data-testid="secondary-button"]')
130
+ .should('be.visible')
131
+ .click({ force: true })
132
+ cy.location().should((loc) => {
133
+ expect(loc.pathname).to.eq('/account')
134
+ })
135
+ })
136
+
137
+ // it('Should go to edit page and change email', () => {
138
+ // cy.get('a[href="/account/edit/email"]')
139
+ // .should('be.visible')
140
+ // .click({ force: true })
141
+
142
+ // // Locally you need to add a "MAIN_USER_EMAIL" to cypress.env.json
143
+ // // "MAIN_USER_EMAIL" should be the email of the user you use for testing
144
+ // cy.contains(Cypress.env('MAIN_USER_EMAIL'))
145
+ // cy.get('[name="email"]').clear().type(Cypress.env('newEmail'))
146
+
147
+ // cy.get('[data-testid="primary-button"]').scrollIntoView().click()
148
+
149
+ // // Redirects to Personal details page
150
+ // cy.contains(Cypress.env('newEmail')).should('have.length', 1)
151
+ // cy.get('a[href="/account/edit/email"]')
152
+ // .should('be.visible')
153
+ // .click({ force: true })
154
+
155
+ // // Check the message for verification link
156
+ // cy.contains(
157
+ // `Email sent to ${Cypress.env(
158
+ // 'newEmail'
159
+ // )} with a verification link. Please click on the link to verify your email address and enjoy full access to our content.`
160
+ // )
161
+ // })
162
+
163
+ // it('Should go to edit page and change password', () => {
164
+ // cy.get('a[href="/account/edit/password"]')
165
+ // .should('be.visible')
166
+ // .click({ force: true })
167
+
168
+ // cy.get('[data-testid="primary-button"]').should('have.text', 'Send link')
169
+ // cy.get('[data-testid="primary-button"]').scrollIntoView().click()
170
+
171
+ // cy.get('[data-testid="primary-button"]').should('not.exist')
172
+
173
+ // cy.get('a[href="/account/edit/password"]')
174
+ // .should('be.visible')
175
+ // .click({ force: true })
176
+
177
+ // cy.get('[data-testid="inline-message"]')
178
+ // .children()
179
+ // .should(
180
+ // 'contain',
181
+ // `Email sent to ${Cypress.env(
182
+ // 'newEmail'
183
+ // )} 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.`
184
+ // )
185
+ // })
186
+
187
+ it('Should go to edit page and change landline', () => {
188
+ cy.get('a[href="/account/edit/landline"]')
189
+ .should('be.visible')
190
+ .click({ force: true })
191
+ cy.get('[data-testid="primary-button"]').should('have.text', 'Save')
192
+ cy.get('.PhoneInputCountrySelect').select('IE')
193
+ cy.get('.PhoneInputCountryIconImg').should('have.attr', 'alt', 'Ireland')
194
+ cy.get('.PhoneInputInput').clear()
195
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
196
+ cy.contains('Please enter your landline telephone number')
197
+
198
+ cy.get('.PhoneInputInput').click().type('07777 777778')
199
+ cy.get('[data-testid="primary-button"]').scrollIntoView().click()
200
+ cy.contains(
201
+ 'That doesn’t look like a valid phone number. Please try again.'
202
+ )
203
+
204
+ cy.get('.PhoneInputCountrySelect').select('GB')
205
+ cy.get('.PhoneInputCountryIconImg').should(
206
+ 'have.attr',
207
+ 'alt',
208
+ 'United Kingdom'
209
+ )
210
+
211
+ cy.get('[data-testid="primary-button"]').click()
212
+ cy.contains(
213
+ '[data-testid="toast-container"]',
214
+ 'Your landline telephone number has been updated.'
215
+ )
216
+
217
+ cy.contains('07777 777778')
218
+ })
219
+
220
+ it('Should throw error when editing landline', () => {
221
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
222
+ cy.get('a[href="/account/edit/landline"]')
223
+ .should('be.visible')
224
+ .click({ force: true })
225
+ cy.get('[data-testid="primary-button"]').should('have.text', 'Save')
226
+
227
+ cy.get('.PhoneInputCountrySelect').select('GB')
228
+ cy.get('.PhoneInputCountryIconImg').should(
229
+ 'have.attr',
230
+ 'alt',
231
+ 'United Kingdom'
232
+ )
233
+
234
+ cy.get('[data-testid="primary-button"]').click()
235
+ cy.contains(
236
+ '[data-testid="toast-container"]',
237
+ "Sorry, we're unable to save your landline telephone number right now. Please try again or come back later."
238
+ )
239
+ })
240
+
241
+ it('Should go to edit page and change address', () => {
242
+ cy.get('a[href="/account/edit/address"]')
243
+ .should('be.visible')
244
+ .click({ force: true })
245
+
246
+ cy.get('input[name="line1"]').clear().type('News UK')
247
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
248
+ cy.get('input[name="line3"]').clear().type('Buckie;')
249
+ cy.get('input[name="city"]').clear().type('London')
250
+ cy.get('input[name="county"]').clear().type('Kent')
251
+ cy.get('input[name="postcode"]').clear().type('SE1 9GF')
252
+ cy.get('select[name="country"]').select('GB')
253
+
254
+ cy.get('[data-testid="primary-button"]').click()
255
+ cy.contains(
256
+ 'Your address can’t contain special characters. Please try again.'
257
+ )
258
+ cy.get('input[name="line3"]').type('{backspace} 2')
259
+ cy.get('[data-testid="primary-button"]').click()
260
+ cy.contains('[data-testid="toast-container"]', 'Updating your address...')
261
+ cy.get('a[href="/account/edit/address"]')
262
+ .children()
263
+ .should('contain', 'News UK')
264
+ .and('contain', '1 London Bridge Street')
265
+ .and('contain', 'Buckie 2')
266
+ .and('contain', 'London')
267
+ .and('contain', 'Kent')
268
+ .and('contain', 'SE1 9GF')
269
+ cy.contains(
270
+ '[data-testid="toast-container"]',
271
+ 'Your address has been updated'
272
+ )
273
+ })
274
+
275
+ it('Should throw error when editing address', () => {
276
+ cy.intercept('POST', '/api/account/mutate', { statusCode: 500 })
277
+ cy.get('a[href="/account/edit/address"]')
278
+ .should('be.visible')
279
+ .click({ force: true })
280
+
281
+ cy.get('input[name="line1"]').clear().type('News UK')
282
+ cy.get('input[name="line2"]').clear().type('1 London Bridge Street')
283
+ cy.get('input[name="line3"]').clear().type('Buckie')
284
+ cy.get('input[name="city"]').clear().type('London')
285
+ cy.get('input[name="county"]').clear().type('Kent')
286
+ cy.get('input[name="postcode"]').clear().type('SE1 9GF')
287
+ cy.get('select[name="country"]').select('GB')
288
+
289
+ cy.get('[data-testid="primary-button"]').click()
290
+ cy.contains('[data-testid="toast-container"]', 'Updating your address...')
291
+ cy.contains(
292
+ '[data-testid="toast-container"]',
293
+ "Sorry, we're unable to save your address right now. Please try again or come back later."
294
+ )
295
+ })
296
+
297
+ // it('Should go to subscriptions and change contact preferences', () => {
298
+ // cy.get('a[href="/account/newsletters-and-alerts"]')
299
+ // .should('be.visible')
300
+ // .click({ force: true })
301
+ // cy.get('a[href="/account/edit/commenting-notifications"]')
302
+ // .should('be.visible')
303
+ // .click({ force: true })
304
+
305
+ // cy.get('[data-testid="switch-userMentioned-off"]')
306
+ // .should('be.visible')
307
+ // .click({ force: true })
308
+ // cy.get('[data-testid="switch-userMentioned-on"]').should('be.visible')
309
+
310
+ // cy.get('[data-testid="switch-likedYourMessage-off"]')
311
+ // .should('be.visible')
312
+ // .click({ force: true })
313
+ // cy.get('[data-testid="switch-likedYourMessage-on"]').should(
314
+ // 'have.attr',
315
+ // 'aria-checked',
316
+ // 'true'
317
+ // )
318
+
319
+ // cy.get('[data-testid="switch-repliedToMessage-off"]')
320
+ // .should('be.visible')
321
+ // .click({ force: true })
322
+ // cy.get('[data-testid="switch-repliedToMessage-on"]').should(
323
+ // 'have.attr',
324
+ // 'aria-checked',
325
+ // 'true'
326
+ // )
327
+
328
+ // // To be enabled as part of PPDSR-418
329
+ // // cy.get('a[href="/account/newsletters-and-alerts"]')
330
+ // // .should('be.visible')
331
+ // // .click({ force: true })
332
+ // // cy.get('a[href="/account/edit/commenting-notifications"]')
333
+ // // .should('be.visible')
334
+ // // .click({ force: true })
335
+ // // cy.get('[data-testid="switch-userMentioned-on"]').should('have.attr', 'aria-checked', 'true')
336
+ // // cy.get('[data-testid="switch-likedYourMessage-on"]').should('have.attr', 'aria-checked', 'true')
337
+ // // cy.get('[data-testid="switch-repliedToMessage-on"]').should('have.attr', 'aria-checked', 'true')
338
+ // })
339
+ })
@@ -0,0 +1,44 @@
1
+ describe('My account commenting notifications', () => {
2
+ beforeEach(() => {
3
+ cy.GetAcsSession()
4
+ cy.mockConsentAndVisit('/account/edit/commenting-notifications')
5
+ })
6
+
7
+ it('Should display commenting notifications', () => {
8
+ cy.get('[data-testid="layout-Cell"]').contains(
9
+ 'Edit your commenting notifications'
10
+ )
11
+ cy.get('[data-testid="layout-Cell"]').contains(
12
+ 'When someone mentions me in a comment'
13
+ )
14
+ cy.get('[data-testid="layout-Cell"]').contains(
15
+ 'When someone likes one of my comments'
16
+ )
17
+ cy.get('[data-testid="layout-Cell"]').contains(
18
+ 'When someone replies to one of my comments'
19
+ )
20
+ })
21
+ it('Should update commenting notifications', () => {
22
+ cy.get('[data-testid="userMentioned"]').check()
23
+ cy.get('[data-testid="likedYourMessage"]').check()
24
+ cy.get('[data-testid="repliedToMessage"]').check()
25
+ cy.get('[data-testid="primary-button"]').click()
26
+ cy.contains(
27
+ '[data-testid="toast-container"]',
28
+ 'Your commenting notifications has been updated'
29
+ )
30
+ cy.visit('/account/edit/commenting-notifications')
31
+ cy.get('[data-testid="userMentioned"]').should('be.checked')
32
+ cy.get('[data-testid="likedYourMessage"]').should('be.checked')
33
+ cy.get('[data-testid="repliedToMessage"]').should('be.checked')
34
+ cy.get('[data-testid="userMentioned"]').uncheck()
35
+ cy.get('[data-testid="likedYourMessage"]').uncheck()
36
+ cy.get('[data-testid="repliedToMessage"]').uncheck()
37
+ cy.get('[data-testid="primary-button"]').click()
38
+
39
+ cy.contains(
40
+ '[data-testid="toast-container"]',
41
+ 'Your commenting notifications has been updated'
42
+ )
43
+ })
44
+ })
@@ -0,0 +1,93 @@
1
+ describe('MAIN API', () => {
2
+ beforeEach(() => {
3
+ cy.GetAcsSession()
4
+ cy.mockConsentAndVisit('/account')
5
+ })
6
+
7
+ it('mutateUser - name', () => {
8
+ cy.getCookie(Cypress.env('MAIN_COOKIE_NAME')).then((cookie) => {
9
+ cy.request({
10
+ url: `${Cypress.env('E2E_BASE_URL')}/mutate`,
11
+ method: 'POST',
12
+ headers: {
13
+ Cookie: `${Cypress.env('MAIN_COOKIE_NAME')}=${cookie.value}`,
14
+ },
15
+ body: {
16
+ firstName: 'John',
17
+ lastName: 'Smith',
18
+ validationSchemaKey: 'name',
19
+ },
20
+ }).as('mutateUser')
21
+ cy.get('@mutateUser').then((updatedUser) => {
22
+ expect(updatedUser.status).to.eq(200)
23
+ expect(updatedUser.body.data.updateUser.email).to.eq(
24
+ 'temp.account@tempaccount.com'
25
+ )
26
+ })
27
+ })
28
+ })
29
+
30
+ it('mutateUser - mobile', () => {
31
+ cy.getCookie(Cypress.env('MAIN_COOKIE_NAME')).then((cookie) => {
32
+ cy.request({
33
+ url: `${Cypress.env('E2E_BASE_URL')}/mutate`,
34
+ method: 'POST',
35
+ headers: {
36
+ Cookie: `${Cypress.env('MAIN_COOKIE_NAME')}=${cookie.value}`,
37
+ },
38
+ body: {
39
+ mobile: '+447777777778',
40
+ validationSchemaKey: 'mobile',
41
+ },
42
+ }).as('mutateUser')
43
+ cy.get('@mutateUser').then((updatedUser) => {
44
+ expect(updatedUser.status).to.eq(200)
45
+ expect(updatedUser.body.data.updateUser.email).to.eq(
46
+ 'temp.account@tempaccount.com'
47
+ )
48
+ })
49
+ })
50
+ })
51
+
52
+ it('getUserQuery', () => {
53
+ cy.getCookie(Cypress.env('MAIN_COOKIE_NAME')).then((cookie) => {
54
+ cy.request({
55
+ url: `${Cypress.env('E2E_BASE_URL')}/query`,
56
+ method: 'POST',
57
+ headers: {
58
+ Cookie: `${Cypress.env('MAIN_COOKIE_NAME')}=${cookie.value}`,
59
+ },
60
+ body: {
61
+ queryFragment: 'UserProfile',
62
+ },
63
+ }).as('user')
64
+ cy.get('@user').then((response) => {
65
+ expect(response.status).to.eq(200)
66
+ expect(response.body.email).to.eq('temp.account@tempaccount.com')
67
+ expect(response.body.mobile).to.eq('+447777777778')
68
+ expect(response.body.firstName).to.eq('John')
69
+ expect(response.body.lastName).to.eq('Smith')
70
+ expect(response.body.address.city).to.eq('London')
71
+ })
72
+ })
73
+ })
74
+ it('getUserSubscription', () => {
75
+ cy.getCookie(Cypress.env('MAIN_COOKIE_NAME')).then((cookie) => {
76
+ cy.request({
77
+ url: `${Cypress.env('E2E_BASE_URL')}/query`,
78
+ method: 'POST',
79
+ headers: {
80
+ Cookie: `${Cypress.env('MAIN_COOKIE_NAME')}=${cookie.value}`,
81
+ },
82
+ body: {
83
+ queryFragment: 'UserSubscription',
84
+ },
85
+ }).as('userSubscription')
86
+ cy.get('@userSubscription').then((response) => {
87
+ expect(response.status).to.eq(200)
88
+ expect(response.body.cpn).to.eq('4AAA038681020')
89
+ assert.isArray(response.body.subscriptions)
90
+ })
91
+ })
92
+ })
93
+ })
@@ -0,0 +1,42 @@
1
+ describe('My account Payment page', () => {
2
+ beforeEach(() => {
3
+ cy.mockConsentAndVisit('/account/payment')
4
+ })
5
+
6
+ it('should load the zuora iFrame', () => {
7
+ cy.get('iframe').should('exist')
8
+ })
9
+
10
+ it('should successully send the form', () => {
11
+ if (Cypress.config('chromeWebSecurity')) {
12
+ throw new Error(
13
+ 'To get Zuora element `chromeWebSecurity` must be disabled'
14
+ )
15
+ }
16
+
17
+ cy.get('iframe').should('exist')
18
+ cy.getZuoraElement('input[name="field_creditCardHolderName"]').type(
19
+ 'Gabriel Dimitrov'
20
+ )
21
+ cy.getZuoraElement('input[name="field_creditCardNumber"]').type(
22
+ '4111 1111 1111 1111'
23
+ )
24
+ cy.getZuoraElement('input[name="field_cardSecurityCode"]').type('123')
25
+ cy.getZuoraElement('input[name="field_creditCardPostalCode"]').type(
26
+ 'E11 9HB'
27
+ )
28
+
29
+ cy.getZuoraElement('select[name="field_creditCardExpirationMonth"]').select(
30
+ '11'
31
+ )
32
+ cy.getZuoraElement('select[name="field_creditCardExpirationYear"]').select(
33
+ '2026'
34
+ )
35
+ cy.getZuoraElement('#submitButton').click()
36
+
37
+ cy.contains(
38
+ '[data-testid="toast-container"]',
39
+ 'Your payment method has been updated'
40
+ )
41
+ })
42
+ })
@@ -15,8 +15,39 @@
15
15
  /**
16
16
  * @type {Cypress.PluginConfig}
17
17
  */
18
+ import fs from 'fs'
19
+ import path from 'path'
18
20
 
19
21
  module.exports = (on, config) => {
20
22
  // `on` is used to hook into various events Cypress emits
21
23
  // `config` is the resolved Cypress config
24
+ const conf = config
25
+
26
+ const dirPath = config.integrationFolder==="./cypress/e2e" ? path.resolve('./cypress/e2e') : path.resolve('./cypress/visual')
27
+ fs.readdir(dirPath, function (err, files) {
28
+ if (err) {
29
+ return console.log('Unable to scan directory: ' + err);
30
+ }
31
+ //listing all files using forEach. For this script to work the folder must only contain folders with spec files
32
+ files.forEach(function (file) {
33
+ conf.integrationFolder = `${dirPath}/${file}`
34
+ });
35
+ return conf
36
+ });
37
+
38
+ on('task', {
39
+ log(message) {
40
+ console.log(message)
41
+
42
+ return null
43
+ },
44
+ table(message) {
45
+ console.table(message)
46
+
47
+ return null
48
+ },
49
+ })
50
+ return conf
22
51
  }
52
+
53
+ require('@applitools/eyes-cypress')(module)