@financial-times/n-conversion-forms 44.5.3 → 45.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.toolkitstate/ci.json +3 -3
- package/components/__snapshots__/confirmation.spec.js.snap +50 -0
- package/components/__snapshots__/delivery-start-date.spec.js.snap +46 -9
- package/components/__snapshots__/graduation-date.spec.js.snap +3 -3
- package/components/confirmation.jsx +3 -3
- package/components/confirmation.spec.js +13 -1
- package/components/delivery-option.jsx +6 -0
- package/components/delivery-option.stories.js +34 -0
- package/components/delivery-start-date.jsx +8 -4
- package/components/delivery-start-date.spec.js +6 -0
- package/components/payment-term.jsx +22 -17
- package/components/payment-term.spec.js +102 -3
- package/dist/confirmation.jsx +4 -4
- package/dist/delivery-option.jsx +11 -3
- package/dist/delivery-start-date.jsx +7 -4
- package/dist/payment-term.jsx +11 -8
- package/package.json +1 -1
- package/utils/delivery-option-messages.js +46 -8
- package/utils/delivery-option-messages.spec.js +64 -2
package/.toolkitstate/ci.json
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`Confirmation renders appropriately if is 'Evergreen' subscription term type 1`] = `
|
|
4
|
+
<div class="ncf ncf__wrapper">
|
|
5
|
+
<div class="ncf__center">
|
|
6
|
+
<div class="ncf__icon ncf__icon--tick ncf__icon--large">
|
|
7
|
+
</div>
|
|
8
|
+
<p class="ncf__paragraph--reduced-padding ncf__paragraph--subscription-confirmation">
|
|
9
|
+
You are now subscribed to:
|
|
10
|
+
</p>
|
|
11
|
+
<h1 class="ncf__header ncf__header--confirmation">
|
|
12
|
+
</h1>
|
|
13
|
+
</div>
|
|
14
|
+
<p class="ncf__paragraph">
|
|
15
|
+
We’ve sent confirmation to your email. Make sure you check your spam folder if you don’t receive it.
|
|
16
|
+
</p>
|
|
17
|
+
<p class="ncf__paragraph">
|
|
18
|
+
Here’s a summary of your subscription:
|
|
19
|
+
</p>
|
|
20
|
+
<div class="ncf__headed-paragraph">
|
|
21
|
+
<h3 class="ncf__header">
|
|
22
|
+
Something not right?
|
|
23
|
+
</h3>
|
|
24
|
+
<p class="ncf__paragraph o3-type-body-base">
|
|
25
|
+
Go to your
|
|
26
|
+
<a href="https://www.ft.com/myaccount/personal-details"
|
|
27
|
+
target="_blank"
|
|
28
|
+
rel="noopener noreferrer"
|
|
29
|
+
data-trackable="yourAccount"
|
|
30
|
+
>
|
|
31
|
+
account settings
|
|
32
|
+
</a>
|
|
33
|
+
to view or edit your account. If you need to get in touch call us on
|
|
34
|
+
<a href="tel:+442077556248">
|
|
35
|
+
+44 (0) 207 755 6248
|
|
36
|
+
</a>
|
|
37
|
+
. Or contact us for additional support.
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
<p class="ncf__paragraph o3-type-body-base">
|
|
41
|
+
We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date. See our
|
|
42
|
+
<a href="http://help.ft.com/help/legal-privacy/terms-conditions/"
|
|
43
|
+
target="_top"
|
|
44
|
+
rel="noopener"
|
|
45
|
+
>
|
|
46
|
+
Terms & Conditions
|
|
47
|
+
</a>
|
|
48
|
+
for details on how to cancel.
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
`;
|
|
52
|
+
|
|
3
53
|
exports[`Confirmation renders appropriately if is 'Termed' subscription term type 1`] = `
|
|
4
54
|
<div class="ncf ncf__wrapper">
|
|
5
55
|
<div class="ncf__center">
|
|
@@ -13,7 +13,7 @@ exports[`DeliveryStartDate renders with a custom date 1`] = `
|
|
|
13
13
|
Start date
|
|
14
14
|
</span>
|
|
15
15
|
<span class="o-forms-title__prompt">
|
|
16
|
-
Earliest available
|
|
16
|
+
Earliest available start date: 5th November 2019
|
|
17
17
|
</span>
|
|
18
18
|
</span>
|
|
19
19
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -51,7 +51,7 @@ exports[`DeliveryStartDate renders with a custom input max value 1`] = `
|
|
|
51
51
|
Start date
|
|
52
52
|
</span>
|
|
53
53
|
<span class="o-forms-title__prompt">
|
|
54
|
-
Earliest available
|
|
54
|
+
Earliest available start date: 2
|
|
55
55
|
</span>
|
|
56
56
|
</span>
|
|
57
57
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -89,7 +89,7 @@ exports[`DeliveryStartDate renders with a custom input min value 1`] = `
|
|
|
89
89
|
Start date
|
|
90
90
|
</span>
|
|
91
91
|
<span class="o-forms-title__prompt">
|
|
92
|
-
Earliest available
|
|
92
|
+
Earliest available start date:
|
|
93
93
|
</span>
|
|
94
94
|
</span>
|
|
95
95
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -127,7 +127,7 @@ exports[`DeliveryStartDate renders with a custom input value 1`] = `
|
|
|
127
127
|
Start date
|
|
128
128
|
</span>
|
|
129
129
|
<span class="o-forms-title__prompt">
|
|
130
|
-
Earliest available
|
|
130
|
+
Earliest available start date:
|
|
131
131
|
</span>
|
|
132
132
|
</span>
|
|
133
133
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -164,7 +164,7 @@ exports[`DeliveryStartDate renders with a disabled input 1`] = `
|
|
|
164
164
|
Start date
|
|
165
165
|
</span>
|
|
166
166
|
<span class="o-forms-title__prompt">
|
|
167
|
-
Earliest available
|
|
167
|
+
Earliest available start date:
|
|
168
168
|
</span>
|
|
169
169
|
</span>
|
|
170
170
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -202,7 +202,7 @@ exports[`DeliveryStartDate renders with an error 1`] = `
|
|
|
202
202
|
Start date
|
|
203
203
|
</span>
|
|
204
204
|
<span class="o-forms-title__prompt">
|
|
205
|
-
Earliest available
|
|
205
|
+
Earliest available start date:
|
|
206
206
|
</span>
|
|
207
207
|
</span>
|
|
208
208
|
<span class="o-forms-input o-forms-input--text o-forms-input--invalid">
|
|
@@ -239,7 +239,7 @@ exports[`DeliveryStartDate renders with appropriate start message when isAddress
|
|
|
239
239
|
Start date
|
|
240
240
|
</span>
|
|
241
241
|
<span class="o-forms-title__prompt">
|
|
242
|
-
Earliest available
|
|
242
|
+
Earliest available start date:
|
|
243
243
|
</span>
|
|
244
244
|
</span>
|
|
245
245
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -263,6 +263,43 @@ exports[`DeliveryStartDate renders with appropriate start message when isAddress
|
|
|
263
263
|
</label>
|
|
264
264
|
`;
|
|
265
265
|
|
|
266
|
+
exports[`DeliveryStartDate renders with appropriate start message when isPaperVoucherDeliveryOptionOnly 1`] = `
|
|
267
|
+
<label id="deliveryStartDateField"
|
|
268
|
+
class="o-forms-field ncf__validation-error"
|
|
269
|
+
data-validate="required"
|
|
270
|
+
for="deliveryStartDate"
|
|
271
|
+
>
|
|
272
|
+
<span class="o-forms-title">
|
|
273
|
+
<span class="o-forms-title__main"
|
|
274
|
+
id="start-date-picker-title-span"
|
|
275
|
+
>
|
|
276
|
+
Start date
|
|
277
|
+
</span>
|
|
278
|
+
<span class="o-forms-title__prompt">
|
|
279
|
+
Earliest available start date:
|
|
280
|
+
</span>
|
|
281
|
+
</span>
|
|
282
|
+
<span class="o-forms-input o-forms-input--text">
|
|
283
|
+
<input type="date"
|
|
284
|
+
id="deliveryStartDate"
|
|
285
|
+
name="deliveryStartDate"
|
|
286
|
+
data-trackable="field-deliveryStartDate"
|
|
287
|
+
aria-required="true"
|
|
288
|
+
required
|
|
289
|
+
value
|
|
290
|
+
>
|
|
291
|
+
<span class="o-forms-input__error">
|
|
292
|
+
Please select a valid start date
|
|
293
|
+
</span>
|
|
294
|
+
</span>
|
|
295
|
+
<p>
|
|
296
|
+
Your vouchers will be valid from:
|
|
297
|
+
<strong class="js-start-date-text">
|
|
298
|
+
</strong>
|
|
299
|
+
</p>
|
|
300
|
+
</label>
|
|
301
|
+
`;
|
|
302
|
+
|
|
266
303
|
exports[`DeliveryStartDate renders with country different than default 1`] = `
|
|
267
304
|
<label id="deliveryStartDateField"
|
|
268
305
|
class="o-forms-field ncf__validation-error"
|
|
@@ -276,7 +313,7 @@ exports[`DeliveryStartDate renders with country different than default 1`] = `
|
|
|
276
313
|
Start date
|
|
277
314
|
</span>
|
|
278
315
|
<span class="o-forms-title__prompt">
|
|
279
|
-
Earliest available
|
|
316
|
+
Earliest available start date:
|
|
280
317
|
</span>
|
|
281
318
|
</span>
|
|
282
319
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -313,7 +350,7 @@ exports[`DeliveryStartDate renders with default props 1`] = `
|
|
|
313
350
|
Start date
|
|
314
351
|
</span>
|
|
315
352
|
<span class="o-forms-title__prompt">
|
|
316
|
-
Earliest available
|
|
353
|
+
Earliest available start date:
|
|
317
354
|
</span>
|
|
318
355
|
</span>
|
|
319
356
|
<span class="o-forms-input o-forms-input--text">
|
|
@@ -71,9 +71,6 @@ exports[`GraduationDate renders with default props 1`] = `
|
|
|
71
71
|
name="graduationDateYear"
|
|
72
72
|
aria-required="false"
|
|
73
73
|
>
|
|
74
|
-
<option value="2021">
|
|
75
|
-
2021
|
|
76
|
-
</option>
|
|
77
74
|
<option value="2022">
|
|
78
75
|
2022
|
|
79
76
|
</option>
|
|
@@ -98,6 +95,9 @@ exports[`GraduationDate renders with default props 1`] = `
|
|
|
98
95
|
<option value="2029">
|
|
99
96
|
2029
|
|
100
97
|
</option>
|
|
98
|
+
<option value="2030">
|
|
99
|
+
2030
|
|
100
|
+
</option>
|
|
101
101
|
</select>
|
|
102
102
|
</span>
|
|
103
103
|
</div>
|
|
@@ -8,7 +8,7 @@ export function Confirmation({
|
|
|
8
8
|
isTrial = false,
|
|
9
9
|
isB2cPartnership = false,
|
|
10
10
|
b2cPartnershipCopy = [],
|
|
11
|
-
|
|
11
|
+
isEvergreenSubscriptionTermType = true,
|
|
12
12
|
offer = '',
|
|
13
13
|
email = EMAIL_DEFAULT_TEXT,
|
|
14
14
|
details = null,
|
|
@@ -114,7 +114,7 @@ export function Confirmation({
|
|
|
114
114
|
</p>
|
|
115
115
|
</div>
|
|
116
116
|
<p className="ncf__paragraph o3-type-body-base">
|
|
117
|
-
{
|
|
117
|
+
{isEvergreenSubscriptionTermType
|
|
118
118
|
? 'We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date. '
|
|
119
119
|
: ''}
|
|
120
120
|
{'See our '}
|
|
@@ -136,7 +136,7 @@ Confirmation.propTypes = {
|
|
|
136
136
|
isTrial: PropTypes.bool,
|
|
137
137
|
isB2cPartnership: PropTypes.bool,
|
|
138
138
|
b2cPartnershipCopy: PropTypes.array,
|
|
139
|
-
|
|
139
|
+
isEvergreenSubscriptionTermType: PropTypes.bool,
|
|
140
140
|
offer: PropTypes.string.isRequired,
|
|
141
141
|
email: PropTypes.string,
|
|
142
142
|
details: PropTypes.arrayOf(
|
|
@@ -29,8 +29,20 @@ describe('Confirmation', () => {
|
|
|
29
29
|
expect(Confirmation).toRenderCorrectly(props);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
it("renders appropriately if is 'Evergreen' subscription term type", () => {
|
|
33
|
+
const props = {
|
|
34
|
+
isEvergreenSubscriptionTermType: true,
|
|
35
|
+
isTermedSubscriptionTermType: false,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(Confirmation).toRenderCorrectly(props);
|
|
39
|
+
});
|
|
40
|
+
|
|
32
41
|
it("renders appropriately if is 'Termed' subscription term type", () => {
|
|
33
|
-
const props = {
|
|
42
|
+
const props = {
|
|
43
|
+
isEvergreenSubscriptionTermType: false,
|
|
44
|
+
isTermedSubscriptionTermType: true,
|
|
45
|
+
};
|
|
34
46
|
|
|
35
47
|
expect(Confirmation).toRenderCorrectly(props);
|
|
36
48
|
});
|
|
@@ -10,6 +10,8 @@ export function DeliveryOption({
|
|
|
10
10
|
productCode = undefined,
|
|
11
11
|
options = [],
|
|
12
12
|
isSingle = false,
|
|
13
|
+
isEvergreenSubscriptionTermType = true,
|
|
14
|
+
isTermedSubscriptionTermType = false,
|
|
13
15
|
}) {
|
|
14
16
|
const divClassName = classNames([
|
|
15
17
|
'o-forms-field',
|
|
@@ -34,6 +36,8 @@ export function DeliveryOption({
|
|
|
34
36
|
option,
|
|
35
37
|
shippingZone,
|
|
36
38
|
countryCode,
|
|
39
|
+
isEvergreenSubscriptionTermType,
|
|
40
|
+
isTermedSubscriptionTermType,
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
if (!isValidDeliveryOption || !deliveryOptionValue) {
|
|
@@ -96,4 +100,6 @@ DeliveryOption.propTypes = {
|
|
|
96
100
|
})
|
|
97
101
|
),
|
|
98
102
|
isSingle: PropTypes.bool,
|
|
103
|
+
isEvergreenSubscriptionTermType: PropTypes.bool,
|
|
104
|
+
isTermedSubscriptionTermType: PropTypes.bool,
|
|
99
105
|
};
|
|
@@ -34,6 +34,40 @@ Basic.args = {
|
|
|
34
34
|
],
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
export const UKPaperVoucherEvergreenDeliveryOptions = (args) => (
|
|
38
|
+
<div className="ncf">
|
|
39
|
+
<DeliveryOption {...args} />
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
UKPaperVoucherEvergreenDeliveryOptions.args = {
|
|
43
|
+
country: 'GBR',
|
|
44
|
+
options: [
|
|
45
|
+
{
|
|
46
|
+
value: 'PV',
|
|
47
|
+
isValidDeliveryOption: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
isEvergreenSubscriptionTermType: true,
|
|
51
|
+
isTermedSubscriptionTermType: false,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const UKPaperVoucherTermedDeliveryOptions = (args) => (
|
|
55
|
+
<div className="ncf">
|
|
56
|
+
<DeliveryOption {...args} />
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
UKPaperVoucherTermedDeliveryOptions.args = {
|
|
60
|
+
country: 'GBR',
|
|
61
|
+
options: [
|
|
62
|
+
{
|
|
63
|
+
value: 'PV',
|
|
64
|
+
isValidDeliveryOption: true,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
isEvergreenSubscriptionTermType: false,
|
|
68
|
+
isTermedSubscriptionTermType: true,
|
|
69
|
+
};
|
|
70
|
+
|
|
37
71
|
export const UnitedStates5or6DaysWeekDeliveryOptions = (args) => (
|
|
38
72
|
<div className="ncf">
|
|
39
73
|
<DeliveryOption {...args} />
|
|
@@ -10,6 +10,7 @@ export function DeliveryStartDate({
|
|
|
10
10
|
max = null,
|
|
11
11
|
isDisabled = false,
|
|
12
12
|
isAddressUpdate = false,
|
|
13
|
+
isPaperVoucherDeliveryOptionOnly = false,
|
|
13
14
|
}) {
|
|
14
15
|
const inputWrapperClassNames = classNames([
|
|
15
16
|
'o-forms-input',
|
|
@@ -30,9 +31,11 @@ export function DeliveryStartDate({
|
|
|
30
31
|
defaultValue: value,
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const startMessage =
|
|
34
|
-
? '
|
|
35
|
-
:
|
|
34
|
+
const startMessage = isPaperVoucherDeliveryOptionOnly
|
|
35
|
+
? 'Your vouchers will be valid from:'
|
|
36
|
+
: isAddressUpdate
|
|
37
|
+
? 'We’ll start delivering to this address from:'
|
|
38
|
+
: 'The first print edition you will receive is:';
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
41
|
<label
|
|
@@ -46,7 +49,7 @@ export function DeliveryStartDate({
|
|
|
46
49
|
Start date
|
|
47
50
|
</span>
|
|
48
51
|
<span className="o-forms-title__prompt">
|
|
49
|
-
Earliest available
|
|
52
|
+
Earliest available start date: {date}
|
|
50
53
|
</span>
|
|
51
54
|
</span>
|
|
52
55
|
|
|
@@ -72,4 +75,5 @@ DeliveryStartDate.propTypes = {
|
|
|
72
75
|
max: PropTypes.string,
|
|
73
76
|
isDisabled: PropTypes.bool,
|
|
74
77
|
isAddressUpdate: PropTypes.bool,
|
|
78
|
+
isPaperVoucherDeliveryOptionOnly: PropTypes.bool,
|
|
75
79
|
};
|
|
@@ -52,6 +52,12 @@ describe('DeliveryStartDate', () => {
|
|
|
52
52
|
expect(DeliveryStartDate).toRenderCorrectly(props);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
it('renders with appropriate start message when isPaperVoucherDeliveryOptionOnly', () => {
|
|
56
|
+
const props = { isPaperVoucherDeliveryOptionOnly: true };
|
|
57
|
+
|
|
58
|
+
expect(DeliveryStartDate).toRenderCorrectly(props);
|
|
59
|
+
});
|
|
60
|
+
|
|
55
61
|
it('renders with country different than default', () => {
|
|
56
62
|
const props = { country: 'USA' };
|
|
57
63
|
|
|
@@ -13,6 +13,7 @@ export function PaymentTerm({
|
|
|
13
13
|
largePrice = false,
|
|
14
14
|
optionsInARow = false,
|
|
15
15
|
billingCountry = '',
|
|
16
|
+
isEvergreenSubscriptionTermType = true,
|
|
16
17
|
isTermedSubscriptionTermType = false,
|
|
17
18
|
}) {
|
|
18
19
|
/**
|
|
@@ -162,7 +163,6 @@ export function PaymentTerm({
|
|
|
162
163
|
</span>
|
|
163
164
|
),
|
|
164
165
|
renewsText: (renewalPeriod) =>
|
|
165
|
-
!isTermedSubscriptionTermType &&
|
|
166
166
|
Boolean(renewalPeriod) && (
|
|
167
167
|
<p className="ncf__payment-term__renews-text">
|
|
168
168
|
Renews every {renewalPeriod} unless cancelled
|
|
@@ -228,7 +228,8 @@ export function PaymentTerm({
|
|
|
228
228
|
<div className="ncf__payment-term__description">
|
|
229
229
|
{nameMap[option.name].price(option.price)}
|
|
230
230
|
{nameMap[option.name].monthlyPrice(option.monthlyPrice)}
|
|
231
|
-
{
|
|
231
|
+
{isEvergreenSubscriptionTermType &&
|
|
232
|
+
nameMap[option.name].renewsText()}
|
|
232
233
|
{/* Remove this discount text temporarily in favour of monthly price */}
|
|
233
234
|
{/* <br />Save up to 25% when you pay annually */}
|
|
234
235
|
</div>
|
|
@@ -246,7 +247,8 @@ export function PaymentTerm({
|
|
|
246
247
|
option.value
|
|
247
248
|
)
|
|
248
249
|
)}
|
|
249
|
-
{
|
|
250
|
+
{isEvergreenSubscriptionTermType &&
|
|
251
|
+
nameMap['custom'].renewsText(getTimeFromPeriod(option.value))}
|
|
250
252
|
</div>
|
|
251
253
|
) : (
|
|
252
254
|
<div>
|
|
@@ -342,20 +344,7 @@ export function PaymentTerm({
|
|
|
342
344
|
|
|
343
345
|
{showLegal && (
|
|
344
346
|
<div className="ncf__payment-term__legal">
|
|
345
|
-
{
|
|
346
|
-
<p className="o3-type-body-base">
|
|
347
|
-
Find out more about our cancellation policy in our{' '}
|
|
348
|
-
<a
|
|
349
|
-
href="https://help.ft.com/legal-privacy/terms-and-conditions/"
|
|
350
|
-
title="FT Legal Terms and Conditions help page"
|
|
351
|
-
target="_blank"
|
|
352
|
-
rel="noopener noreferrer"
|
|
353
|
-
>
|
|
354
|
-
Terms & Conditions
|
|
355
|
-
</a>
|
|
356
|
-
.
|
|
357
|
-
</p>
|
|
358
|
-
) : (
|
|
347
|
+
{isEvergreenSubscriptionTermType && (
|
|
359
348
|
<React.Fragment>
|
|
360
349
|
<p>
|
|
361
350
|
With all subscription types, we will automatically renew your
|
|
@@ -378,6 +367,21 @@ export function PaymentTerm({
|
|
|
378
367
|
</p>
|
|
379
368
|
</React.Fragment>
|
|
380
369
|
)}
|
|
370
|
+
|
|
371
|
+
{isTermedSubscriptionTermType && (
|
|
372
|
+
<p className="o3-type-body-base">
|
|
373
|
+
Find out more about our cancellation policy in our{' '}
|
|
374
|
+
<a
|
|
375
|
+
href="https://help.ft.com/legal-privacy/terms-and-conditions/"
|
|
376
|
+
title="FT Legal Terms and Conditions help page"
|
|
377
|
+
target="_blank"
|
|
378
|
+
rel="noopener noreferrer"
|
|
379
|
+
>
|
|
380
|
+
Terms & Conditions
|
|
381
|
+
</a>
|
|
382
|
+
.
|
|
383
|
+
</p>
|
|
384
|
+
)}
|
|
381
385
|
</div>
|
|
382
386
|
)}
|
|
383
387
|
</div>
|
|
@@ -411,6 +415,7 @@ PaymentTerm.propTypes = {
|
|
|
411
415
|
fulfilmentOption: PropTypes.string,
|
|
412
416
|
})
|
|
413
417
|
),
|
|
418
|
+
isEvergreenSubscriptionTermType: PropTypes.bool,
|
|
414
419
|
isTermedSubscriptionTermType: PropTypes.bool,
|
|
415
420
|
showLegal: PropTypes.bool,
|
|
416
421
|
largePrice: PropTypes.bool,
|
|
@@ -117,7 +117,75 @@ describe('PaymentTerm', () => {
|
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
describe('
|
|
120
|
+
describe('isEvergreenSubscriptionTermType is true; isTermedSubscriptionTermType is false', () => {
|
|
121
|
+
describe('pre-defined option name (i.e. frequency)', () => {
|
|
122
|
+
const ANNUAL_FREQUENCY = 'annual';
|
|
123
|
+
const QUARTERLY_FREQUENCY = 'quarterly';
|
|
124
|
+
const MONTHLY_FREQUENCY = 'monthly';
|
|
125
|
+
|
|
126
|
+
[ANNUAL_FREQUENCY, QUARTERLY_FREQUENCY, MONTHLY_FREQUENCY].forEach(
|
|
127
|
+
(frequency) => {
|
|
128
|
+
const FREQUENCY_TO_RENEWAL_TEXT_MAP = {
|
|
129
|
+
[ANNUAL_FREQUENCY]: 'Renews annually unless cancelled',
|
|
130
|
+
[QUARTERLY_FREQUENCY]: 'Renews quarterly unless cancelled',
|
|
131
|
+
[MONTHLY_FREQUENCY]: 'Renews monthly unless cancelled',
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
describe(`${frequency} option`, () => {
|
|
135
|
+
const options = [
|
|
136
|
+
{
|
|
137
|
+
name: frequency,
|
|
138
|
+
value: frequency,
|
|
139
|
+
price: '£20.00',
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
it(`renders '${FREQUENCY_TO_RENEWAL_TEXT_MAP[frequency]}' when true`, () => {
|
|
144
|
+
const wrapper = shallow(
|
|
145
|
+
<PaymentTerm
|
|
146
|
+
options={options}
|
|
147
|
+
isEvergreenSubscriptionTermType={true}
|
|
148
|
+
isTermedSubscriptionTermType={false}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
expect(
|
|
152
|
+
wrapper.find('.ncf__payment-term__renews-text').exists()
|
|
153
|
+
).toBe(true);
|
|
154
|
+
expect(
|
|
155
|
+
wrapper.find('.ncf__payment-term__renews-text').text()
|
|
156
|
+
).toBe(FREQUENCY_TO_RENEWAL_TEXT_MAP[frequency]);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('custom option with period provided', () => {
|
|
164
|
+
const options = [
|
|
165
|
+
{
|
|
166
|
+
price: '£50.00',
|
|
167
|
+
amount: '50.00',
|
|
168
|
+
currency: 'GBP',
|
|
169
|
+
value: 'P6M',
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
it('renders renewal text for custom terms that specify a period', () => {
|
|
174
|
+
const wrapper = shallow(
|
|
175
|
+
<PaymentTerm
|
|
176
|
+
options={options}
|
|
177
|
+
isEvergreenSubscriptionTermType={true}
|
|
178
|
+
isTermedSubscriptionTermType={false}
|
|
179
|
+
/>
|
|
180
|
+
);
|
|
181
|
+
expect(wrapper.find('.ncf__payment-term__renews-text').text()).toBe(
|
|
182
|
+
'Renews every 6 months unless cancelled'
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('isEvergreenSubscriptionTermType is false; isTermedSubscriptionTermType is true', () => {
|
|
121
189
|
describe('options include duration expressed in weeks', () => {
|
|
122
190
|
const options = [
|
|
123
191
|
{
|
|
@@ -127,7 +195,11 @@ describe('PaymentTerm', () => {
|
|
|
127
195
|
},
|
|
128
196
|
];
|
|
129
197
|
const wrapper = shallow(
|
|
130
|
-
<PaymentTerm
|
|
198
|
+
<PaymentTerm
|
|
199
|
+
options={options}
|
|
200
|
+
isEvergreenSubscriptionTermType={false}
|
|
201
|
+
isTermedSubscriptionTermType={true}
|
|
202
|
+
/>
|
|
131
203
|
);
|
|
132
204
|
|
|
133
205
|
it('renders subscription term as title', () => {
|
|
@@ -154,7 +226,11 @@ describe('PaymentTerm', () => {
|
|
|
154
226
|
},
|
|
155
227
|
];
|
|
156
228
|
const wrapper = shallow(
|
|
157
|
-
<PaymentTerm
|
|
229
|
+
<PaymentTerm
|
|
230
|
+
options={options}
|
|
231
|
+
isEvergreenSubscriptionTermType={false}
|
|
232
|
+
isTermedSubscriptionTermType={true}
|
|
233
|
+
/>
|
|
158
234
|
);
|
|
159
235
|
|
|
160
236
|
it('renders subscription term as title', () => {
|
|
@@ -171,6 +247,29 @@ describe('PaymentTerm', () => {
|
|
|
171
247
|
);
|
|
172
248
|
});
|
|
173
249
|
});
|
|
250
|
+
|
|
251
|
+
describe('renewal text', () => {
|
|
252
|
+
const options = [
|
|
253
|
+
{
|
|
254
|
+
price: '£19.00',
|
|
255
|
+
amount: '19.00',
|
|
256
|
+
value: 'P8W',
|
|
257
|
+
},
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
it('does not render renewal text for custom terms', () => {
|
|
261
|
+
const wrapper = shallow(
|
|
262
|
+
<PaymentTerm
|
|
263
|
+
options={options}
|
|
264
|
+
isEvergreenSubscriptionTermType={false}
|
|
265
|
+
isTermedSubscriptionTermType={true}
|
|
266
|
+
/>
|
|
267
|
+
);
|
|
268
|
+
expect(wrapper.find('.ncf__payment-term__renews-text').exists()).toBe(
|
|
269
|
+
false
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
174
273
|
});
|
|
175
274
|
|
|
176
275
|
describe('getDisplayName', () => {
|
package/dist/confirmation.jsx
CHANGED
|
@@ -18,8 +18,8 @@ function Confirmation(_ref) {
|
|
|
18
18
|
isB2cPartnership = _ref$isB2cPartnership === void 0 ? false : _ref$isB2cPartnership,
|
|
19
19
|
_ref$b2cPartnershipCo = _ref.b2cPartnershipCopy,
|
|
20
20
|
b2cPartnershipCopy = _ref$b2cPartnershipCo === void 0 ? [] : _ref$b2cPartnershipCo,
|
|
21
|
-
_ref$
|
|
22
|
-
|
|
21
|
+
_ref$isEvergreenSubsc = _ref.isEvergreenSubscriptionTermType,
|
|
22
|
+
isEvergreenSubscriptionTermType = _ref$isEvergreenSubsc === void 0 ? true : _ref$isEvergreenSubsc,
|
|
23
23
|
_ref$offer = _ref.offer,
|
|
24
24
|
offer = _ref$offer === void 0 ? '' : _ref$offer,
|
|
25
25
|
_ref$email = _ref.email,
|
|
@@ -95,7 +95,7 @@ function Confirmation(_ref) {
|
|
|
95
95
|
href: "tel:+442077556248"
|
|
96
96
|
}, "+44 (0) 207 755 6248"), ". Or contact us for additional support.")), /*#__PURE__*/_react["default"].createElement("p", {
|
|
97
97
|
className: "ncf__paragraph o3-type-body-base"
|
|
98
|
-
},
|
|
98
|
+
}, isEvergreenSubscriptionTermType ? 'We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date. ' : '', 'See our ', /*#__PURE__*/_react["default"].createElement("a", {
|
|
99
99
|
href: "http://help.ft.com/help/legal-privacy/terms-conditions/",
|
|
100
100
|
target: "_top",
|
|
101
101
|
rel: "noopener"
|
|
@@ -105,7 +105,7 @@ Confirmation.propTypes = {
|
|
|
105
105
|
isTrial: _propTypes["default"].bool,
|
|
106
106
|
isB2cPartnership: _propTypes["default"].bool,
|
|
107
107
|
b2cPartnershipCopy: _propTypes["default"].array,
|
|
108
|
-
|
|
108
|
+
isEvergreenSubscriptionTermType: _propTypes["default"].bool,
|
|
109
109
|
offer: _propTypes["default"].string.isRequired,
|
|
110
110
|
email: _propTypes["default"].string,
|
|
111
111
|
details: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
package/dist/delivery-option.jsx
CHANGED
|
@@ -19,7 +19,11 @@ function DeliveryOption(_ref) {
|
|
|
19
19
|
_ref$options = _ref.options,
|
|
20
20
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
21
21
|
_ref$isSingle = _ref.isSingle,
|
|
22
|
-
isSingle = _ref$isSingle === void 0 ? false : _ref$isSingle
|
|
22
|
+
isSingle = _ref$isSingle === void 0 ? false : _ref$isSingle,
|
|
23
|
+
_ref$isEvergreenSubsc = _ref.isEvergreenSubscriptionTermType,
|
|
24
|
+
isEvergreenSubscriptionTermType = _ref$isEvergreenSubsc === void 0 ? true : _ref$isEvergreenSubsc,
|
|
25
|
+
_ref$isTermedSubscrip = _ref.isTermedSubscriptionTermType,
|
|
26
|
+
isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip;
|
|
23
27
|
var divClassName = (0, _classnames["default"])(['o-forms-field', 'ncf__delivery-option', {
|
|
24
28
|
'ncf__delivery-option--single': isSingle
|
|
25
29
|
}]);
|
|
@@ -39,7 +43,9 @@ function DeliveryOption(_ref) {
|
|
|
39
43
|
productCode: productCode,
|
|
40
44
|
option: option,
|
|
41
45
|
shippingZone: shippingZone,
|
|
42
|
-
countryCode: countryCode
|
|
46
|
+
countryCode: countryCode,
|
|
47
|
+
isEvergreenSubscriptionTermType: isEvergreenSubscriptionTermType,
|
|
48
|
+
isTermedSubscriptionTermType: isTermedSubscriptionTermType
|
|
43
49
|
});
|
|
44
50
|
if (!isValidDeliveryOption || !deliveryOptionValue) {
|
|
45
51
|
return null;
|
|
@@ -81,5 +87,7 @@ DeliveryOption.propTypes = {
|
|
|
81
87
|
flightMarket: _propTypes["default"].bool,
|
|
82
88
|
mailDelivery: _propTypes["default"].bool
|
|
83
89
|
})),
|
|
84
|
-
isSingle: _propTypes["default"].bool
|
|
90
|
+
isSingle: _propTypes["default"].bool,
|
|
91
|
+
isEvergreenSubscriptionTermType: _propTypes["default"].bool,
|
|
92
|
+
isTermedSubscriptionTermType: _propTypes["default"].bool
|
|
85
93
|
};
|
|
@@ -25,7 +25,9 @@ function DeliveryStartDate(_ref) {
|
|
|
25
25
|
_ref$isDisabled = _ref.isDisabled,
|
|
26
26
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
27
27
|
_ref$isAddressUpdate = _ref.isAddressUpdate,
|
|
28
|
-
isAddressUpdate = _ref$isAddressUpdate === void 0 ? false : _ref$isAddressUpdate
|
|
28
|
+
isAddressUpdate = _ref$isAddressUpdate === void 0 ? false : _ref$isAddressUpdate,
|
|
29
|
+
_ref$isPaperVoucherDe = _ref.isPaperVoucherDeliveryOptionOnly,
|
|
30
|
+
isPaperVoucherDeliveryOptionOnly = _ref$isPaperVoucherDe === void 0 ? false : _ref$isPaperVoucherDe;
|
|
29
31
|
var inputWrapperClassNames = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--text', {
|
|
30
32
|
'o-forms-input--invalid': hasError
|
|
31
33
|
}]);
|
|
@@ -44,7 +46,7 @@ function DeliveryStartDate(_ref) {
|
|
|
44
46
|
disabled: isDisabled,
|
|
45
47
|
defaultValue: value
|
|
46
48
|
});
|
|
47
|
-
var startMessage = isAddressUpdate ? 'We’ll start delivering to this address from:' : 'The first print edition you will receive is:';
|
|
49
|
+
var startMessage = isPaperVoucherDeliveryOptionOnly ? 'Your vouchers will be valid from:' : isAddressUpdate ? 'We’ll start delivering to this address from:' : 'The first print edition you will receive is:';
|
|
48
50
|
return /*#__PURE__*/_react["default"].createElement("label", {
|
|
49
51
|
id: "deliveryStartDateField",
|
|
50
52
|
className: "o-forms-field ncf__validation-error",
|
|
@@ -57,7 +59,7 @@ function DeliveryStartDate(_ref) {
|
|
|
57
59
|
id: "start-date-picker-title-span"
|
|
58
60
|
}, "Start date"), /*#__PURE__*/_react["default"].createElement("span", {
|
|
59
61
|
className: "o-forms-title__prompt"
|
|
60
|
-
}, "Earliest available
|
|
62
|
+
}, "Earliest available start date: ", date)), /*#__PURE__*/_react["default"].createElement("span", {
|
|
61
63
|
className: inputWrapperClassNames
|
|
62
64
|
}, /*#__PURE__*/_react["default"].createElement("input", inputProps), /*#__PURE__*/_react["default"].createElement("span", {
|
|
63
65
|
className: "o-forms-input__error"
|
|
@@ -73,5 +75,6 @@ DeliveryStartDate.propTypes = {
|
|
|
73
75
|
min: _propTypes["default"].string,
|
|
74
76
|
max: _propTypes["default"].string,
|
|
75
77
|
isDisabled: _propTypes["default"].bool,
|
|
76
|
-
isAddressUpdate: _propTypes["default"].bool
|
|
78
|
+
isAddressUpdate: _propTypes["default"].bool,
|
|
79
|
+
isPaperVoucherDeliveryOptionOnly: _propTypes["default"].bool
|
|
77
80
|
};
|
package/dist/payment-term.jsx
CHANGED
|
@@ -31,6 +31,8 @@ function PaymentTerm(_ref) {
|
|
|
31
31
|
optionsInARow = _ref$optionsInARow === void 0 ? false : _ref$optionsInARow,
|
|
32
32
|
_ref$billingCountry = _ref.billingCountry,
|
|
33
33
|
billingCountry = _ref$billingCountry === void 0 ? '' : _ref$billingCountry,
|
|
34
|
+
_ref$isEvergreenSubsc = _ref.isEvergreenSubscriptionTermType,
|
|
35
|
+
isEvergreenSubscriptionTermType = _ref$isEvergreenSubsc === void 0 ? true : _ref$isEvergreenSubsc,
|
|
34
36
|
_ref$isTermedSubscrip = _ref.isTermedSubscriptionTermType,
|
|
35
37
|
isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip;
|
|
36
38
|
/**
|
|
@@ -160,7 +162,7 @@ function PaymentTerm(_ref) {
|
|
|
160
162
|
}, _monthlyPrice), ' ', "per month");
|
|
161
163
|
},
|
|
162
164
|
renewsText: function renewsText(renewalPeriod) {
|
|
163
|
-
return
|
|
165
|
+
return Boolean(renewalPeriod) && /*#__PURE__*/_react["default"].createElement("p", {
|
|
164
166
|
className: "ncf__payment-term__renews-text"
|
|
165
167
|
}, "Renews every ", renewalPeriod, " unless cancelled");
|
|
166
168
|
}
|
|
@@ -197,12 +199,12 @@ function PaymentTerm(_ref) {
|
|
|
197
199
|
className: "ncf__payment-term__trial-price"
|
|
198
200
|
}, option.trialPrice), /*#__PURE__*/_react["default"].createElement("br", null), nameMap[option.name] && nameMap[option.name].trialPrice(option.price)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, nameMap[option.name] ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
199
201
|
className: "ncf__payment-term__description"
|
|
200
|
-
}, nameMap[option.name].price(option.price), nameMap[option.name].monthlyPrice(option.monthlyPrice), nameMap[option.name].renewsText()) :
|
|
202
|
+
}, nameMap[option.name].price(option.price), nameMap[option.name].monthlyPrice(option.monthlyPrice), isEvergreenSubscriptionTermType && nameMap[option.name].renewsText()) :
|
|
201
203
|
// this should cover the cases different than annual, quarterly and monthly
|
|
202
204
|
// for those containing period on option.value, render custom template, for the rest keep legacy render
|
|
203
205
|
isValidPeriod(option.value) ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
204
206
|
className: "ncf__payment-term__description"
|
|
205
|
-
}, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) : getMonthlyPriceFromPeriod(option.amount, option.currency, option.value)), nameMap['custom'].renewsText(getTimeFromPeriod(option.value))) : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
207
|
+
}, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) : getMonthlyPriceFromPeriod(option.amount, option.currency, option.value)), isEvergreenSubscriptionTermType && nameMap['custom'].renewsText(getTimeFromPeriod(option.value))) : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
206
208
|
className: largePrice ? 'ncf__payment-term__large-price' : ''
|
|
207
209
|
}, option.price), option.chargeOnText && /*#__PURE__*/_react["default"].createElement("p", {
|
|
208
210
|
className: "ncf__payment-term__charge-on-text"
|
|
@@ -256,21 +258,21 @@ function PaymentTerm(_ref) {
|
|
|
256
258
|
return createPaymentTerm(option);
|
|
257
259
|
})), showLegal && /*#__PURE__*/_react["default"].createElement("div", {
|
|
258
260
|
className: "ncf__payment-term__legal"
|
|
259
|
-
},
|
|
261
|
+
}, isEvergreenSubscriptionTermType && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("p", null, "With all subscription types, we will automatically renew your subscription using the payment method provided unless you cancel before your renewal date."), /*#__PURE__*/_react["default"].createElement("p", {
|
|
260
262
|
className: "o3-type-body-base"
|
|
261
|
-
}, "Find out more about our cancellation policy in our", ' ', /*#__PURE__*/_react["default"].createElement("a", {
|
|
263
|
+
}, "We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our", ' ', /*#__PURE__*/_react["default"].createElement("a", {
|
|
262
264
|
href: "https://help.ft.com/legal-privacy/terms-and-conditions/",
|
|
263
265
|
title: "FT Legal Terms and Conditions help page",
|
|
264
266
|
target: "_blank",
|
|
265
267
|
rel: "noopener noreferrer"
|
|
266
|
-
}, "Terms & Conditions"), ".")
|
|
268
|
+
}, "Terms & Conditions"), ".")), isTermedSubscriptionTermType && /*#__PURE__*/_react["default"].createElement("p", {
|
|
267
269
|
className: "o3-type-body-base"
|
|
268
|
-
}, "
|
|
270
|
+
}, "Find out more about our cancellation policy in our", ' ', /*#__PURE__*/_react["default"].createElement("a", {
|
|
269
271
|
href: "https://help.ft.com/legal-privacy/terms-and-conditions/",
|
|
270
272
|
title: "FT Legal Terms and Conditions help page",
|
|
271
273
|
target: "_blank",
|
|
272
274
|
rel: "noopener noreferrer"
|
|
273
|
-
}, "Terms & Conditions"), ".")))
|
|
275
|
+
}, "Terms & Conditions"), ".")));
|
|
274
276
|
}
|
|
275
277
|
PaymentTerm.propTypes = {
|
|
276
278
|
fieldId: _propTypes["default"].string,
|
|
@@ -297,6 +299,7 @@ PaymentTerm.propTypes = {
|
|
|
297
299
|
chargeOnText: _propTypes["default"].string,
|
|
298
300
|
fulfilmentOption: _propTypes["default"].string
|
|
299
301
|
})),
|
|
302
|
+
isEvergreenSubscriptionTermType: _propTypes["default"].bool,
|
|
300
303
|
isTermedSubscriptionTermType: _propTypes["default"].bool,
|
|
301
304
|
showLegal: _propTypes["default"].bool,
|
|
302
305
|
largePrice: _propTypes["default"].bool,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "45.1.0",
|
|
4
4
|
"description": "Containing jsx components and styles for forms included on Accounts and Acquisition apps (next-signup, next-profile, next-retention, etc).",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,27 +28,44 @@ const USA_COUNTRY_CODE = 'USA';
|
|
|
28
28
|
const countryCodeToCustomDeliveryOptionsMap = {
|
|
29
29
|
[JAPAN_COUNTRY_CODE]: {
|
|
30
30
|
HD: {
|
|
31
|
-
description:
|
|
31
|
+
description: () =>
|
|
32
32
|
'Enjoy delivery of the newspaper to your home or office address.',
|
|
33
33
|
},
|
|
34
34
|
ML: {
|
|
35
|
-
description:
|
|
35
|
+
description: () =>
|
|
36
36
|
'Enjoy delivery of the newspaper to your home or office address.',
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
[UK_COUNTRY_CODE]: {
|
|
40
40
|
PV: {
|
|
41
41
|
title: 'Paper vouchers',
|
|
42
|
-
description:
|
|
43
|
-
|
|
42
|
+
description: ({
|
|
43
|
+
isEvergreenSubscriptionTermType,
|
|
44
|
+
isTermedSubscriptionTermType,
|
|
45
|
+
}) => {
|
|
46
|
+
if (isEvergreenSubscriptionTermType) {
|
|
47
|
+
return '13-week voucher pack delivered quarterly and redeemable at retailers nationwide.';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isTermedSubscriptionTermType) {
|
|
51
|
+
// Note: This wording relates to a specific offer: UK Retail Sampling
|
|
52
|
+
// • Production environment offer ID: f9f6383d-98fd-4655-9bc8-2b22bfda8bab
|
|
53
|
+
// • Test environment offer ID: 83fd2c19-2899-4e59-8929-aeb1e0cae096
|
|
54
|
+
// Should in the future there be additional offers for
|
|
55
|
+
// Termed subscriptions then this approach will need to be revised.
|
|
56
|
+
return '6 flexible vouchers that can be exchanged for a copy of FT Weekend over a 13-week period at retailers nationwide.';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return '';
|
|
60
|
+
},
|
|
44
61
|
},
|
|
45
62
|
HD: {
|
|
46
63
|
title: 'Hand delivery',
|
|
47
|
-
description: 'Free delivery to your home or office before 7am.',
|
|
64
|
+
description: () => 'Free delivery to your home or office before 7am.',
|
|
48
65
|
},
|
|
49
66
|
EV: {
|
|
50
67
|
title: 'Electronic vouchers',
|
|
51
|
-
description:
|
|
68
|
+
description: () =>
|
|
52
69
|
'Delivered via email and card, redeemable at retailers nationwide.',
|
|
53
70
|
},
|
|
54
71
|
},
|
|
@@ -309,12 +326,33 @@ function findCustomDeliveryOption(productCode, option, shippingZone) {
|
|
|
309
326
|
return deliveryOption;
|
|
310
327
|
}
|
|
311
328
|
|
|
312
|
-
function getDeliveryOption({
|
|
329
|
+
function getDeliveryOption({
|
|
330
|
+
productCode,
|
|
331
|
+
option,
|
|
332
|
+
shippingZone,
|
|
333
|
+
countryCode,
|
|
334
|
+
isEvergreenSubscriptionTermType,
|
|
335
|
+
isTermedSubscriptionTermType,
|
|
336
|
+
}) {
|
|
337
|
+
let deliveryOption;
|
|
338
|
+
|
|
313
339
|
// Custom delivery messages are displayed for certain countries
|
|
314
340
|
if (
|
|
315
341
|
Object.keys(countryCodeToCustomDeliveryOptionsMap).includes(countryCode)
|
|
316
342
|
) {
|
|
317
|
-
|
|
343
|
+
deliveryOption =
|
|
344
|
+
countryCodeToCustomDeliveryOptionsMap[countryCode][option.value];
|
|
345
|
+
|
|
346
|
+
const normalisedDeliveryOption = {
|
|
347
|
+
...deliveryOption,
|
|
348
|
+
// Set `description` value as string returned from function.
|
|
349
|
+
description: deliveryOption?.description({
|
|
350
|
+
isEvergreenSubscriptionTermType,
|
|
351
|
+
isTermedSubscriptionTermType,
|
|
352
|
+
}),
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
return normalisedDeliveryOption;
|
|
318
356
|
}
|
|
319
357
|
|
|
320
358
|
return (
|
|
@@ -141,8 +141,70 @@ describe('Find Custom Delivery Option', () => {
|
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
describe('
|
|
145
|
-
|
|
144
|
+
describe('find UK Paper Vouchers delivery option', () => {
|
|
145
|
+
describe('Evergreen (i.e. recurring) subscription term type', () => {
|
|
146
|
+
it('returns UK Paper Vouchers delivery option for Evergreen subscription term type', () => {
|
|
147
|
+
const expected = {
|
|
148
|
+
title: 'Paper vouchers',
|
|
149
|
+
description:
|
|
150
|
+
'13-week voucher pack delivered quarterly and redeemable at retailers nationwide.',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const deliveryOption = getDeliveryOption({
|
|
154
|
+
productCode: sixDaysProductCode,
|
|
155
|
+
option: { value: 'PV' },
|
|
156
|
+
shippingZone: 'GBR',
|
|
157
|
+
countryCode: 'GBR',
|
|
158
|
+
isEvergreenSubscriptionTermType: true,
|
|
159
|
+
isTermedSubscriptionTermType: false,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
expect(deliveryOption).toEqual(expected);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('Termed (i.e. single-term) subscription term type', () => {
|
|
167
|
+
it('returns UK Paper Vouchers delivery option for Termed subscription term type', () => {
|
|
168
|
+
const expected = {
|
|
169
|
+
title: 'Paper vouchers',
|
|
170
|
+
description:
|
|
171
|
+
'6 flexible vouchers that can be exchanged for a copy of FT Weekend over a 13-week period at retailers nationwide.',
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const deliveryOption = getDeliveryOption({
|
|
175
|
+
productCode: sixDaysProductCode,
|
|
176
|
+
option: { value: 'PV' },
|
|
177
|
+
shippingZone: 'GBR',
|
|
178
|
+
countryCode: 'GBR',
|
|
179
|
+
isEvergreenSubscriptionTermType: false,
|
|
180
|
+
isTermedSubscriptionTermType: true,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(deliveryOption).toEqual(expected);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('find UK Hand delivery option', () => {
|
|
189
|
+
it('returns UK Hand delivery option', () => {
|
|
190
|
+
const expected = {
|
|
191
|
+
title: 'Hand delivery',
|
|
192
|
+
description: 'Free delivery to your home or office before 7am.',
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const deliveryOption = getDeliveryOption({
|
|
196
|
+
productCode: sixDaysProductCode,
|
|
197
|
+
option: { value: 'HD' },
|
|
198
|
+
shippingZone: 'GBR',
|
|
199
|
+
countryCode: 'GBR',
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect(deliveryOption).toEqual(expected);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('find UK Electronic Vouchers delivery option', () => {
|
|
207
|
+
it('returns UK Electronic Vouchers delivery option', () => {
|
|
146
208
|
const expected = {
|
|
147
209
|
title: 'Electronic vouchers',
|
|
148
210
|
description:
|