@financial-times/n-conversion-forms 28.7.0 → 28.9.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.
@@ -1,6 +1,86 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`B2CPartnershipConfirmation renders Premium access for premium subscription 1`] = `
3
+ exports[`B2CPartnershipConfirmation renders FT access if subscription prop is null 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
+ <div class="ncf__paragraph">
9
+ <h1 class="ncf__header ncf__header--confirmation">
10
+ Welcome to your FT access
11
+ </h1>
12
+ </div>
13
+ </div>
14
+ <p class="ncf__paragraph">
15
+ Please check your email to confirm your account and set your password.
16
+ </p>
17
+ <p class="ncf__paragraph">
18
+ Explore the homepage &amp; enjoy your unlimited access &amp; exclusive content.
19
+ </p>
20
+ hello
21
+ <p class="ncf__paragraph ncf__center">
22
+ <a href="/"
23
+ class="ncf__link"
24
+ >
25
+ Start reading
26
+ </a>
27
+ </p>
28
+ <p class="ncf__paragraph">
29
+ <div class="ncf__strong">
30
+ Can we help?
31
+ </div>
32
+ For any queries about your Premium subscription please
33
+ <a href="https://help.ft.com/"
34
+ class="ncf__link"
35
+ >
36
+ contact Customer Care
37
+ </a>
38
+ .
39
+ </p>
40
+ </div>
41
+ `;
42
+
43
+ exports[`B2CPartnershipConfirmation renders FT access if subscription prop is undefined 1`] = `
44
+ <div class="ncf ncf__wrapper">
45
+ <div class="ncf__center">
46
+ <div class="ncf__icon ncf__icon--tick ncf__icon--large">
47
+ </div>
48
+ <div class="ncf__paragraph">
49
+ <h1 class="ncf__header ncf__header--confirmation">
50
+ Welcome to your FT access
51
+ </h1>
52
+ </div>
53
+ </div>
54
+ <p class="ncf__paragraph">
55
+ Please check your email to confirm your account and set your password.
56
+ </p>
57
+ <p class="ncf__paragraph">
58
+ Explore the homepage &amp; enjoy your unlimited access &amp; exclusive content.
59
+ </p>
60
+ hello
61
+ <p class="ncf__paragraph ncf__center">
62
+ <a href="/"
63
+ class="ncf__link"
64
+ >
65
+ Start reading
66
+ </a>
67
+ </p>
68
+ <p class="ncf__paragraph">
69
+ <div class="ncf__strong">
70
+ Can we help?
71
+ </div>
72
+ For any queries about your Premium subscription please
73
+ <a href="https://help.ft.com/"
74
+ class="ncf__link"
75
+ >
76
+ contact Customer Care
77
+ </a>
78
+ .
79
+ </p>
80
+ </div>
81
+ `;
82
+
83
+ exports[`B2CPartnershipConfirmation renders Premium access for premium subscription lowercase 1`] = `
4
84
  <div class="ncf ncf__wrapper">
5
85
  <div class="ncf__center">
6
86
  <div class="ncf__icon ncf__icon--tick ncf__icon--large">
