@newskit-render/core 2.17.0 → 2.17.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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.17.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.17.1-alpha.0...@newskit-render/core@2.17.1) (2022-11-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [2.17.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.17.0-alpha.1...@newskit-render/core@2.17.0) (2022-11-10)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @newskit-render/core
|
|
@@ -3,7 +3,7 @@ import * as userHolidayStops from '../../fixtures/holiday-stops.json'
|
|
|
3
3
|
describe('Book a holiday stop', () => {
|
|
4
4
|
beforeEach(() => {
|
|
5
5
|
cy.GetAcsSession()
|
|
6
|
-
cy.mockConsentAndVisit('/account/holiday-stop
|
|
6
|
+
cy.mockConsentAndVisit('/account/holiday-stop')
|
|
7
7
|
})
|
|
8
8
|
|
|
9
9
|
it('should display book a holiday stop page', () => {
|
|
@@ -26,7 +26,7 @@ describe('Upcoming holiday stops', () => {
|
|
|
26
26
|
|
|
27
27
|
it('should navigate to the Upcoming holiday stops and display the list of upcoming holiday stops', () => {
|
|
28
28
|
cy.visitAndOverrideNextData(
|
|
29
|
-
'/account/holiday-stop
|
|
29
|
+
'/account/holiday-stop',
|
|
30
30
|
'props.pageProps.user.holidayStops',
|
|
31
31
|
userHolidayStops.holidayStops
|
|
32
32
|
)
|
|
@@ -45,11 +45,11 @@ describe('Upcoming holiday stops', () => {
|
|
|
45
45
|
})
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
describe('Cancel holiday stop', () => {
|
|
48
|
+
describe.skip('Cancel holiday stop', () => {
|
|
49
49
|
beforeEach(() => {
|
|
50
50
|
cy.mockConsent()
|
|
51
51
|
cy.visitAndOverrideNextData(
|
|
52
|
-
'/account/holiday-stop
|
|
52
|
+
'/account/holiday-stop',
|
|
53
53
|
'props.pageProps.user.holidayStops',
|
|
54
54
|
userHolidayStops.holidayStops
|
|
55
55
|
)
|
|
@@ -71,3 +71,77 @@ describe('Cancel holiday stop', () => {
|
|
|
71
71
|
)
|
|
72
72
|
})
|
|
73
73
|
})
|
|
74
|
+
|
|
75
|
+
describe('Add a Holiday Stop', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
cy.GetAcsSession()
|
|
78
|
+
cy.mockConsentAndVisit('/account/add/holiday-stop')
|
|
79
|
+
})
|
|
80
|
+
it('should display add holiday stop page', () => {
|
|
81
|
+
cy.get('[data-testid="introduction-title"]').contains('Add a Holiday Stop')
|
|
82
|
+
cy.get('[data-testid="create-holiday-stop"]').should('exist')
|
|
83
|
+
cy.get('[data-testid="description-block"]').contains('Choose Your Dates')
|
|
84
|
+
cy.get('[id="startDate"]').should('exist')
|
|
85
|
+
cy.get('[id="endDate"]').should('exist')
|
|
86
|
+
cy.get('[data-testid="primary-button"]').should('exist')
|
|
87
|
+
cy.get('[data-testid="secondary-button"]')
|
|
88
|
+
.should('have.attr', 'href', '/account/holiday-stop')
|
|
89
|
+
.contains('Cancel')
|
|
90
|
+
})
|
|
91
|
+
it('should able to select startDate and endDate', () => {
|
|
92
|
+
const dateFormatOptions = {
|
|
93
|
+
year: 'numeric',
|
|
94
|
+
month: 'numeric',
|
|
95
|
+
day: 'numeric',
|
|
96
|
+
}
|
|
97
|
+
cy.get('[id="startDate"]').should('be.visible').click({ force: true })
|
|
98
|
+
|
|
99
|
+
cy.get('input[name="startDate"]').type(
|
|
100
|
+
new Date('10/18/2022').toLocaleDateString('en-GB', dateFormatOptions)
|
|
101
|
+
)
|
|
102
|
+
cy.get('input[name="endDate"]').type(
|
|
103
|
+
new Date('10/20/2022').toLocaleDateString('en-GB', dateFormatOptions)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
cy.intercept('POST', '/api/account/mutate', {
|
|
107
|
+
statusCode: 200,
|
|
108
|
+
body: { data: { createUserHolidayStop: { success: true } } },
|
|
109
|
+
})
|
|
110
|
+
cy.get('[data-testid="primary-button"]')
|
|
111
|
+
.should('be.visible')
|
|
112
|
+
.click({ force: true })
|
|
113
|
+
cy.get('[data-testid="modal"]').should('exist')
|
|
114
|
+
cy.get('[data-testid="introduction-title"]').contains('Holiday Stop added')
|
|
115
|
+
cy.get('[data-testid="description-block"]').contains(
|
|
116
|
+
'You have successfully added a Holiday Stop to your account. Your account will be credited no more than 8 weeks after the holiday start date.'
|
|
117
|
+
)
|
|
118
|
+
cy.get('[aria-label="Retun to Holiday Stops"]').click()
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
describe('Edit Holiday Stops', () => {
|
|
123
|
+
beforeEach(() => {
|
|
124
|
+
cy.GetAcsSession()
|
|
125
|
+
cy.visitAndOverrideNextData(
|
|
126
|
+
'/account/edit/holiday-stop?id=a2U7Y000001r8aSUAQ',
|
|
127
|
+
'props.pageProps.data.fields',
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
value: [
|
|
131
|
+
{
|
|
132
|
+
id: 'a2U7Y000001r8aSUAQ',
|
|
133
|
+
startDate: '2022-10-12T00:00:00',
|
|
134
|
+
endDate: '2022-10-13T00:00:00',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
]
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
it('should display edit holiday stop page', () => {
|
|
142
|
+
cy.get('[data-testid="introduction-title"]').contains('Edit a Holiday Stop')
|
|
143
|
+
cy.get('[data-testid="update-holiday-stop"]').should('exist')
|
|
144
|
+
cy.get('[name="startDate"]').invoke('val').should('equal', '12/10/2022')
|
|
145
|
+
cy.get('[name="endDate"]').invoke('val').should('equal', '13/10/2022')
|
|
146
|
+
})
|
|
147
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"@emotion/styled": "11.10.4",
|
|
41
41
|
"@newskit-render/api": "^1.2.1",
|
|
42
42
|
"@newskit-render/auth": "^1.1.1",
|
|
43
|
-
"@newskit-render/checkout": "^1.5.
|
|
43
|
+
"@newskit-render/checkout": "^1.5.4",
|
|
44
44
|
"@newskit-render/feature-flags": "^1.2.0",
|
|
45
45
|
"@newskit-render/feed": "^1.2.0",
|
|
46
|
-
"@newskit-render/my-account": "^3.13.
|
|
47
|
-
"@newskit-render/shared-components": "^1.12.
|
|
48
|
-
"@newskit-render/standalone-components": "^1.9.
|
|
49
|
-
"@newskit-render/validation": "^1.3.
|
|
46
|
+
"@newskit-render/my-account": "^3.13.1",
|
|
47
|
+
"@newskit-render/shared-components": "^1.12.1",
|
|
48
|
+
"@newskit-render/standalone-components": "^1.9.2",
|
|
49
|
+
"@newskit-render/validation": "^1.3.1",
|
|
50
50
|
"cross-fetch": "3.1.5",
|
|
51
51
|
"graphql": "15.6.0",
|
|
52
52
|
"lodash.get": "4.4.2",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
import newrelic from 'newrelic'
|
|
3
|
+
import { AddField, NotFound, addComponentMap } from '@newskit-render/my-account'
|
|
4
|
+
import validation from '../../../validation'
|
|
5
|
+
import { AppContext } from '../../../context/app-context'
|
|
6
|
+
import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
|
|
7
|
+
|
|
8
|
+
const AccountAddField = (props) => {
|
|
9
|
+
const doesAddPageExist = Object.keys(addComponentMap).includes(
|
|
10
|
+
props.data.type
|
|
11
|
+
)
|
|
12
|
+
const { theme, setTheme } = useContext(AppContext)
|
|
13
|
+
const themeDropdownObject = createThemeDropdownObject(setTheme)
|
|
14
|
+
|
|
15
|
+
if (doesAddPageExist) {
|
|
16
|
+
return (
|
|
17
|
+
<AddField
|
|
18
|
+
{...props}
|
|
19
|
+
validation={validation}
|
|
20
|
+
customTheme={theme}
|
|
21
|
+
themeDropdownObject={themeDropdownObject}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
return <NotFound />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default AccountAddField
|
|
29
|
+
export const getServerSideProps = async (context) => {
|
|
30
|
+
const {
|
|
31
|
+
params: { field },
|
|
32
|
+
} = context
|
|
33
|
+
const doesAddpageExist = Object.keys(addComponentMap).includes(field)
|
|
34
|
+
|
|
35
|
+
newrelic.setTransactionName(`Account: add ${field}`)
|
|
36
|
+
|
|
37
|
+
if (!doesAddpageExist) {
|
|
38
|
+
context.res.statusCode = 404
|
|
39
|
+
// Logging the error for being captured by New Relic
|
|
40
|
+
console.error(`An error ${context.res.statusCode} occurred on server`)
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
props: { data: { type: field } },
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
EditField,
|
|
5
5
|
getProviderProps,
|
|
6
6
|
NotFound,
|
|
7
|
-
|
|
7
|
+
editComponentMap,
|
|
8
8
|
} from '@newskit-render/my-account'
|
|
9
9
|
import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
|
|
10
10
|
import { optimizelysdkKey } from '../../../config' // create-render-app effected
|
|
@@ -13,7 +13,9 @@ import { AppContext } from '../../../context/app-context'
|
|
|
13
13
|
import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
|
|
14
14
|
|
|
15
15
|
const AccountEditField = (props) => {
|
|
16
|
-
const doesEditPageExist = Object.keys(
|
|
16
|
+
const doesEditPageExist = Object.keys(editComponentMap).includes(
|
|
17
|
+
props.data.type
|
|
18
|
+
)
|
|
17
19
|
const { theme, setTheme } = useContext(AppContext)
|
|
18
20
|
const themeDropdownObject = createThemeDropdownObject(setTheme)
|
|
19
21
|
|
|
@@ -36,7 +38,7 @@ export const getServerSideProps = async (context) => {
|
|
|
36
38
|
const {
|
|
37
39
|
params: { field },
|
|
38
40
|
} = context
|
|
39
|
-
const doesEditPageExist = Object.keys(
|
|
41
|
+
const doesEditPageExist = Object.keys(editComponentMap).includes(field)
|
|
40
42
|
|
|
41
43
|
newrelic.setTransactionName(`Account: edit ${field}`)
|
|
42
44
|
|
|
File without changes
|