@capillarytech/creatives-library 9.0.70 → 9.0.71-alpha.sprint-cap-211543.17
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +58 -1
- package/v2Components/CapTagListWithInput/index.js +64 -35
- package/v2Components/CapTagListWithInput/index.scss +9 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/EmailPreviewContent.js +8 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +7 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +1 -0
- package/v2Components/CommonTestAndPreview/actions.js +1 -1
- package/v2Components/CommonTestAndPreview/index.js +29 -13
- package/v2Components/CommonTestAndPreview/sagas.js +2 -1
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/EmailPreviewContent.test.js +27 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +40 -0
- package/v2Components/CommonTestAndPreview/tests/index.test.js +95 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +24 -0
- package/v2Components/EmailMobilePreview/index.js +8 -1
- package/v2Components/EmailMobilePreview/index.scss +12 -3
- package/v2Components/EmailMobilePreview/tests/index.test.js +31 -0
- package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +35 -5
- package/v2Components/EmailPreviewV2/index.js +18 -6
- package/v2Components/EmailPreviewV2/messages.js +4 -0
- package/v2Components/EmailPreviewV2/tests/index.test.js +43 -0
- package/v2Components/FormBuilder/Classic.js +113 -10
- package/v2Components/FormBuilder/_formBuilder.scss +18 -0
- package/v2Components/FormBuilder/messages.js +8 -0
- package/v2Containers/Cap/tests/index.test.js +1 -0
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +2 -1
- package/v2Containers/CommunicationFlow/Tests/constants.test.js +4 -4
- package/v2Containers/CommunicationFlow/constants.js +1 -0
- package/v2Containers/CommunicationFlow/utils/Tests/mapCommDefinitionToStepData.test.js +2 -1
- package/v2Containers/CommunicationFlow/utils/mapCommDefinitionToStepData.js +1 -0
- package/v2Containers/CreativesContainer/index.js +9 -3
- package/v2Containers/CreativesContainer/tests/index.test.js +81 -0
- package/v2Containers/Email/index.js +31 -4
- package/v2Containers/Email/initialSchema.js +30 -0
- package/v2Containers/Email/messages.js +8 -0
- package/v2Containers/Email/tests/index.test.js +107 -0
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +168 -8
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +72 -3
- package/v2Containers/EmailWrapper/components/_emailHTMLEditor.scss +26 -0
- package/v2Containers/EmailWrapper/constants.js +5 -0
- package/v2Containers/EmailWrapper/messages.js +20 -0
- package/v2Containers/TagList/index.js +7 -0
- package/v2Containers/TagList/tests/TagList.test.js +42 -0
- package/v2Containers/Templates/constants.js +1 -0
- package/v2Containers/Templates/index.js +31 -27
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +128 -4
- package/v2Containers/Templates/tests/archival.test.js +221 -0
|
@@ -536,6 +536,45 @@ describe('CommonTestAndPreview', () => {
|
|
|
536
536
|
expect(initialPayload.emailDeliverySettings.channelSettings.channel).toBe(CHANNELS.EMAIL);
|
|
537
537
|
});
|
|
538
538
|
|
|
539
|
+
it('should send the pre-header as messagePreHeader alongside messageSubject/messageBody for EMAIL', async () => {
|
|
540
|
+
render(
|
|
541
|
+
<TestWrapper>
|
|
542
|
+
<CommonTestAndPreview
|
|
543
|
+
{...defaultProps}
|
|
544
|
+
channel={CHANNELS.EMAIL}
|
|
545
|
+
formData={{
|
|
546
|
+
...defaultProps.formData,
|
|
547
|
+
'template-preheader': 'Test Preheader',
|
|
548
|
+
}}
|
|
549
|
+
/>
|
|
550
|
+
</TestWrapper>
|
|
551
|
+
);
|
|
552
|
+
await waitFor(() => {
|
|
553
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
554
|
+
expect(typeof lastSendTestMessageProps.handleSendTestMessage).toBe('function');
|
|
555
|
+
});
|
|
556
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
557
|
+
expect(mockActions.createMessageMetaRequested).toHaveBeenCalled();
|
|
558
|
+
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
559
|
+
expect(initialPayload.emailMessageContent.messageSubject).toBe('Test Subject');
|
|
560
|
+
expect(initialPayload.emailMessageContent.messagePreHeader).toBe('Test Preheader');
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
it('should default messagePreHeader to an empty string when no pre-header is present for EMAIL', async () => {
|
|
564
|
+
render(
|
|
565
|
+
<TestWrapper>
|
|
566
|
+
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.EMAIL} />
|
|
567
|
+
</TestWrapper>
|
|
568
|
+
);
|
|
569
|
+
await waitFor(() => {
|
|
570
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
571
|
+
expect(typeof lastSendTestMessageProps.handleSendTestMessage).toBe('function');
|
|
572
|
+
});
|
|
573
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
574
|
+
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
575
|
+
expect(initialPayload.emailMessageContent.messagePreHeader).toBe('');
|
|
576
|
+
});
|
|
577
|
+
|
|
539
578
|
it('should include delivery settings in payload when handleSendTestMessage is called for SMS', async () => {
|
|
540
579
|
render(
|
|
541
580
|
<TestWrapper>
|
|
@@ -2977,6 +3016,37 @@ describe('CommonTestAndPreview', () => {
|
|
|
2977
3016
|
expect(mockActions.extractTagsRequested).toHaveBeenCalled();
|
|
2978
3017
|
});
|
|
2979
3018
|
|
|
3019
|
+
it('should pass template-preheader separately (not merged into templateSubject) in the extraction payload for EMAIL', async () => {
|
|
3020
|
+
const props = {
|
|
3021
|
+
...defaultProps,
|
|
3022
|
+
channel: CHANNELS.EMAIL,
|
|
3023
|
+
formData: {
|
|
3024
|
+
'template-subject': 'Hello {{name}}',
|
|
3025
|
+
'template-preheader': 'Enjoy {{discount}} off, {{name}}',
|
|
3026
|
+
0: {
|
|
3027
|
+
activeTab: 'base',
|
|
3028
|
+
base: {
|
|
3029
|
+
'template-content': '<html>Your order {{orderId}} is ready</html>',
|
|
3030
|
+
},
|
|
3031
|
+
},
|
|
3032
|
+
},
|
|
3033
|
+
};
|
|
3034
|
+
|
|
3035
|
+
render(
|
|
3036
|
+
<TestWrapper>
|
|
3037
|
+
<CommonTestAndPreview {...props} />
|
|
3038
|
+
</TestWrapper>
|
|
3039
|
+
);
|
|
3040
|
+
|
|
3041
|
+
expect(mockActions.extractTagsRequested).toHaveBeenCalled();
|
|
3042
|
+
const call = mockActions.extractTagsRequested.mock.calls.find(
|
|
3043
|
+
([payload]) => payload?.templatePreheader?.includes('{{discount}}')
|
|
3044
|
+
);
|
|
3045
|
+
expect(call).toBeDefined();
|
|
3046
|
+
expect(call[0].templateSubject).toBe('Hello {{name}}');
|
|
3047
|
+
expect(call[0].templatePreheader).toBe('Enjoy {{discount}} off, {{name}}');
|
|
3048
|
+
});
|
|
3049
|
+
|
|
2980
3050
|
it('should extract tags from SMS content', async () => {
|
|
2981
3051
|
const props = {
|
|
2982
3052
|
...defaultProps,
|
|
@@ -3759,6 +3829,31 @@ describe('CommonTestAndPreview', () => {
|
|
|
3759
3829
|
expect(mockActions.updatePreviewRequested).toHaveBeenCalledTimes(1);
|
|
3760
3830
|
});
|
|
3761
3831
|
|
|
3832
|
+
it('should include messageSubtitle alongside messageTitle/messageBody in the EMAIL preview payload', async () => {
|
|
3833
|
+
render(
|
|
3834
|
+
<TestWrapper>
|
|
3835
|
+
<CommonTestAndPreview
|
|
3836
|
+
{...defaultProps}
|
|
3837
|
+
channel={CHANNELS.EMAIL}
|
|
3838
|
+
formData={{
|
|
3839
|
+
...defaultProps.formData,
|
|
3840
|
+
'template-preheader': 'Enjoy {{discount}}',
|
|
3841
|
+
}}
|
|
3842
|
+
/>
|
|
3843
|
+
</TestWrapper>
|
|
3844
|
+
);
|
|
3845
|
+
|
|
3846
|
+
await waitFor(() => expect(lastCustomValuesEditorProps).not.toBeNull());
|
|
3847
|
+
|
|
3848
|
+
lastCustomValuesEditorProps.handleDiscardCustomValues();
|
|
3849
|
+
|
|
3850
|
+
expect(mockActions.updatePreviewRequested).toHaveBeenCalledTimes(1);
|
|
3851
|
+
const [payload] = mockActions.updatePreviewRequested.mock.calls[0];
|
|
3852
|
+
expect(payload.messageTitle).toBe('Test Subject');
|
|
3853
|
+
expect(payload.messageSubtitle).toBe('Enjoy {{discount}}');
|
|
3854
|
+
expect(payload.messageBody).toBeDefined();
|
|
3855
|
+
});
|
|
3856
|
+
|
|
3762
3857
|
it('should call updatePreviewRequested with RCS channel when handleDiscardCustomValues is invoked for RCS with fallback', async () => {
|
|
3763
3858
|
render(
|
|
3764
3859
|
<TestWrapper>
|
|
@@ -224,6 +224,7 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
224
224
|
expect(generator.next().value).toEqual(
|
|
225
225
|
call(Api.extractTagsWithMetaData, {
|
|
226
226
|
messageTitle: 'Hello {{name}}',
|
|
227
|
+
messageSubtitle: '',
|
|
227
228
|
messageBody: 'Welcome {{email}}',
|
|
228
229
|
})
|
|
229
230
|
);
|
|
@@ -238,6 +239,25 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
238
239
|
expect(generator.next().done).toBe(true);
|
|
239
240
|
});
|
|
240
241
|
|
|
242
|
+
it('should pass templatePreheader through as messageSubtitle', () => {
|
|
243
|
+
const action = {
|
|
244
|
+
payload: {
|
|
245
|
+
templateSubject: 'Hello {{name}}',
|
|
246
|
+
templatePreheader: 'Enjoy {{discount}}',
|
|
247
|
+
templateContent: 'Welcome {{email}}',
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
const generator = extractTagsSaga(action);
|
|
251
|
+
|
|
252
|
+
expect(generator.next().value).toEqual(
|
|
253
|
+
call(Api.extractTagsWithMetaData, {
|
|
254
|
+
messageTitle: 'Hello {{name}}',
|
|
255
|
+
messageSubtitle: 'Enjoy {{discount}}',
|
|
256
|
+
messageBody: 'Welcome {{email}}',
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
|
|
241
261
|
it('should handle empty templateSubject', () => {
|
|
242
262
|
const action = {
|
|
243
263
|
payload: {
|
|
@@ -250,6 +270,7 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
250
270
|
expect(generator.next().value).toEqual(
|
|
251
271
|
call(Api.extractTagsWithMetaData, {
|
|
252
272
|
messageTitle: '',
|
|
273
|
+
messageSubtitle: '',
|
|
253
274
|
messageBody: 'Welcome {{email}}',
|
|
254
275
|
})
|
|
255
276
|
);
|
|
@@ -268,6 +289,7 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
268
289
|
expect(generator.next().value).toEqual(
|
|
269
290
|
call(Api.extractTagsWithMetaData, {
|
|
270
291
|
messageTitle: 'Hello {{name}}',
|
|
292
|
+
messageSubtitle: '',
|
|
271
293
|
messageBody: '',
|
|
272
294
|
})
|
|
273
295
|
);
|
|
@@ -284,6 +306,7 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
284
306
|
expect(generator.next().value).toEqual(
|
|
285
307
|
call(Api.extractTagsWithMetaData, {
|
|
286
308
|
messageTitle: '',
|
|
309
|
+
messageSubtitle: '',
|
|
287
310
|
messageBody: 'Welcome {{email}}',
|
|
288
311
|
})
|
|
289
312
|
);
|
|
@@ -301,6 +324,7 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
301
324
|
expect(generator.next().value).toEqual(
|
|
302
325
|
call(Api.extractTagsWithMetaData, {
|
|
303
326
|
messageTitle: 'Hello {{name}}',
|
|
327
|
+
messageSubtitle: '',
|
|
304
328
|
messageBody: '',
|
|
305
329
|
})
|
|
306
330
|
);
|
|
@@ -29,7 +29,7 @@ const deviceAspectRatio = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
class EmailMobilePreview extends React.Component {
|
|
32
|
+
export class EmailMobilePreview extends React.Component {
|
|
33
33
|
static getDerivedStateFromProps(props) {
|
|
34
34
|
if (props.showAllDevices) {
|
|
35
35
|
return {
|
|
@@ -66,6 +66,7 @@ class EmailMobilePreview extends React.Component {
|
|
|
66
66
|
templateContent,
|
|
67
67
|
enableShowAllDevices,
|
|
68
68
|
templateSubject,
|
|
69
|
+
templatePreHeader,
|
|
69
70
|
} = this.props;
|
|
70
71
|
const copyContent = templateContent && removeLinksFromHtmlContent(templateContent);
|
|
71
72
|
const updateCopyContent = templateContent && iframePreviewAdjustWidth(copyContent);
|
|
@@ -76,6 +77,10 @@ class EmailMobilePreview extends React.Component {
|
|
|
76
77
|
<CapLabel className="email-subject-mobile" type="label2">
|
|
77
78
|
<FormattedMessage {...messages.subject} /> {templateSubject}</CapLabel>
|
|
78
79
|
);
|
|
80
|
+
const emailPreHeaderLabel = templatePreHeader && (
|
|
81
|
+
<CapLabel className="email-preheader-mobile" type="label2">
|
|
82
|
+
<FormattedMessage {...messages.preheader} /> {templatePreHeader}</CapLabel>
|
|
83
|
+
);
|
|
79
84
|
|
|
80
85
|
return (
|
|
81
86
|
<div className="email-mobile-preview-container">
|
|
@@ -100,6 +105,7 @@ class EmailMobilePreview extends React.Component {
|
|
|
100
105
|
<img src={mobileBody} alt="capillary" width="386" />
|
|
101
106
|
<div className={`${messageContainerName} ${emailSubjectLabel ? 'with-subject' : ''}`}>
|
|
102
107
|
{emailSubjectLabel}
|
|
108
|
+
{emailPreHeaderLabel}
|
|
103
109
|
<iframe srcDoc={updateCopyContent} {...deviceAspectRatio.mobile} >
|
|
104
110
|
<p><FormattedMessage {...messages.noIframeSupport}/></p>
|
|
105
111
|
</iframe>
|
|
@@ -127,6 +133,7 @@ class EmailMobilePreview extends React.Component {
|
|
|
127
133
|
EmailMobilePreview.propTypes = {
|
|
128
134
|
templateContent: PropTypes.string,
|
|
129
135
|
templateSubject: PropTypes.string,
|
|
136
|
+
templatePreHeader: PropTypes.string,
|
|
130
137
|
templateData: PropTypes.object,
|
|
131
138
|
templateActions: PropTypes.object,
|
|
132
139
|
onClickShowInAllDevices: PropTypes.func,
|
|
@@ -44,10 +44,19 @@ $classPrefix: email-mobile-preview-container;
|
|
|
44
44
|
justify-content: center;
|
|
45
45
|
}
|
|
46
46
|
.email-subject-mobile {
|
|
47
|
-
width:
|
|
47
|
+
width: 14.1875rem;
|
|
48
48
|
text-align: left;
|
|
49
|
-
margin:
|
|
50
|
-
|
|
49
|
+
margin: 0.5rem 0.25rem 0;
|
|
50
|
+
padding-bottom: 0.5rem;
|
|
51
|
+
border-bottom: 0.0625rem solid #d9d9d9;
|
|
52
|
+
}
|
|
53
|
+
.email-preheader-mobile {
|
|
54
|
+
width: 14.1875rem;
|
|
55
|
+
text-align: left;
|
|
56
|
+
margin: 0.5rem 0.25rem 0;
|
|
57
|
+
padding-bottom: 0.5rem;
|
|
58
|
+
border-bottom: 0.0625rem solid #d9d9d9;
|
|
59
|
+
color: #8c8c8c;
|
|
51
60
|
}
|
|
52
61
|
// .mobile-message-container {
|
|
53
62
|
// position: absolute;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { EmailMobilePreview } from '../index';
|
|
4
|
+
|
|
5
|
+
describe('<EmailMobilePreview />', () => {
|
|
6
|
+
const baseProps = {
|
|
7
|
+
templateContent: '<p>Body</p>',
|
|
8
|
+
templateActions: {
|
|
9
|
+
getTemplateDetails: jest.fn(),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('does not render a pre-header label when templatePreHeader is not provided', () => {
|
|
14
|
+
const wrapper = shallow(<EmailMobilePreview {...baseProps} templateSubject="Hello" />);
|
|
15
|
+
expect(wrapper.find('.email-preheader-mobile')).toHaveLength(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders the pre-header label when templatePreHeader is provided', () => {
|
|
19
|
+
const wrapper = shallow(
|
|
20
|
+
<EmailMobilePreview {...baseProps} templateSubject="Hello" templatePreHeader="Enjoy 20% off" />
|
|
21
|
+
);
|
|
22
|
+
const label = wrapper.find('.email-preheader-mobile');
|
|
23
|
+
expect(label).toHaveLength(1);
|
|
24
|
+
expect(label.text()).toContain('Enjoy 20% off');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders the pre-header label even when subject is absent', () => {
|
|
28
|
+
const wrapper = shallow(<EmailMobilePreview {...baseProps} templatePreHeader="Enjoy 20% off" />);
|
|
29
|
+
expect(wrapper.find('.email-preheader-mobile')).toHaveLength(1);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import '~@capillarytech/cap-ui-library/styles/_variables';
|
|
2
|
+
|
|
1
3
|
$classPrefix: email-preview-v2;
|
|
2
4
|
.#{$classPrefix}:not(.email-mobile-preview-container){
|
|
3
5
|
#emailPreivew-container {
|
|
@@ -54,19 +56,47 @@ $classPrefix: email-preview-v2;
|
|
|
54
56
|
.email-subject-mobile {
|
|
55
57
|
width: 310px;
|
|
56
58
|
text-align: left;
|
|
57
|
-
margin:
|
|
58
|
-
|
|
59
|
+
margin: 0.5rem 0.25rem 0;
|
|
60
|
+
padding-bottom: 0.5rem;
|
|
61
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
59
62
|
}
|
|
60
63
|
.email-subject-tablet {
|
|
61
64
|
width: 450px;
|
|
62
65
|
text-align: left;
|
|
63
|
-
margin:
|
|
64
|
-
|
|
66
|
+
margin: 0.5rem 0.25rem 0;
|
|
67
|
+
padding-bottom: 0.5rem;
|
|
68
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
65
69
|
}
|
|
66
70
|
.email-subject-desktop {
|
|
67
71
|
text-align: left;
|
|
68
72
|
margin-left: 6%;
|
|
69
|
-
margin-
|
|
73
|
+
margin-right: 6%;
|
|
74
|
+
padding-bottom: 0.5rem;
|
|
75
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
76
|
+
}
|
|
77
|
+
.email-preheader-mobile {
|
|
78
|
+
width: 19.375rem;
|
|
79
|
+
text-align: left;
|
|
80
|
+
margin: 0.5rem 0.25rem 0;
|
|
81
|
+
padding-bottom: 0.5rem;
|
|
82
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
83
|
+
color: #8c8c8c;
|
|
84
|
+
}
|
|
85
|
+
.email-preheader-tablet {
|
|
86
|
+
width: 28.125rem;
|
|
87
|
+
text-align: left;
|
|
88
|
+
margin: 0.5rem 0.25rem 0;
|
|
89
|
+
padding-bottom: 0.5rem;
|
|
90
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
91
|
+
color: #8c8c8c;
|
|
92
|
+
}
|
|
93
|
+
.email-preheader-desktop {
|
|
94
|
+
text-align: left;
|
|
95
|
+
margin-left: 6%;
|
|
96
|
+
margin-right: 6%;
|
|
97
|
+
padding-bottom: 0.5rem;
|
|
98
|
+
border-bottom: 0.0625rem solid $CAP_COLOR_16;
|
|
99
|
+
color: #8c8c8c;
|
|
70
100
|
}
|
|
71
101
|
.tablet-message-container {
|
|
72
102
|
position: absolute;
|
|
@@ -30,12 +30,12 @@ const deviceAspectRatio = {
|
|
|
30
30
|
height: "500",
|
|
31
31
|
width: "1024",
|
|
32
32
|
}),
|
|
33
|
-
tablet: (emailSubject) => ({
|
|
34
|
-
height: emailSubject ? "570" : "600",
|
|
33
|
+
tablet: (emailSubject, emailPreHeader) => ({
|
|
34
|
+
height: emailSubject ? (emailPreHeader ? "545" : "570") : "600",
|
|
35
35
|
width: "450",
|
|
36
36
|
}),
|
|
37
|
-
mobile: (emailSubject) => ({
|
|
38
|
-
height: emailSubject ? "541" : "511",
|
|
37
|
+
mobile: (emailSubject, emailPreHeader) => ({
|
|
38
|
+
height: emailSubject ? (emailPreHeader ? "516" : "541") : "511",
|
|
39
39
|
width: "340",
|
|
40
40
|
}),
|
|
41
41
|
};
|
|
@@ -72,25 +72,36 @@ export class EmailPreviewV2 extends React.Component {
|
|
|
72
72
|
render() {
|
|
73
73
|
let messageContainerName = '';
|
|
74
74
|
const {currentDevice} = this.state;
|
|
75
|
-
const {
|
|
75
|
+
const {
|
|
76
|
+
templateContent, templateData = {}, templateSubject, templatePreHeader,
|
|
77
|
+
} = this.props;
|
|
76
78
|
const copyContent = templateContent && removeLinksFromHtmlContent(templateContent);
|
|
77
79
|
const updateCopyContent = templateContent && iframePreviewAdjustWidth(copyContent);
|
|
78
80
|
let subjectClassName = 'email-subject-desktop';
|
|
81
|
+
let preheaderClassName = 'email-preheader-desktop';
|
|
79
82
|
if (currentDevice === devices.tablet) {
|
|
80
83
|
messageContainerName = 'tablet-message-container';
|
|
81
84
|
subjectClassName = "email-subject-tablet";
|
|
85
|
+
preheaderClassName = "email-preheader-tablet";
|
|
82
86
|
} else if (currentDevice === devices.mobile) {
|
|
83
87
|
messageContainerName = 'mobile-message-container';
|
|
84
88
|
subjectClassName = "email-subject-mobile";
|
|
89
|
+
preheaderClassName = "email-preheader-mobile";
|
|
85
90
|
}
|
|
86
91
|
const emailSubject = get(templateData, 'versions.base.subject') || templateSubject;
|
|
92
|
+
const emailPreHeader = get(templateData, 'versions.base.preheader') || templatePreHeader;
|
|
87
93
|
const emailSubjectLabel = emailSubject && (
|
|
88
94
|
<CapLabel className={subjectClassName} type="label2">
|
|
89
95
|
<FormattedMessage {...messages.subject} /> {emailSubject}</CapLabel>
|
|
90
96
|
);
|
|
97
|
+
const emailPreHeaderLabel = emailPreHeader && (
|
|
98
|
+
<CapLabel className={preheaderClassName} type="label2">
|
|
99
|
+
<FormattedMessage {...messages.preheader} /> {emailPreHeader}</CapLabel>
|
|
100
|
+
);
|
|
91
101
|
const iframeDiv = (<div className={`${messageContainerName}`}>
|
|
92
102
|
{emailSubjectLabel}
|
|
93
|
-
|
|
103
|
+
{emailPreHeaderLabel}
|
|
104
|
+
<iframe srcDoc={updateCopyContent} {...deviceAspectRatio[currentDevice](emailSubject, emailPreHeader)} >
|
|
94
105
|
<p><FormattedMessage {...messages.browserDoesntSupportIframe} /></p>
|
|
95
106
|
</iframe>
|
|
96
107
|
</div>);
|
|
@@ -171,6 +182,7 @@ export class EmailPreviewV2 extends React.Component {
|
|
|
171
182
|
EmailPreviewV2.propTypes = {
|
|
172
183
|
templateContent: PropTypes.string,
|
|
173
184
|
templateSubject: PropTypes.string,
|
|
185
|
+
templatePreHeader: PropTypes.string,
|
|
174
186
|
templateData: PropTypes.object,
|
|
175
187
|
templateActions: PropTypes.object,
|
|
176
188
|
device: PropTypes.string,
|
|
@@ -42,6 +42,10 @@ export default defineMessages({
|
|
|
42
42
|
id: 'creatives.componentsV2.EmailPreviewV2.subject',
|
|
43
43
|
defaultMessage: 'Subject:',
|
|
44
44
|
},
|
|
45
|
+
preheader: {
|
|
46
|
+
id: 'creatives.componentsV2.EmailPreviewV2.preheader',
|
|
47
|
+
defaultMessage: 'Pre-header:',
|
|
48
|
+
},
|
|
45
49
|
browserDoesntSupportIframe: {
|
|
46
50
|
id: 'creatives.componentsV2.EmailPreviewV2.browserDoesntSupportIframe',
|
|
47
51
|
defaultMessage: 'Your browser does not support iframes.',
|
|
@@ -13,4 +13,47 @@ describe('<EmailPreviewV2 />', () => {
|
|
|
13
13
|
/>);
|
|
14
14
|
expect(compoent).toMatchSnapshot();
|
|
15
15
|
});
|
|
16
|
+
|
|
17
|
+
const baseProps = {
|
|
18
|
+
templateData: {},
|
|
19
|
+
templateActions: {
|
|
20
|
+
getTemplateDetails: jest.fn(),
|
|
21
|
+
resetTemplateData: jest.fn(),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// The desktop pane's content is passed as a prop to CapTab (not a rendered child), so
|
|
26
|
+
// shallow() won't reach into it via .find() directly - render that pane's content JSX
|
|
27
|
+
// on its own to inspect it.
|
|
28
|
+
const getDesktopPaneWrapper = (wrapper) => {
|
|
29
|
+
const panes = wrapper.find('CapTab').prop('panes');
|
|
30
|
+
const desktopPane = panes.find((pane) => pane.key === 'desktop');
|
|
31
|
+
return shallow(desktopPane.content);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
it('does not render a pre-header label when templatePreHeader is not provided', () => {
|
|
35
|
+
const wrapper = shallow(<EmailPreviewV2 {...baseProps} templateSubject="Hello" />);
|
|
36
|
+
expect(getDesktopPaneWrapper(wrapper).find('.email-preheader-desktop')).toHaveLength(0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders the pre-header label for the current (desktop) device by default', () => {
|
|
40
|
+
const wrapper = shallow(
|
|
41
|
+
<EmailPreviewV2 {...baseProps} templateSubject="Hello" templatePreHeader="Enjoy 20% off" />
|
|
42
|
+
);
|
|
43
|
+
const label = getDesktopPaneWrapper(wrapper).find('.email-preheader-desktop');
|
|
44
|
+
expect(label).toHaveLength(1);
|
|
45
|
+
expect(label.text()).toContain('Enjoy 20% off');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('prefers templateData.versions.base.preheader over the templatePreHeader prop', () => {
|
|
49
|
+
const wrapper = shallow(
|
|
50
|
+
<EmailPreviewV2
|
|
51
|
+
{...baseProps}
|
|
52
|
+
templateData={{ versions: { base: { preheader: 'From template data' } } }}
|
|
53
|
+
templatePreHeader="From prop"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
const label = getDesktopPaneWrapper(wrapper).find('.email-preheader-desktop');
|
|
57
|
+
expect(label.text()).toContain('From template data');
|
|
58
|
+
});
|
|
16
59
|
});
|