@@ -40,7 +120,7 @@ exports[`B2CPartnershipConfirmation renders Premium access for premium subscript
40
120
  </div>
41
121
  `;
42
122
 
43
- exports[`B2CPartnershipConfirmation renders Premium access if subscription prop is null 1`] = `
123
+ exports[`B2CPartnershipConfirmation renders Premium access for premium subscription uppercase 1`] = `
44
124
  <div class="ncf ncf__wrapper">
45
125
  <div class="ncf__center">
46
126
  <div class="ncf__icon ncf__icon--tick ncf__icon--large">
@@ -80,7 +160,47 @@ exports[`B2CPartnershipConfirmation renders Premium access if subscription prop
80
160
  </div>
81
161
  `;
82
162
 
83
- exports[`B2CPartnershipConfirmation renders Standard access for standard subscription 1`] = `
163
+ exports[`B2CPartnershipConfirmation renders Standard access for standard subscription lowercase 1`] = `
164
+ <div class="ncf ncf__wrapper">
165
+ <div class="ncf__center">
166
+ <div class="ncf__icon ncf__icon--tick ncf__icon--large">
167
+ </div>
168
+ <div class="ncf__paragraph">
169
+ <h1 class="ncf__header ncf__header--confirmation">
170
+ Welcome to your Standard access
171
+ </h1>
172
+ </div>
173
+ </div>
174
+ <p class="ncf__paragraph">
175
+ Please check your email to confirm your account and set your password.
176
+ </p>
177
+ <p class="ncf__paragraph">
178
+ Explore the homepage &amp; enjoy your unlimited access &amp; exclusive content.
179
+ </p>
180
+ hello
181
+ <p class="ncf__paragraph ncf__center">
182
+ <a href="/"
183
+ class="ncf__link"
184
+ >
185
+ Start reading
186
+ </a>
187
+ </p>
188
+ <p class="ncf__paragraph">
189
+ <div class="ncf__strong">
190
+ Can we help?
191
+ </div>
192
+ For any queries about your Premium subscription please
193
+ <a href="https://help.ft.com/"
194
+ class="ncf__link"
195
+ >
196
+ contact Customer Care
197
+ </a>
198
+ .
199
+ </p>
200
+ </div>
201
+ `;
202
+
203
+ exports[`B2CPartnershipConfirmation renders Standard access for standard subscription uppercase 1`] = `
84
204
  <div class="ncf ncf__wrapper">
85
205
  <div class="ncf__center">
86
206
  <div class="ncf__icon ncf__icon--tick ncf__icon--large">
@@ -127,7 +247,87 @@ exports[`B2CPartnershipConfirmation renders as default 1`] = `
127
247
  </div>
128
248
  <div class="ncf__paragraph">
129
249
  <h1 class="ncf__header ncf__header--confirmation">
130
- Welcome to your Premium access
250
+ Welcome to your FT access
251
+ </h1>
252
+ </div>
253
+ </div>
254
+ <p class="ncf__paragraph">
255
+ Please check your email to confirm your account and set your password.
256
+ </p>
257
+ <p class="ncf__paragraph">
258
+ Explore the homepage &amp; enjoy your unlimited access &amp; exclusive content.
259
+ </p>
260
+ hello
261
+ <p class="ncf__paragraph ncf__center">
262
+ <a href="/"
263
+ class="ncf__link"
264
+ >
265
+ Start reading
266
+ </a>
267
+ </p>
268
+ <p class="ncf__paragraph">
269
+ <div class="ncf__strong">
270
+ Can we help?
271
+ </div>
272
+ For any queries about your Premium subscription please
273
+ <a href="https://help.ft.com/"
274
+ class="ncf__link"
275
+ >
276
+ contact Customer Care
277
+ </a>
278
+ .
279
+ </p>
280
+ </div>
281
+ `;
282
+
283
+ exports[`B2CPartnershipConfirmation renders ePaper access for ePaper subscription lowercase 1`] = `
284
+ <div class="ncf ncf__wrapper">
285
+ <div class="ncf__center">
286
+ <div class="ncf__icon ncf__icon--tick ncf__icon--large">
287
+ </div>
288
+ <div class="ncf__paragraph">
289
+ <h1 class="ncf__header ncf__header--confirmation">
290
+ Welcome to your ePaper access
291
+ </h1>
292
+ </div>
293
+ </div>
294
+ <p class="ncf__paragraph">
295
+ Please check your email to confirm your account and set your password.
296
+ </p>
297
+ <p class="ncf__paragraph">
298
+ Explore the homepage &amp; enjoy your unlimited access &amp; exclusive content.
299
+ </p>
300
+ hello
301
+ <p class="ncf__paragraph ncf__center">
302
+ <a href="/"
303
+ class="ncf__link"
304
+ >
305
+ Start reading
306
+ </a>
307
+ </p>
308
+ <p class="ncf__paragraph">
309
+ <div class="ncf__strong">
310
+ Can we help?
311
+ </div>
312
+ For any queries about your Premium subscription please
313
+ <a href="https://help.ft.com/"
314
+ class="ncf__link"
315
+ >
316
+ contact Customer Care
317
+ </a>
318
+ .
319
+ </p>
320
+ </div>
321
+ `;
322
+
323
+ exports[`B2CPartnershipConfirmation renders ePaper access for ePaper subscription uppercase 1`] = `
324
+ <div class="ncf ncf__wrapper">
325
+ <div class="ncf__center">
326
+ <div class="ncf__icon ncf__icon--tick ncf__icon--large">
327
+ </div>
328
+ <div class="ncf__paragraph">
329
+ <h1 class="ncf__header ncf__header--confirmation">
330
+ Welcome to your ePaper access
131
331
  </h1>
132
332
  </div>
133
333
  </div>
@@ -1,6 +1,12 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
+ const productCodeMapping = {
5
+ P1: 'Standard',
6
+ P2: 'Premium',
7
+ EP: 'ePaper',
8
+ };
9
+
4
10
  export function B2CPartnershipConfirmation({
5
11
  ctaElement = null,
6
12
  productCode = null,
@@ -15,8 +21,11 @@ export function B2CPartnershipConfirmation({
15
21
  className: 'ncf__link',
16
22
  };
17
23
 
18
- const accessType =
19
- productCode?.toUpperCase() === 'P1' ? 'Standard' : 'Premium';
24
+ // Welcome to your Standard access
25
+ // Welcome to your Premium access
26
+ // Welcome to your ePaper access
27
+ // Welcome to your FT access (default)
28
+ const accessType = productCodeMapping[productCode?.toUpperCase()] || 'FT';
20
29
 
21
30
  return (
22
31
  <div className="ncf ncf__wrapper">
@@ -10,21 +10,51 @@ describe('B2CPartnershipConfirmation', () => {
10
10
  expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
11
11
  });
12
12
 
13
- it('renders Premium access for premium subscription', () => {
13
+ it('renders Premium access for premium subscription lowercase', () => {
14
14
  const props = { ctaElement: 'hello', productCode: 'p2' };
15
15
 
16
16
  expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
17
17
  });
18
18
 
19
- it('renders Standard access for standard subscription', () => {
19
+ it('renders Premium access for premium subscription uppercase', () => {
20
+ const props = { ctaElement: 'hello', productCode: 'P2' };
21
+
22
+ expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
23
+ });
24
+
25
+ it('renders Standard access for standard subscription lowercase', () => {
20
26
  const props = { ctaElement: 'hello', productCode: 'p1' };
21
27
 
22
28
  expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
23
29
  });
24
30
 
25
- it('renders Premium access if subscription prop is null', () => {
31
+ it('renders Standard access for standard subscription uppercase', () => {
32
+ const props = { ctaElement: 'hello', productCode: 'P1' };
33
+
34
+ expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
35
+ });
36
+
37
+ it('renders ePaper access for ePaper subscription lowercase', () => {
38
+ const props = { ctaElement: 'hello', productCode: 'ep' };
39
+
40
+ expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
41
+ });
42
+
43
+ it('renders ePaper access for ePaper subscription uppercase', () => {
44
+ const props = { ctaElement: 'hello', productCode: 'EP' };
45
+
46
+ expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
47
+ });
48
+
49
+ it('renders FT access if subscription prop is null', () => {
26
50
  const props = { ctaElement: 'hello', productCode: null };
27
51
 
28
52
  expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
29
53
  });
54
+
55
+ it('renders FT access if subscription prop is undefined', () => {
56
+ const props = { ctaElement: 'hello', productCode: undefined };
57
+
58
+ expect(B2CPartnershipConfirmation).toRenderCorrectly(props);
59
+ });
30
60
  });
@@ -406,6 +406,7 @@ PaymentTerm.propTypes = {
406
406
  subTitle: PropTypes.string,
407
407
  bestOffer: PropTypes.bool,
408
408
  chargeOnText: PropTypes.string,
409
+ fulfilmentOption: PropTypes.string,
409
410
  })
410
411
  ),
411
412
  isFixedTermOffer: PropTypes.bool,
@@ -7,6 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.B2CPartnershipConfirmation = B2CPartnershipConfirmation;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var productCodeMapping = {
11
+ P1: 'Standard',
12
+ P2: 'Premium',
13
+ EP: 'ePaper'
14
+ };
10
15
  function B2CPartnershipConfirmation(_ref) {
11
16
  var _ref$ctaElement = _ref.ctaElement,
12
17
  ctaElement = _ref$ctaElement === void 0 ? null : _ref$ctaElement,
@@ -20,7 +25,12 @@ function B2CPartnershipConfirmation(_ref) {
20
25
  href: 'https://help.ft.com/',
21
26
  className: 'ncf__link'
22
27
  };
23
- var accessType = (productCode === null || productCode === void 0 ? void 0 : productCode.toUpperCase()) === 'P1' ? 'Standard' : 'Premium';
28
+
29
+ // Welcome to your Standard access
30
+ // Welcome to your Premium access
31
+ // Welcome to your ePaper access
32
+ // Welcome to your FT access (default)
33
+ var accessType = productCodeMapping[productCode === null || productCode === void 0 ? void 0 : productCode.toUpperCase()] || 'FT';
24
34
  return /*#__PURE__*/_react["default"].createElement("div", {
25
35
  className: "ncf ncf__wrapper"
26
36
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -288,7 +288,8 @@ PaymentTerm.propTypes = {
288
288
  title: _propTypes["default"].string,
289
289
  subTitle: _propTypes["default"].string,
290
290
  bestOffer: _propTypes["default"].bool,
291
- chargeOnText: _propTypes["default"].string
291
+ chargeOnText: _propTypes["default"].string,
292
+ fulfilmentOption: _propTypes["default"].string
292
293
  })),
293
294
  isFixedTermOffer: _propTypes["default"].bool,
294
295
  offerDisplayName: _propTypes["default"].string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "28.7.0",
3
+ "version": "28.9.0",
4
4
  "description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -104,8 +104,9 @@ class PaymentTerm {
104
104
  }
105
105
 
106
106
  /**
107
- * Update the payment term options
108
- * @param {Array} options Array of objects contain terms information
107
+ * Updates the payment term options.
108
+ * @param {Object} options - indexed Object about Array of objects containing terms information. E.g.: { P1Y: {...}, P3M: {...}}
109
+ * @throws Will throw an error if a payment term update is not found for a given value.
109
110
  */
110
111
  updateOptions(options) {
111
112
  const terms = this.$paymentTerm.querySelectorAll(ITEM_CLASS);
@@ -115,7 +116,7 @@ class PaymentTerm {
115
116
  const price = term.querySelector(PRICE_CLASS);
116
117
  const trialPrice = term.querySelector(TRIAL_PRICE_CLASS);
117
118
  const monthlyPrice = term.querySelector(MONTHLY_PRICE_CLASS);
118
- const update = options.find((option) => option.value === value);
119
+ const update = options[value];
119
120
 
120
121
  if (!update) {
121
122
  throw new Error(`Payment term update not found for "${value}"`);
@@ -94,7 +94,7 @@ describe('PaymentTerm', () => {
94
94
 
95
95
  it('throws an error if not all terms have an update', () => {
96
96
  expect(() => {
97
- paymentTerm.updateOptions([]);
97
+ paymentTerm.updateOptions({});
98
98
  }).toThrow();
99
99
  });
100
100
 
@@ -105,12 +105,12 @@ describe('PaymentTerm', () => {
105
105
  ? priceStub
106
106
  : elementStub;
107
107
  });
108
- paymentTerm.updateOptions([
109
- {
108
+ paymentTerm.updateOptions({
109
+ test: {
110
110
  value: 'test',
111
111
  price: '£1.01',
112
112
  },
113
- ]);
113
+ });
114
114
  expect(priceStub.innerHTML).toEqual('£1.01');
115
115
  });
116
116
 
@@ -121,12 +121,12 @@ describe('PaymentTerm', () => {
121
121
  ? trialPriceStub
122
122
  : elementStub;
123
123
  });
124
- paymentTerm.updateOptions([
125
- {
124
+ paymentTerm.updateOptions({
125
+ test: {
126
126
  value: 'test',
127
127
  trialPrice: '£1.01',
128
128
  },
129
- ]);
129
+ });
130
130
  expect(trialPriceStub.innerHTML).toEqual('£1.01');
131
131
  });
132
132
 
@@ -137,31 +137,31 @@ describe('PaymentTerm', () => {
137
137
  ? monthlyPriceStub
138
138
  : elementStub;
139
139
  });
140
- paymentTerm.updateOptions([
141
- {
140
+ paymentTerm.updateOptions({
141
+ test: {
142
142
  value: 'test',
143
143
  monthlyPrice: '£1.01',
144
144
  },
145
- ]);
145
+ });
146
146
  expect(monthlyPriceStub.innerHTML).toEqual('£1.01');
147
147
  });
148
148
 
149
149
  describe('updating base amount', () => {
150
- const updatedOptions = [
151
- {
150
+ const updatedOptions = {
151
+ test: {
152
152
  value: 'test',
153
153
  monthlyPrice: '£1.01',
154
154
  amount: 500,
155
155
  trialAmount: 1,
156
156
  },
157
- ];
157
+ };
158
158
 
159
159
  beforeEach(() => {
160
160
  elementStub.querySelector.mockReturnValue(elementStub);
161
161
  });
162
162
 
163
163
  it('replaces the base amount with the correct updated trial amount', () => {
164
- updatedOptions[0].isTrial = true;
164
+ updatedOptions.test.isTrial = true;
165
165
  paymentTerm.updateOptions(updatedOptions);
166
166
  expect(elementStub.setAttribute).toHaveBeenCalledWith(
167
167
  'data-base-amount',
@@ -170,7 +170,7 @@ describe('PaymentTerm', () => {
170
170
  });
171
171
 
172
172
  it('replaces the base amount with the correct updated amount', () => {
173
- updatedOptions[0].isTrial = false;
173
+ updatedOptions.test.isTrial = false;
174
174
  paymentTerm.updateOptions(updatedOptions);
175
175
  expect(elementStub.setAttribute).toHaveBeenCalledWith(
176
176
  'data-base-amount',