@capillarytech/creatives-library 8.0.330-alpha.0 → 8.0.330-alpha.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/package.json +1 -1
- package/utils/tests/tagValidations.test.js +20 -0
- package/v2Components/CapActionButton/constants.js +7 -0
- package/v2Components/CapActionButton/index.js +167 -109
- package/v2Components/CapActionButton/index.scss +157 -6
- package/v2Components/CapActionButton/messages.js +19 -3
- package/v2Components/CapActionButton/tests/index.test.js +41 -17
- package/v2Components/CapTagList/index.js +28 -23
- package/v2Components/CapTagList/style.scss +29 -0
- package/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
- package/v2Components/CapTagListWithInput/index.js +4 -0
- package/v2Components/CapWhatsappCTA/index.js +2 -0
- package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +1 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +160 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +18 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +323 -77
- package/v2Components/CommonTestAndPreview/messages.js +8 -0
- package/v2Components/CommonTestAndPreview/reducer.js +3 -1
- package/v2Components/CommonTestAndPreview/sagas.js +2 -1
- package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
- package/v2Components/FormBuilder/index.js +1 -0
- package/v2Components/HtmlEditor/HTMLEditor.js +6 -1
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +927 -2
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +3 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +33 -23
- package/v2Components/TemplatePreview/constants.js +2 -0
- package/v2Components/TemplatePreview/index.js +143 -28
- package/v2Components/TemplatePreview/tests/index.test.js +142 -0
- package/v2Components/mockdata.js +1 -0
- package/v2Containers/BeeEditor/index.js +19 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +28 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +5 -0
- package/v2Containers/Email/index.js +78 -39
- package/v2Containers/Email/reducer.js +2 -2
- package/v2Containers/Email/sagas.js +3 -1
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -2
- package/v2Containers/Email/tests/sagas.test.js +230 -0
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +6 -1
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +20 -2
- package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +3 -1
- package/v2Containers/EmailWrapper/index.js +4 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +9 -0
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +1 -0
- package/v2Containers/MobilePush/Create/index.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +2 -0
- package/v2Containers/MobilepushWrapper/index.js +3 -1
- package/v2Containers/Rcs/constants.js +79 -5
- package/v2Containers/Rcs/index.js +1374 -73
- package/v2Containers/Rcs/index.js.rej +1336 -0
- package/v2Containers/Rcs/index.scss +191 -0
- package/v2Containers/Rcs/index.scss.rej +74 -0
- package/v2Containers/Rcs/messages.js +26 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +69173 -118166
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +128 -0
- package/v2Containers/Rcs/tests/index.test.js +132 -94
- package/v2Containers/Rcs/tests/utils.test.js +220 -38
- package/v2Containers/Rcs/utils.js +77 -1
- package/v2Containers/Sms/Edit/index.js +2 -0
- package/v2Containers/SmsWrapper/index.js +2 -0
- package/v2Containers/TagList/index.js +73 -20
- package/v2Containers/TagList/messages.js +4 -0
- package/v2Containers/TagList/tests/TagList.test.js +124 -20
- package/v2Containers/TagList/tests/mockdata.js +17 -0
- package/v2Containers/Templates/_templates.scss +99 -0
- package/v2Containers/Templates/index.js +29 -14
- package/v2Containers/Viber/index.js +3 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +0 -2
- package/v2Containers/WebPush/Create/index.js +10 -2
- package/v2Containers/Whatsapp/index.js +5 -0
- package/v2Containers/Zalo/index.js +2 -0
|
@@ -88,6 +88,55 @@ describe('Email Templates Sagas', () => {
|
|
|
88
88
|
.run();
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
it('should handle creating a template successfully with onCreateTemplateComplete callback', () => {
|
|
92
|
+
const onCreateTemplateComplete = jest.fn();
|
|
93
|
+
const template = { id: 1, name: 'New Template', onCreateTemplateComplete };
|
|
94
|
+
const fakeResponse = {
|
|
95
|
+
success: true,
|
|
96
|
+
response: { id: 1, name: 'New Template', status: 'created' },
|
|
97
|
+
status: { code: 200 },
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return expectSaga(sagas.createTemplate, template)
|
|
101
|
+
.provide([
|
|
102
|
+
[matchers.call.fn(Api.createEmailTemplate), fakeResponse],
|
|
103
|
+
])
|
|
104
|
+
.put({
|
|
105
|
+
type: types.CREATE_TEMPLATE_SUCCESS,
|
|
106
|
+
data: fakeResponse.response,
|
|
107
|
+
statusCode: 200,
|
|
108
|
+
errorMsg: undefined,
|
|
109
|
+
})
|
|
110
|
+
.run()
|
|
111
|
+
.then(() => {
|
|
112
|
+
expect(onCreateTemplateComplete).toHaveBeenCalledWith(fakeResponse.response);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should handle creating a template successfully when result has no status (statusCode empty string)', () => {
|
|
117
|
+
const onCreateTemplateComplete = jest.fn();
|
|
118
|
+
const template = { id: 1, name: 'New Template', onCreateTemplateComplete };
|
|
119
|
+
const fakeResponse = {
|
|
120
|
+
success: true,
|
|
121
|
+
response: { id: 1, name: 'New Template' },
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return expectSaga(sagas.createTemplate, template)
|
|
125
|
+
.provide([
|
|
126
|
+
[matchers.call.fn(Api.createEmailTemplate), fakeResponse],
|
|
127
|
+
])
|
|
128
|
+
.put({
|
|
129
|
+
type: types.CREATE_TEMPLATE_SUCCESS,
|
|
130
|
+
data: fakeResponse.response,
|
|
131
|
+
statusCode: '',
|
|
132
|
+
errorMsg: undefined,
|
|
133
|
+
})
|
|
134
|
+
.run()
|
|
135
|
+
.then(() => {
|
|
136
|
+
expect(onCreateTemplateComplete).toHaveBeenCalledWith(fakeResponse.response);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
91
140
|
it('should handle errors when creating a template fails', () => {
|
|
92
141
|
const template = { id: 1, name: 'New Template' };
|
|
93
142
|
const fakeError = new Error('Failed to create template');
|
|
@@ -150,6 +199,29 @@ describe('Email Templates Sagas', () => {
|
|
|
150
199
|
.run();
|
|
151
200
|
});
|
|
152
201
|
|
|
202
|
+
it('should handle successful asset upload with no status (empty statusCode)', () => {
|
|
203
|
+
const uploadResponse = {
|
|
204
|
+
response: {
|
|
205
|
+
asset: {
|
|
206
|
+
id: 1,
|
|
207
|
+
url: 'http://example.com/asset.jpg',
|
|
208
|
+
metaInfo: { secure_file_path: 'path', file_size: 1024 },
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
|
|
214
|
+
.provide([
|
|
215
|
+
[matchers.call.fn(Api.uploadFile), uploadResponse],
|
|
216
|
+
])
|
|
217
|
+
.put({
|
|
218
|
+
type: types.UPLOAD_ASSET_SUCCESS,
|
|
219
|
+
data: uploadResponse.response.asset,
|
|
220
|
+
statusCode: '',
|
|
221
|
+
})
|
|
222
|
+
.run();
|
|
223
|
+
});
|
|
224
|
+
|
|
153
225
|
it('should handle failure in asset upload', () => {
|
|
154
226
|
const error = new Error('Failed to upload asset');
|
|
155
227
|
|
|
@@ -275,6 +347,37 @@ describe('getAllAssets saga', () => {
|
|
|
275
347
|
.run();
|
|
276
348
|
});
|
|
277
349
|
|
|
350
|
+
it('should handle success when page > 1 (isReset false)', () => {
|
|
351
|
+
const fakeResponse = {
|
|
352
|
+
status: { code: 200 },
|
|
353
|
+
response: [{ id: 3, name: 'Asset 3' }],
|
|
354
|
+
};
|
|
355
|
+
const payload = { assetType: 'image', queryParams: { page: 2 } };
|
|
356
|
+
|
|
357
|
+
return expectSaga(sagas.getAllAssets, payload)
|
|
358
|
+
.provide([
|
|
359
|
+
[matchers.call.fn(Api.getAllAssets), fakeResponse],
|
|
360
|
+
])
|
|
361
|
+
.put({
|
|
362
|
+
type: types.GET_ALL_ASSETS_SUCCESS,
|
|
363
|
+
data: fakeResponse.response,
|
|
364
|
+
isReset: false,
|
|
365
|
+
})
|
|
366
|
+
.run();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should handle failure when fetching all assets throws an error', () => {
|
|
370
|
+
const error = new Error('Network error');
|
|
371
|
+
const payload = { assetType: 'image', queryParams: { page: 1 } };
|
|
372
|
+
|
|
373
|
+
return expectSaga(sagas.getAllAssets, payload)
|
|
374
|
+
.provide([
|
|
375
|
+
[matchers.call.fn(Api.getAllAssets), throwError(error)],
|
|
376
|
+
])
|
|
377
|
+
.put({ type: types.GET_ALL_ASSETS_FAILURE, error })
|
|
378
|
+
.run();
|
|
379
|
+
});
|
|
380
|
+
|
|
278
381
|
describe('getCmsAccounts saga', () => {
|
|
279
382
|
it('should handle successful CMS accounts fetch with matching type', () => {
|
|
280
383
|
const cmsType = 'bee';
|
|
@@ -463,6 +566,20 @@ describe('getAllAssets saga', () => {
|
|
|
463
566
|
.run();
|
|
464
567
|
});
|
|
465
568
|
|
|
569
|
+
it('should use "Unknown error" fallback when statusCode is also undefined', () => {
|
|
570
|
+
const template = { id: 1, name: 'New Template' };
|
|
571
|
+
const fakeResponse = {
|
|
572
|
+
success: false,
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
return expectSaga(sagas.createTemplate, template)
|
|
576
|
+
.provide([
|
|
577
|
+
[matchers.call.fn(Api.createEmailTemplate), fakeResponse],
|
|
578
|
+
])
|
|
579
|
+
.put({ type: types.CREATE_TEMPLATE_FAILURE, errorMsg: 'API Error: Unknown error' })
|
|
580
|
+
.run();
|
|
581
|
+
});
|
|
582
|
+
|
|
466
583
|
it('should handle callback error gracefully', () => {
|
|
467
584
|
const template = {
|
|
468
585
|
id: 1,
|
|
@@ -569,3 +686,116 @@ describe('getAllAssets saga', () => {
|
|
|
569
686
|
});
|
|
570
687
|
});
|
|
571
688
|
});
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
describe('getCmsSetting saga', () => {
|
|
692
|
+
const basePayload = {
|
|
693
|
+
cmsType: 'bee',
|
|
694
|
+
projectId: 1,
|
|
695
|
+
cmsMode: 'normal',
|
|
696
|
+
langId: 1,
|
|
697
|
+
isEdmSupport: false,
|
|
698
|
+
isBEEAppEnable: true,
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
it('should handle successful settings fetch with matching type (isBeeEnabled true)', () => {
|
|
702
|
+
const fakeResponse = {
|
|
703
|
+
data: {
|
|
704
|
+
response: {
|
|
705
|
+
cmsDetails: { type: 'bee', settings: {} },
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
711
|
+
.provide([
|
|
712
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
713
|
+
])
|
|
714
|
+
.put({ type: types.GET_CMS_ACCOUNTS_SUCCESS, isBeeEnabled: true })
|
|
715
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails })
|
|
716
|
+
.run();
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
it('should handle successful settings fetch with non-matching type (isBeeEnabled false)', () => {
|
|
720
|
+
const fakeResponse = {
|
|
721
|
+
data: {
|
|
722
|
+
response: {
|
|
723
|
+
cmsDetails: { type: 'ck', settings: {} },
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
729
|
+
.provide([
|
|
730
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
731
|
+
])
|
|
732
|
+
.put({ type: types.GET_CMS_ACCOUNTS_SUCCESS, isBeeEnabled: false })
|
|
733
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails })
|
|
734
|
+
.run();
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
it('should handle successful settings fetch when cmsDetails is undefined (fallback to empty object)', () => {
|
|
738
|
+
const fakeResponse = {
|
|
739
|
+
data: {
|
|
740
|
+
response: {},
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
745
|
+
.provide([
|
|
746
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
747
|
+
])
|
|
748
|
+
.put({ type: types.GET_CMS_ACCOUNTS_SUCCESS, isBeeEnabled: false })
|
|
749
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: undefined })
|
|
750
|
+
.run();
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it('should handle error when fetching CMS settings fails', () => {
|
|
754
|
+
const fakeError = new Error('Failed to fetch CMS settings');
|
|
755
|
+
|
|
756
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
757
|
+
.provide([
|
|
758
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), throwError(fakeError)],
|
|
759
|
+
])
|
|
760
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_FAILURE, error: fakeError })
|
|
761
|
+
.run();
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
describe('getCmsData saga', () => {
|
|
767
|
+
const payload = { cmsType: 'bee', projectId: 1, langId: 1 };
|
|
768
|
+
|
|
769
|
+
it('should handle successful CMS data fetch', () => {
|
|
770
|
+
const fakeResponse = {
|
|
771
|
+
data: {
|
|
772
|
+
response: {
|
|
773
|
+
data: { html: '<p>content</p>' },
|
|
774
|
+
langId: 1,
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
return expectSaga(sagas.getCmsData, payload)
|
|
780
|
+
.provide([
|
|
781
|
+
[matchers.call.fn(Api.getCmsTemplateDataV2), fakeResponse],
|
|
782
|
+
])
|
|
783
|
+
.put({
|
|
784
|
+
type: types.GET_CMS_EDITOR_DATA_SUCCESS,
|
|
785
|
+
data: fakeResponse.data.response.data,
|
|
786
|
+
langId: fakeResponse.data.response.langId,
|
|
787
|
+
})
|
|
788
|
+
.run();
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
it('should handle error when fetching CMS data fails', () => {
|
|
792
|
+
const fakeError = new Error('Failed to fetch CMS data');
|
|
793
|
+
|
|
794
|
+
return expectSaga(sagas.getCmsData, payload)
|
|
795
|
+
.provide([
|
|
796
|
+
[matchers.call.fn(Api.getCmsTemplateDataV2), throwError(fakeError)],
|
|
797
|
+
])
|
|
798
|
+
.put({ type: types.GET_CMS_EDITOR_DATA_FAILURE, error: fakeError })
|
|
799
|
+
.run();
|
|
800
|
+
});
|
|
801
|
+
});
|
|
@@ -54,6 +54,7 @@ const EmailHTMLEditor = (props) => {
|
|
|
54
54
|
globalActions,
|
|
55
55
|
loadingTags,
|
|
56
56
|
eventContextTags,
|
|
57
|
+
waitEventContextTags,
|
|
57
58
|
forwardedTags,
|
|
58
59
|
selectedOfferDetails,
|
|
59
60
|
currentOrgDetails,
|
|
@@ -510,7 +511,7 @@ const EmailHTMLEditor = (props) => {
|
|
|
510
511
|
setTagValidationError(null);
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
|
-
}, [tags, injectedTags, location, getDefaultTags, eventContextTags, showLiquidErrorInFooter]);
|
|
514
|
+
}, [tags, injectedTags, location, getDefaultTags, eventContextTags, waitEventContextTags, showLiquidErrorInFooter]);
|
|
514
515
|
|
|
515
516
|
// Store the last validation state received from HTMLEditor
|
|
516
517
|
const lastValidationStateRef = useRef(null);
|
|
@@ -1100,6 +1101,7 @@ const EmailHTMLEditor = (props) => {
|
|
|
1100
1101
|
injectedTags={injectedTags || {}}
|
|
1101
1102
|
selectedOfferDetails={selectedOfferDetails}
|
|
1102
1103
|
eventContextTags={eventContextTags}
|
|
1104
|
+
waitEventContextTags={waitEventContextTags}
|
|
1103
1105
|
showHeading
|
|
1104
1106
|
showTagList
|
|
1105
1107
|
showInput
|
|
@@ -1124,6 +1126,7 @@ const EmailHTMLEditor = (props) => {
|
|
|
1124
1126
|
injectedTags={injectedTags}
|
|
1125
1127
|
location={location}
|
|
1126
1128
|
eventContextTags={eventContextTags}
|
|
1129
|
+
waitEventContextTags={waitEventContextTags}
|
|
1127
1130
|
selectedOfferDetails={selectedOfferDetails}
|
|
1128
1131
|
channel={EMAIL}
|
|
1129
1132
|
userLocale={intl.locale || 'en'}
|
|
@@ -1151,6 +1154,7 @@ EmailHTMLEditor.propTypes = {
|
|
|
1151
1154
|
globalActions: PropTypes.object,
|
|
1152
1155
|
loadingTags: PropTypes.bool,
|
|
1153
1156
|
eventContextTags: PropTypes.array,
|
|
1157
|
+
waitEventContextTags: PropTypes.object,
|
|
1154
1158
|
forwardedTags: PropTypes.object,
|
|
1155
1159
|
selectedOfferDetails: PropTypes.array,
|
|
1156
1160
|
currentOrgDetails: PropTypes.object,
|
|
@@ -1197,6 +1201,7 @@ EmailHTMLEditor.defaultProps = {
|
|
|
1197
1201
|
globalActions: {},
|
|
1198
1202
|
loadingTags: false,
|
|
1199
1203
|
eventContextTags: [],
|
|
1204
|
+
waitEventContextTags: {},
|
|
1200
1205
|
forwardedTags: {},
|
|
1201
1206
|
selectedOfferDetails: [],
|
|
1202
1207
|
currentOrgDetails: {},
|
|
@@ -173,6 +173,7 @@ const EmailWrapperView = ({
|
|
|
173
173
|
forwardedTags,
|
|
174
174
|
selectedOfferDetails,
|
|
175
175
|
eventContextTags,
|
|
176
|
+
waitEventContextTags,
|
|
176
177
|
getFormdata,
|
|
177
178
|
isGetFormData,
|
|
178
179
|
getLiquidTags,
|
|
@@ -246,6 +247,7 @@ const EmailWrapperView = ({
|
|
|
246
247
|
globalActions,
|
|
247
248
|
loadingTags,
|
|
248
249
|
eventContextTags,
|
|
250
|
+
waitEventContextTags,
|
|
249
251
|
forwardedTags,
|
|
250
252
|
selectedOfferDetails,
|
|
251
253
|
currentOrgDetails,
|
|
@@ -371,6 +373,7 @@ EmailWrapperView.propTypes = {
|
|
|
371
373
|
forwardedTags: PropTypes.object,
|
|
372
374
|
selectedOfferDetails: PropTypes.array,
|
|
373
375
|
eventContextTags: PropTypes.array,
|
|
376
|
+
waitEventContextTags: PropTypes.object,
|
|
374
377
|
emailActions: PropTypes.object,
|
|
375
378
|
Email: PropTypes.object,
|
|
376
379
|
templateData: PropTypes.object,
|
|
@@ -71,7 +71,10 @@ jest.mock('../../../../v2Components/HtmlEditor/index.lazy', () => {
|
|
|
71
71
|
}));
|
|
72
72
|
|
|
73
73
|
return (
|
|
74
|
-
<div
|
|
74
|
+
<div
|
|
75
|
+
data-testid="html-editor"
|
|
76
|
+
data-wait-event-context-tags={JSON.stringify(props.waitEventContextTags ?? null)}
|
|
77
|
+
>
|
|
75
78
|
<button
|
|
76
79
|
onClick={() => props.onContentChange && props.onContentChange('<p>New content</p>')}
|
|
77
80
|
data-testid="trigger-content-change"
|
|
@@ -130,7 +133,10 @@ jest.mock('../../../../v2Components/HtmlEditor', () => {
|
|
|
130
133
|
}));
|
|
131
134
|
|
|
132
135
|
return (
|
|
133
|
-
<div
|
|
136
|
+
<div
|
|
137
|
+
data-testid="html-editor"
|
|
138
|
+
data-wait-event-context-tags={JSON.stringify(props.waitEventContextTags ?? null)}
|
|
139
|
+
>
|
|
134
140
|
<button
|
|
135
141
|
onClick={() => props.onContentChange && props.onContentChange('<p>New content</p>')}
|
|
136
142
|
data-testid="trigger-content-change"
|
|
@@ -364,6 +370,7 @@ const defaultProps = {
|
|
|
364
370
|
},
|
|
365
371
|
loadingTags: false,
|
|
366
372
|
eventContextTags: [],
|
|
373
|
+
waitEventContextTags: {},
|
|
367
374
|
forwardedTags: {},
|
|
368
375
|
selectedOfferDetails: [],
|
|
369
376
|
currentOrgDetails: {
|
|
@@ -522,6 +529,17 @@ describe('EmailHTMLEditor', () => {
|
|
|
522
529
|
});
|
|
523
530
|
});
|
|
524
531
|
|
|
532
|
+
describe('waitEventContextTags', () => {
|
|
533
|
+
it('forwards waitEventContextTags to HTMLEditor', () => {
|
|
534
|
+
const waitMap = { b1: { eventName: 'E', blockName: 'B', tags: ['t'] } };
|
|
535
|
+
renderWithIntl({ waitEventContextTags: waitMap });
|
|
536
|
+
expect(screen.getByTestId('html-editor')).toHaveAttribute(
|
|
537
|
+
'data-wait-event-context-tags',
|
|
538
|
+
JSON.stringify(waitMap),
|
|
539
|
+
);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
|
|
525
543
|
describe('Content Initialization', () => {
|
|
526
544
|
it('initializes with empty content in create mode', () => {
|
|
527
545
|
renderWithIntl({ isGetFormData: false });
|
|
@@ -37,7 +37,14 @@ jest.mock('../EmailHTMLEditor', () => {
|
|
|
37
37
|
getContentForPreview: jest.fn(() => '<p>Test</p>'),
|
|
38
38
|
}));
|
|
39
39
|
|
|
40
|
-
return
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
data-testid="email-html-editor"
|
|
43
|
+
data-wait-event-context-tags={JSON.stringify(props.waitEventContextTags ?? null)}
|
|
44
|
+
>
|
|
45
|
+
HTML Editor
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
41
48
|
});
|
|
42
49
|
});
|
|
43
50
|
|
|
@@ -137,6 +144,7 @@ const defaultProps = {
|
|
|
137
144
|
forwardedTags: {},
|
|
138
145
|
selectedOfferDetails: [],
|
|
139
146
|
eventContextTags: [],
|
|
147
|
+
waitEventContextTags: {},
|
|
140
148
|
getFormdata: jest.fn(),
|
|
141
149
|
isGetFormData: false,
|
|
142
150
|
getLiquidTags: jest.fn(),
|
|
@@ -171,6 +179,13 @@ describe('EmailWrapperView', () => {
|
|
|
171
179
|
jest.clearAllMocks();
|
|
172
180
|
});
|
|
173
181
|
|
|
182
|
+
it('passes waitEventContextTags to EmailHTMLEditor when HTML editor is shown', () => {
|
|
183
|
+
const waitMap = { b1: { eventName: 'E', blockName: 'B', tags: [] } };
|
|
184
|
+
renderWithIntl({ waitEventContextTags: waitMap });
|
|
185
|
+
const el = screen.getByTestId('email-html-editor');
|
|
186
|
+
expect(el).toHaveAttribute('data-wait-event-context-tags', JSON.stringify(waitMap));
|
|
187
|
+
});
|
|
188
|
+
|
|
174
189
|
describe('Mode Selection UI', () => {
|
|
175
190
|
it('renders mode selection when step is MODE_SELECTION', () => {
|
|
176
191
|
renderWithIntl({ step: STEPS.MODE_SELECTION });
|
|
@@ -51,6 +51,7 @@ const useEmailWrapper = ({
|
|
|
51
51
|
editor,
|
|
52
52
|
moduleType,
|
|
53
53
|
eventContextTags,
|
|
54
|
+
waitEventContextTags,
|
|
54
55
|
isLoyaltyModule,
|
|
55
56
|
// Props for CmsTemplates component
|
|
56
57
|
cmsTemplatesLoader,
|
|
@@ -251,7 +252,6 @@ const useEmailWrapper = ({
|
|
|
251
252
|
};
|
|
252
253
|
|
|
253
254
|
const isDragDrop = getIsDragDrop(editTemplateData);
|
|
254
|
-
|
|
255
255
|
// If it's a BEE template, set it in Templates.BEETemplate
|
|
256
256
|
if (isDragDrop) {
|
|
257
257
|
beeTemplateSetRef.current = true;
|
|
@@ -737,6 +737,7 @@ const useEmailWrapper = ({
|
|
|
737
737
|
selectedEditorMode, // Pass selected mode to Email component (only for HTML_EDITOR)
|
|
738
738
|
moduleType,
|
|
739
739
|
eventContextTags,
|
|
740
|
+
waitEventContextTags,
|
|
740
741
|
isLoyaltyModule,
|
|
741
742
|
showTestAndPreviewSlidebox,
|
|
742
743
|
handleTestAndPreview,
|
|
@@ -766,6 +767,7 @@ const useEmailWrapper = ({
|
|
|
766
767
|
editor,
|
|
767
768
|
moduleType,
|
|
768
769
|
eventContextTags,
|
|
770
|
+
waitEventContextTags,
|
|
769
771
|
isLoyaltyModule,
|
|
770
772
|
showTestAndPreviewSlidebox,
|
|
771
773
|
handleTestAndPreview,
|
|
@@ -63,6 +63,7 @@ const EmailWrapper = (props) => {
|
|
|
63
63
|
onEnterTemplateName,
|
|
64
64
|
onRemoveTemplateName,
|
|
65
65
|
eventContextTags,
|
|
66
|
+
waitEventContextTags,
|
|
66
67
|
isLoyaltyModule,
|
|
67
68
|
cmsTemplatesLoader,
|
|
68
69
|
onPreviewContentClicked,
|
|
@@ -130,6 +131,7 @@ const EmailWrapper = (props) => {
|
|
|
130
131
|
onEnterTemplateName,
|
|
131
132
|
onRemoveTemplateName,
|
|
132
133
|
eventContextTags,
|
|
134
|
+
waitEventContextTags,
|
|
133
135
|
isLoyaltyModule,
|
|
134
136
|
cmsTemplatesLoader,
|
|
135
137
|
onPreviewContentClicked,
|
|
@@ -184,6 +186,7 @@ const EmailWrapper = (props) => {
|
|
|
184
186
|
forwardedTags={forwardedTags}
|
|
185
187
|
selectedOfferDetails={selectedOfferDetails}
|
|
186
188
|
eventContextTags={eventContextTags}
|
|
189
|
+
waitEventContextTags={waitEventContextTags}
|
|
187
190
|
getFormdata={getFormdata}
|
|
188
191
|
isGetFormData={isGetFormData}
|
|
189
192
|
getLiquidTags={globalActionsProp?.getLiquidTags}
|
|
@@ -241,6 +244,7 @@ EmailWrapper.propTypes = {
|
|
|
241
244
|
onEnterTemplateName: PropTypes.func,
|
|
242
245
|
onRemoveTemplateName: PropTypes.func,
|
|
243
246
|
eventContextTags: PropTypes.array,
|
|
247
|
+
waitEventContextTags: PropTypes.object,
|
|
244
248
|
isLoyaltyModule: PropTypes.bool,
|
|
245
249
|
onPreviewContentClicked: PropTypes.func,
|
|
246
250
|
onTestContentClicked: PropTypes.func,
|
|
@@ -102,6 +102,7 @@ describe('useEmailWrapper', () => {
|
|
|
102
102
|
editor: null,
|
|
103
103
|
moduleType: '',
|
|
104
104
|
eventContextTags: [],
|
|
105
|
+
waitEventContextTags: {},
|
|
105
106
|
isLoyaltyModule: false,
|
|
106
107
|
cmsTemplatesLoader: false,
|
|
107
108
|
currentOrgDetails: { id: 'org1' },
|
|
@@ -120,6 +121,14 @@ describe('useEmailWrapper', () => {
|
|
|
120
121
|
expect(result.current.onTemplateNameChange).toBeInstanceOf(Function);
|
|
121
122
|
});
|
|
122
123
|
|
|
124
|
+
it('passes waitEventContextTags through emailProps', () => {
|
|
125
|
+
const waitMap = { block1: { eventName: 'E', blockName: 'B', tags: [] } };
|
|
126
|
+
const { result } = renderHook(() =>
|
|
127
|
+
useEmailWrapper({ ...mockProps, waitEventContextTags: waitMap }),
|
|
128
|
+
);
|
|
129
|
+
expect(result.current.emailProps.waitEventContextTags).toEqual(waitMap);
|
|
130
|
+
});
|
|
131
|
+
|
|
123
132
|
it('handles template name change correctly', () => {
|
|
124
133
|
const { result } = renderHook(() => useEmailWrapper(mockProps));
|
|
125
134
|
|
|
@@ -1966,6 +1966,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1966
1966
|
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
1967
1967
|
isFullMode={this.props.isFullMode}
|
|
1968
1968
|
eventContextTags={this.props?.eventContextTags}
|
|
1969
|
+
waitEventContextTags={this.props?.waitEventContextTags}
|
|
1969
1970
|
messageDetails={this.props?.messageDetails}
|
|
1970
1971
|
restrictPersonalization={this.props.restrictPersonalization}
|
|
1971
1972
|
/>
|
|
@@ -2068,6 +2069,7 @@ Create.propTypes = {
|
|
|
2068
2069
|
onPreviewContentClicked: PropTypes.func,
|
|
2069
2070
|
onTestContentClicked: PropTypes.func,
|
|
2070
2071
|
eventContextTags: PropTypes.array,
|
|
2072
|
+
waitEventContextTags: PropTypes.object,
|
|
2071
2073
|
getLiquidTags: PropTypes.func,
|
|
2072
2074
|
showLiquidErrorInFooter: PropTypes.func,
|
|
2073
2075
|
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
@@ -2233,6 +2233,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2233
2233
|
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
2234
2234
|
isFullMode={this.props.isFullMode}
|
|
2235
2235
|
eventContextTags={this.props?.eventContextTags}
|
|
2236
|
+
waitEventContextTags={this.props?.waitEventContextTags}
|
|
2236
2237
|
restrictPersonalization={this.props.restrictPersonalization}
|
|
2237
2238
|
/>;
|
|
2238
2239
|
})()}
|
|
@@ -2339,6 +2340,7 @@ Edit.propTypes = {
|
|
|
2339
2340
|
onTestContentClicked: PropTypes.func,
|
|
2340
2341
|
creativesMode: PropTypes.string,
|
|
2341
2342
|
eventContextTags: PropTypes.array,
|
|
2343
|
+
waitEventContextTags: PropTypes.object,
|
|
2342
2344
|
getLiquidTags: PropTypes.func,
|
|
2343
2345
|
showLiquidErrorInFooter: PropTypes.func,
|
|
2344
2346
|
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
@@ -72,7 +72,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
render() {
|
|
75
|
-
const {mobilePushCreateMode, step, getFormData, getLiquidTags, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], showTestAndPreviewSlidebox, handleTestAndPreview, handleCloseTestAndPreview, restrictPersonalization, isAnonymousType, onPersonalizationTokensChange} = this.props;
|
|
75
|
+
const {mobilePushCreateMode, step, getFormData, getLiquidTags, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], waitEventContextTags = {},showTestAndPreviewSlidebox, handleTestAndPreview, handleCloseTestAndPreview, restrictPersonalization, isAnonymousType, onPersonalizationTokensChange} = this.props;
|
|
76
76
|
const {templateName} = this.state;
|
|
77
77
|
const isShowMobilepushCreate = !isEmpty(mobilePushCreateMode);
|
|
78
78
|
return (
|
|
@@ -121,6 +121,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
|
|
|
121
121
|
templateData={templateData}
|
|
122
122
|
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
123
123
|
eventContextTags={eventContextTags}
|
|
124
|
+
waitEventContextTags={waitEventContextTags}
|
|
124
125
|
showLiquidErrorInFooter={this.props.showLiquidErrorInFooter}
|
|
125
126
|
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
126
127
|
handleTestAndPreview={handleTestAndPreview}
|
|
@@ -155,6 +156,7 @@ MobilepushWrapper.propTypes = {
|
|
|
155
156
|
type: PropTypes.string,
|
|
156
157
|
onValidationFail: PropTypes.func,
|
|
157
158
|
eventContextTags: PropTypes.array,
|
|
159
|
+
waitEventContextTags: PropTypes.object,
|
|
158
160
|
showLiquidErrorInFooter: PropTypes.func,
|
|
159
161
|
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
160
162
|
handleTestAndPreview: PropTypes.func,
|