@capillarytech/creatives-library 8.0.125 → 8.0.127-alpha.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/config/app.js +6 -0
- package/containers/App/constants.js +1 -0
- package/index.html +3 -1
- package/initialReducer.js +2 -0
- package/package.json +1 -1
- package/services/api.js +94 -1
- package/services/tests/api.test.js +191 -0
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +8 -3
- package/tests/integration/TemplateCreation/api-response.js +5 -0
- package/tests/integration/TemplateCreation/msw-handler.js +42 -63
- package/utils/common.js +7 -0
- package/utils/commonUtils.js +2 -6
- package/utils/createPayload.js +272 -0
- package/utils/tests/createPayload.test.js +761 -0
- package/v2Components/CapImageUpload/index.js +59 -46
- package/v2Components/CapInAppCTA/index.js +1 -0
- package/v2Components/CapMpushCTA/constants.js +25 -0
- package/v2Components/CapMpushCTA/index.js +332 -0
- package/v2Components/CapMpushCTA/index.scss +95 -0
- package/v2Components/CapMpushCTA/messages.js +89 -0
- package/v2Components/CapTagList/index.js +177 -120
- package/v2Components/CapVideoUpload/constants.js +3 -0
- package/v2Components/CapVideoUpload/index.js +167 -110
- package/v2Components/CapVideoUpload/messages.js +16 -0
- package/v2Components/Carousel/index.js +15 -13
- package/v2Components/CustomerSearchSection/_customerSearch.scss +309 -0
- package/v2Components/CustomerSearchSection/constants.js +5 -0
- package/v2Components/CustomerSearchSection/index.js +367 -0
- package/v2Components/CustomerSearchSection/messages.js +20 -0
- package/v2Components/CustomerSearchSection/tests/utils.test.js +334 -0
- package/v2Components/CustomerSearchSection/utils.js +49 -0
- package/v2Components/ErrorInfoNote/style.scss +1 -0
- package/v2Components/MobilePushPreviewV2/index.js +37 -5
- package/v2Components/TemplatePreview/_templatePreview.scss +114 -72
- package/v2Components/TemplatePreview/assets/images/Android _ With date and time.svg +29 -0
- package/v2Components/TemplatePreview/assets/images/android.svg +9 -0
- package/v2Components/TemplatePreview/assets/images/iOS _ With date and time.svg +26 -0
- package/v2Components/TemplatePreview/assets/images/ios.svg +9 -0
- package/v2Components/TemplatePreview/index.js +178 -50
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TestAndPreviewSlidebox/CustomValuesEditor.js +169 -0
- package/v2Components/TestAndPreviewSlidebox/LeftPanelContent.js +95 -0
- package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/SendTestMessage.js +68 -0
- package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +543 -0
- package/v2Components/TestAndPreviewSlidebox/actions.js +67 -0
- package/v2Components/TestAndPreviewSlidebox/constants.js +67 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +592 -0
- package/v2Components/TestAndPreviewSlidebox/messages.js +147 -0
- package/v2Components/TestAndPreviewSlidebox/reducer.js +233 -0
- package/v2Components/TestAndPreviewSlidebox/sagas.js +258 -0
- package/v2Components/TestAndPreviewSlidebox/selectors.js +142 -0
- package/v2Components/TestAndPreviewSlidebox/tests/CustomValuesEditor.test.js +425 -0
- package/v2Components/TestAndPreviewSlidebox/tests/LeftPanelContent.test.js +400 -0
- package/v2Components/TestAndPreviewSlidebox/tests/SendTestMessage.test.js +448 -0
- package/v2Components/TestAndPreviewSlidebox/tests/actions.test.js +80 -0
- package/v2Components/TestAndPreviewSlidebox/tests/reducer.test.js +367 -0
- package/v2Components/TestAndPreviewSlidebox/tests/saga.rtl.test.js +192 -0
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +652 -0
- package/v2Components/TestAndPreviewSlidebox/tests/selector.test.js +182 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +22 -10
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +23 -2
- package/v2Containers/CreativesContainer/index.js +216 -136
- package/v2Containers/CreativesContainer/messages.js +4 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +21 -0
- package/v2Containers/Email/index.js +27 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +10 -0
- package/v2Containers/EmailWrapper/index.js +6 -0
- package/v2Containers/InApp/constants.js +1 -0
- package/v2Containers/InApp/index.js +13 -13
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
- package/v2Containers/MobilePush/Create/index.js +1 -0
- package/v2Containers/MobilePush/commonMethods.js +7 -14
- package/v2Containers/MobilePushNew/actions.js +116 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +170 -0
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +754 -0
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +279 -0
- package/v2Containers/MobilePushNew/components/index.js +5 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +779 -0
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +2114 -0
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +343 -0
- package/v2Containers/MobilePushNew/constants.js +115 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1299 -0
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +1223 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +246 -0
- package/v2Containers/MobilePushNew/hooks/useUpload.js +726 -0
- package/v2Containers/MobilePushNew/index.js +2280 -0
- package/v2Containers/MobilePushNew/index.scss +308 -0
- package/v2Containers/MobilePushNew/messages.js +226 -0
- package/v2Containers/MobilePushNew/reducer.js +160 -0
- package/v2Containers/MobilePushNew/sagas.js +198 -0
- package/v2Containers/MobilePushNew/selectors.js +55 -0
- package/v2Containers/MobilePushNew/tests/reducer.test.js +741 -0
- package/v2Containers/MobilePushNew/tests/sagas.test.js +863 -0
- package/v2Containers/MobilePushNew/tests/selectors.test.js +425 -0
- package/v2Containers/MobilePushNew/tests/utils.test.js +322 -0
- package/v2Containers/MobilePushNew/utils.js +33 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +23 -5
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/TagList/index.js +56 -10
- package/v2Containers/Templates/_templates.scss +101 -1
- package/v2Containers/Templates/index.js +147 -35
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Templates/sagas.js +2 -0
- package/v2Containers/Whatsapp/constants.js +1 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -0
- package/v2Containers/Email/tests/index.test.js +0 -35
package/config/app.js
CHANGED
|
@@ -7,6 +7,9 @@ const config = {
|
|
|
7
7
|
campaigns_api_endpoint: '/iris/v2/campaigns',
|
|
8
8
|
campaigns_api_org_endpoint: '/iris/v2/org/campaign',
|
|
9
9
|
liquid_endpoint:'/iris/v2/template',
|
|
10
|
+
membercare_api_endpoint: '/member-care/api/v1',
|
|
11
|
+
iris_api_endpoint: '/iris/v2',
|
|
12
|
+
adiona_api_endpoint: '/adiona/api/v1',
|
|
10
13
|
auth_endpoint: '/arya/api/v1/auth',
|
|
11
14
|
arya_endpoint: '/arya/api/v1',
|
|
12
15
|
login_url: '/auth/login',
|
|
@@ -27,6 +30,9 @@ const config = {
|
|
|
27
30
|
login_url: '/auth/login',
|
|
28
31
|
dashboard_url: '/sms',
|
|
29
32
|
liquid_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/template',
|
|
33
|
+
membercare_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/member-care/api/v1',
|
|
34
|
+
iris_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2',
|
|
35
|
+
adiona_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/adiona/api/v1',
|
|
30
36
|
dashboard_url_v2: '/v2',
|
|
31
37
|
},
|
|
32
38
|
testing: {
|
|
@@ -18,6 +18,7 @@ export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
|
18
18
|
export const ENABLE_WECHAT = 'ENABLE_WECHAT';
|
|
19
19
|
export const ENABLE_CUSTOMER_BARCODE_TAG = "ENABLE_CUSTOMER_BARCODE_TAG";
|
|
20
20
|
export const EMAIL_UNSUBSCRIBE_TAG_MANDATORY = "EMAIL_UNSUBSCRIBE_TAG_MANDATORY";
|
|
21
|
+
export const ENABLE_NEW_MPUSH = "ENABLE_NEW_MPUSH";
|
|
21
22
|
|
|
22
23
|
export const CARD_RELATED_TAGS = [
|
|
23
24
|
'card_series',
|
package/index.html
CHANGED
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
<div style="position: fixed; top: 0; width: 100%; height: 100%; background: rgb(255,255,255); text-align: center;">
|
|
39
39
|
<img
|
|
40
40
|
style="width: 80px; margin-top: 20%;"
|
|
41
|
-
src="https://
|
|
41
|
+
src="https://storage.crm.n.content-cdn.io/capillary/capillary_loading_logo.gif"
|
|
42
|
+
loading="lazy"
|
|
43
|
+
data-testid="capillary-logo"
|
|
42
44
|
alt="Capillary"/>
|
|
43
45
|
</div>
|
|
44
46
|
</div>
|
package/initialReducer.js
CHANGED
|
@@ -14,6 +14,7 @@ import ftpReducer from 'v2Containers/FTP/reducer';
|
|
|
14
14
|
import galleryReducer from './v2Containers/Assets/Gallery/reducer';
|
|
15
15
|
import CapCollapsibleLeftNavigationReducer from '@capillarytech/cap-ui-library/CapCollapsibleLeftNavigation/reducer';
|
|
16
16
|
import { AIRA_REDUCER_DOMAIN, askAiraReducer } from '@capillarytech/cap-ui-library/CapAskAira';
|
|
17
|
+
import previewAndTestReducer from './v2Components/TestAndPreviewSlidebox/reducer';
|
|
17
18
|
|
|
18
19
|
export const initialReducer = {
|
|
19
20
|
language: languageProviderReducer,
|
|
@@ -31,4 +32,5 @@ export const initialReducer = {
|
|
|
31
32
|
[AIRA_REDUCER_DOMAIN]: askAiraReducer,
|
|
32
33
|
gallery: galleryReducer,
|
|
33
34
|
navigationConfig: CapCollapsibleLeftNavigationReducer,
|
|
35
|
+
previewAndTest: previewAndTestReducer,
|
|
34
36
|
};
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -16,6 +16,9 @@ let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
|
16
16
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
17
17
|
let CAMPAIGNS_API_ORG_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
18
18
|
let LIQUID_API_ENDPOINT = config.development.liquid_endpoint;
|
|
19
|
+
let MEMBERCARE_API_ENDPOINT = config.development.membercare_api_endpoint;
|
|
20
|
+
let IRIS_API_ENDPOINT = config.development.iris_api_endpoint;
|
|
21
|
+
let ADIONA_API_ENDPOINT = config.development.adiona_api_endpoint;
|
|
19
22
|
|
|
20
23
|
let API_AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
21
24
|
let ARYA_ENDPOINT = config.development.arya_endpoint;
|
|
@@ -29,6 +32,9 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
29
32
|
SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
|
|
30
33
|
EXPORT_API_ENDPOINT = config.production.exports_api_endpoint;
|
|
31
34
|
LIQUID_API_ENDPOINT = config.production.liquid_endpoint;
|
|
35
|
+
MEMBERCARE_API_ENDPOINT = config.production.membercare_api_endpoint;
|
|
36
|
+
IRIS_API_ENDPOINT = config.production.iris_api_endpoint;
|
|
37
|
+
ADIONA_API_ENDPOINT = config.production.adiona_api_endpoint;
|
|
32
38
|
}
|
|
33
39
|
let requestCallerName = '';
|
|
34
40
|
const isProd = process.env.NODE_ENV === 'production';
|
|
@@ -172,6 +178,46 @@ function getAPICallObject(method, body, isFileUpload = false, loadCampaignHeader
|
|
|
172
178
|
return requestObj;
|
|
173
179
|
}
|
|
174
180
|
|
|
181
|
+
function getLoyaltyAPICallObject(method, body, notStringify) {
|
|
182
|
+
const token = loadItem('token');
|
|
183
|
+
const orgID = loadItem('orgID');
|
|
184
|
+
const user = loadItem('user');
|
|
185
|
+
const headers = {};
|
|
186
|
+
|
|
187
|
+
if (!notStringify) {
|
|
188
|
+
headers['Content-Type'] = 'application/json';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (user && user.refID) {
|
|
192
|
+
headers['X-CAP-REMOTE-USER'] = user.refID;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (process.env.NODE_ENV !== 'production' && orgID !== undefined) {
|
|
196
|
+
headers['X-CAP-API-AUTH-ORG-ID'] = orgID;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (token !== undefined) {
|
|
200
|
+
headers.Authorization = `Bearer ${token}`;
|
|
201
|
+
}
|
|
202
|
+
const requestObj = {
|
|
203
|
+
method,
|
|
204
|
+
mode: 'cors',
|
|
205
|
+
headers: new Headers(headers),
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
if (process.env.NODE_ENV === 'production') {
|
|
209
|
+
requestObj.credentials = 'same-origin';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (body && !notStringify) {
|
|
213
|
+
requestObj.body = JSON.stringify(body);
|
|
214
|
+
} else {
|
|
215
|
+
requestObj.body = body;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return requestObj;
|
|
219
|
+
}
|
|
220
|
+
|
|
175
221
|
// Authentication
|
|
176
222
|
export const authorize = (user) => {
|
|
177
223
|
const body = {
|
|
@@ -231,7 +277,7 @@ export const createWeChatTemplate = ({template}) => {
|
|
|
231
277
|
return request(url, getAPICallObject('POST', template));
|
|
232
278
|
};
|
|
233
279
|
|
|
234
|
-
export const createMobilePushTemplate = (
|
|
280
|
+
export const createMobilePushTemplate = (template) => {
|
|
235
281
|
const url = `${API_ENDPOINT}/templates/MOBILEPUSH`;
|
|
236
282
|
return request(url, getAPICallObject('POST', template));
|
|
237
283
|
};
|
|
@@ -584,4 +630,51 @@ export const createCentralCommsMetaId = (payload, metaType = TRANSACTION) => {
|
|
|
584
630
|
return request(url, getAPICallObject('POST', payload, false, false, false, true));
|
|
585
631
|
};
|
|
586
632
|
|
|
633
|
+
// Customer Search APIs for Email Test & Preview Feature
|
|
634
|
+
export const searchCustomers = ({ query }) => {
|
|
635
|
+
const url = `${MEMBERCARE_API_ENDPOINT}/customers/search?q=${encodeURIComponent(query)}&limit=10`;
|
|
636
|
+
return request(url, getLoyaltyAPICallObject('GET'));
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
export const extractTagsWithMetaData = (payload) => {
|
|
640
|
+
const url = `${LIQUID_API_ENDPOINT}/extractTagsWithMetaData`;
|
|
641
|
+
return request(url, getAPICallObject('POST', payload, false, true));
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
export const updateEmailPreview = (payload) => {
|
|
645
|
+
const url = `${LIQUID_API_ENDPOINT}/preview`;
|
|
646
|
+
return request(url, getAPICallObject('POST', payload, false, true));
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
export const sendTestMessage = (payload) => {
|
|
650
|
+
const url = `${LIQUID_API_ENDPOINT}/sendTestMessage`;
|
|
651
|
+
return request(url, getAPICallObject('POST', payload, false, true));
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
export const fetchTestCustomers = () => {
|
|
655
|
+
const url = `${IRIS_API_ENDPOINT}/userGroup/default`;
|
|
656
|
+
return request(url, getAPICallObject('GET', null, false, true));
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
export const fetchTestGroups = () => {
|
|
660
|
+
const url = `${IRIS_API_ENDPOINT}/userGroup?isDefault=false`;
|
|
661
|
+
return request(url, getAPICallObject('GET', null, false, true));
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
export const getBulkCustomerDetails = (userIds) => {
|
|
665
|
+
const user = loadItem('user');
|
|
666
|
+
const url = `${ADIONA_API_ENDPOINT}/journeys/getBulkCustomer?source=ALL&userValue=${user?.loginName}`;
|
|
667
|
+
return request(url, getLoyaltyAPICallObject('POST', userIds));
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
export const createTestMessageMeta = (payload) => {
|
|
671
|
+
const url = `${LIQUID_API_ENDPOINT}/TEST/createMessageMeta`;
|
|
672
|
+
return request(url, getAPICallObject('POST', payload, false, true));
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
export const updateTestMessageMeta = (payload) => {
|
|
676
|
+
const url = `${LIQUID_API_ENDPOINT}/TEST/${payload.messageMetaConfigId}/updateMessageMeta`;
|
|
677
|
+
return request(url, getAPICallObject('POST', payload?.data, false, true));
|
|
678
|
+
};
|
|
679
|
+
|
|
587
680
|
export {request, getAPICallObject};
|
|
@@ -14,6 +14,15 @@ import {
|
|
|
14
14
|
fetchSchemaForEntity,
|
|
15
15
|
getDefaultBeeTemplates,
|
|
16
16
|
getEdmTemplates,
|
|
17
|
+
searchCustomers,
|
|
18
|
+
extractTagsWithMetaData,
|
|
19
|
+
updateEmailPreview,
|
|
20
|
+
sendTestMessage,
|
|
21
|
+
fetchTestCustomers,
|
|
22
|
+
fetchTestGroups,
|
|
23
|
+
getBulkCustomerDetails,
|
|
24
|
+
createTestMessageMeta,
|
|
25
|
+
updateTestMessageMeta,
|
|
17
26
|
} from '../api';
|
|
18
27
|
import { mockData } from './mockData';
|
|
19
28
|
import getSchema from '../getSchema';
|
|
@@ -613,3 +622,185 @@ describe('Email Template APIs', () => {
|
|
|
613
622
|
sharedTests(getDefaultBeeTemplates, 'getDefaultBeeTemplates');
|
|
614
623
|
});
|
|
615
624
|
});
|
|
625
|
+
|
|
626
|
+
describe('searchCustomers', () => {
|
|
627
|
+
it('should return correct response', async () => {
|
|
628
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
629
|
+
status: 200,
|
|
630
|
+
json: () => Promise.resolve({
|
|
631
|
+
status: 200,
|
|
632
|
+
response: 'test',
|
|
633
|
+
}),
|
|
634
|
+
}));
|
|
635
|
+
const result = await searchCustomers({ query: 'test' });
|
|
636
|
+
expect(result).toEqual({
|
|
637
|
+
status: 200,
|
|
638
|
+
response: 'test',
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
it('should handle fetch failure', async () => {
|
|
642
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
643
|
+
const result = await searchCustomers({ query: 'test' });
|
|
644
|
+
expect(result).toEqual({
|
|
645
|
+
error: 'Network error',
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
describe('extractTagsWithMetaData', () => {
|
|
650
|
+
it('should return correct response', async () => {
|
|
651
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
652
|
+
status: 200,
|
|
653
|
+
json: () => Promise.resolve({
|
|
654
|
+
status: 200,
|
|
655
|
+
response: 'test',
|
|
656
|
+
}),
|
|
657
|
+
}));
|
|
658
|
+
const result = await extractTagsWithMetaData({ query: 'test' });
|
|
659
|
+
expect(result).toEqual({
|
|
660
|
+
status: 200,
|
|
661
|
+
response: 'test',
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
it('should handle fetch failure', async () => {
|
|
665
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
666
|
+
const result = await extractTagsWithMetaData({ query: 'test' });
|
|
667
|
+
expect(result).toEqual({
|
|
668
|
+
error: 'Network error',
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe('updateEmailPreview', () => {
|
|
674
|
+
it('should return correct response', async () => {
|
|
675
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
676
|
+
status: 200,
|
|
677
|
+
json: () => Promise.resolve({
|
|
678
|
+
status: 200,
|
|
679
|
+
response: 'test',
|
|
680
|
+
}),
|
|
681
|
+
}));
|
|
682
|
+
const result = await updateEmailPreview({ query: 'test' });
|
|
683
|
+
expect(result).toEqual({
|
|
684
|
+
status: 200,
|
|
685
|
+
response: 'test',
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
it('should handle fetch failure', async () => {
|
|
689
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
690
|
+
const result = await updateEmailPreview({ query: 'test' });
|
|
691
|
+
expect(result).toEqual({
|
|
692
|
+
error: 'Network error',
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
describe('sendTestMessage', () => {
|
|
698
|
+
it('should return correct response', async () => {
|
|
699
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
700
|
+
status: 200,
|
|
701
|
+
json: () => Promise.resolve({
|
|
702
|
+
status: 200,
|
|
703
|
+
response: 'test',
|
|
704
|
+
}),
|
|
705
|
+
}));
|
|
706
|
+
const result = await sendTestMessage({ query: 'test' });
|
|
707
|
+
expect(result).toEqual({
|
|
708
|
+
status: 200,
|
|
709
|
+
response: 'test',
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
describe('fetchTestCustomers', () => {
|
|
714
|
+
it('should return correct response', async () => {
|
|
715
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
716
|
+
status: 200,
|
|
717
|
+
json: () => Promise.resolve({
|
|
718
|
+
status: 200,
|
|
719
|
+
response: 'test',
|
|
720
|
+
}),
|
|
721
|
+
}));
|
|
722
|
+
const result = await fetchTestCustomers({ query: 'test' });
|
|
723
|
+
expect(result).toEqual({
|
|
724
|
+
status: 200,
|
|
725
|
+
response: 'test',
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
it('should handle fetch failure', async () => {
|
|
729
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
730
|
+
const result = await fetchTestCustomers({ query: 'test' });
|
|
731
|
+
expect(result).toEqual({
|
|
732
|
+
error: 'Network error',
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
describe('fetchTestGroups', () => {
|
|
737
|
+
it('should return correct response', async () => {
|
|
738
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
739
|
+
status: 200,
|
|
740
|
+
json: () => Promise.resolve({
|
|
741
|
+
status: 200,
|
|
742
|
+
response: 'test',
|
|
743
|
+
}),
|
|
744
|
+
}));
|
|
745
|
+
const result = await fetchTestGroups({ query: 'test' });
|
|
746
|
+
expect(result).toEqual({
|
|
747
|
+
status: 200,
|
|
748
|
+
response: 'test',
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
describe('getBulkCustomerDetails', () => {
|
|
753
|
+
it('should return correct response', async () => {
|
|
754
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
755
|
+
status: 200,
|
|
756
|
+
json: () => Promise.resolve({
|
|
757
|
+
status: 200,
|
|
758
|
+
response: 'test',
|
|
759
|
+
}),
|
|
760
|
+
}));
|
|
761
|
+
const result = await getBulkCustomerDetails({ query: 'test' });
|
|
762
|
+
expect(result).toEqual({
|
|
763
|
+
status: 200,
|
|
764
|
+
response: 'test',
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
it('should handle fetch failure', async () => {
|
|
768
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
769
|
+
const result = await getBulkCustomerDetails({ query: 'test' });
|
|
770
|
+
expect(result).toEqual({
|
|
771
|
+
error: 'Network error',
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
describe('createTestMessageMeta', () => {
|
|
776
|
+
it('should return correct response', async () => {
|
|
777
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
778
|
+
status: 200,
|
|
779
|
+
json: () => Promise.resolve({
|
|
780
|
+
status: 200,
|
|
781
|
+
response: 'test',
|
|
782
|
+
}),
|
|
783
|
+
}));
|
|
784
|
+
const result = await createTestMessageMeta({ query: 'test' });
|
|
785
|
+
expect(result).toEqual({
|
|
786
|
+
status: 200,
|
|
787
|
+
response: 'test',
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
describe('updateTestMessageMeta', () => {
|
|
792
|
+
it('should return correct response', async () => {
|
|
793
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
794
|
+
status: 200,
|
|
795
|
+
json: () => Promise.resolve({
|
|
796
|
+
status: 200,
|
|
797
|
+
response: 'test',
|
|
798
|
+
}),
|
|
799
|
+
}));
|
|
800
|
+
const result = await updateTestMessageMeta({ query: 'test' });
|
|
801
|
+
expect(result).toEqual({
|
|
802
|
+
status: 200,
|
|
803
|
+
response: 'test',
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
});
|
|
@@ -32,7 +32,7 @@ jest.mock('@capillarytech/cap-ui-utils', () => ({
|
|
|
32
32
|
},
|
|
33
33
|
}));
|
|
34
34
|
|
|
35
|
-
jest.setTimeout(
|
|
35
|
+
jest.setTimeout(60000);
|
|
36
36
|
|
|
37
37
|
const initializeCreatives = () => {
|
|
38
38
|
const store = configureStore(mockInitialState, initialReducer, history);
|
|
@@ -51,6 +51,12 @@ beforeEach(() => {
|
|
|
51
51
|
server.listen();
|
|
52
52
|
localStorage.clear();
|
|
53
53
|
localStorage.setItem('token', true);
|
|
54
|
+
|
|
55
|
+
// Mock cap auth
|
|
56
|
+
window.capAuth = {
|
|
57
|
+
hasFeatureAccess: jest.fn().mockReturnValue(false),
|
|
58
|
+
isInitialized: jest.fn().mockReturnValue(true),
|
|
59
|
+
};
|
|
54
60
|
});
|
|
55
61
|
|
|
56
62
|
// clean up once the tests are done
|
|
@@ -62,7 +68,6 @@ afterAll(() => {
|
|
|
62
68
|
});
|
|
63
69
|
|
|
64
70
|
describe("Creatives testing template creation", () => {
|
|
65
|
-
jest.useFakeTimers();
|
|
66
71
|
it("Should navigate from creatives home page and create template in RCS channel", async () => {
|
|
67
72
|
initializeCreatives();
|
|
68
73
|
const creativesScreen = await helper.getCreativesScreen();
|
|
@@ -93,7 +98,7 @@ describe("Creatives testing template creation", () => {
|
|
|
93
98
|
name: globalMessages.email.defaultMessage,
|
|
94
99
|
});
|
|
95
100
|
await userEvent.click(whatsapp);
|
|
96
|
-
waitFor(() => {
|
|
101
|
+
await waitFor(() => {
|
|
97
102
|
expect(
|
|
98
103
|
creativesScreen.getByText(
|
|
99
104
|
/Whatsapp accounts are not setup for your brand/i
|
|
@@ -20418,3 +20418,8 @@ export const tag = {
|
|
|
20418
20418
|
}
|
|
20419
20419
|
};
|
|
20420
20420
|
|
|
20421
|
+
export const cdnTransformationConfig = {
|
|
20422
|
+
enabled: false,
|
|
20423
|
+
transformations: [],
|
|
20424
|
+
};
|
|
20425
|
+
|
|
@@ -4,73 +4,52 @@ import 'whatwg-fetch';
|
|
|
4
4
|
import * as apiResponse from './api-response';
|
|
5
5
|
|
|
6
6
|
import config from '../../../config/app';
|
|
7
|
+
import { MOBILE_PUSH } from '../../../v2Containers/CreativesContainer/constants';
|
|
7
8
|
const API_ENDPOINT = config.development.api_endpoint;
|
|
8
9
|
const AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
9
10
|
const CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
10
11
|
|
|
11
12
|
export const server = setupServer(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}),
|
|
13
|
+
rest.options('*', (req, res, ctx) => res(
|
|
14
|
+
ctx.status(200),
|
|
15
|
+
ctx.set('access-control-allow-origin', '*'),
|
|
16
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-org'),
|
|
17
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-remote-user'),
|
|
18
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-api-data-context-org-id'),
|
|
19
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-api-auth-org-id'),
|
|
20
|
+
)),
|
|
21
|
+
rest.get(`${AUTH_ENDPOINT}/auth/org/:orgId/users`, (req, res, ctx) => {
|
|
22
|
+
const { orgId } = req.params;
|
|
23
|
+
switch (orgId) {
|
|
24
|
+
case '50146':
|
|
25
|
+
return res(ctx.status(200), ctx.json(apiResponse.authOrgUsersReonData));
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
res(ctx.status(200), ctx.json(apiResponse.authUserReonData)),
|
|
32
|
-
),
|
|
29
|
+
rest.get(`${AUTH_ENDPOINT}/user`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.authUserReonData))),
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
res(ctx.status(200), ctx.json(apiResponse.gallery)),
|
|
60
|
-
),
|
|
61
|
-
rest.get(`${API_ENDPOINT}/templates/v1/Line`, (req, res, ctx) =>
|
|
62
|
-
res(ctx.status(200), ctx.json(apiResponse.lineTemplates)),
|
|
63
|
-
),
|
|
64
|
-
rest.get(`${API_ENDPOINT}/templates/v1/Viber`, (req, res, ctx) =>
|
|
65
|
-
res(ctx.status(200), ctx.json(apiResponse.viberTemplates)),
|
|
66
|
-
),
|
|
67
|
-
rest.get(`${API_ENDPOINT}/templates/v1/Email`, (req, res, ctx) =>
|
|
68
|
-
res(ctx.status(200), ctx.json(apiResponse.emailTemplates)),
|
|
69
|
-
),
|
|
70
|
-
rest.get(`${API_ENDPOINT}/meta/TAG`, (req, res, ctx) =>
|
|
71
|
-
res(ctx.status(200), ctx.json(apiResponse.tag)),
|
|
72
|
-
),
|
|
73
|
-
rest.get(`${CAMPAIGNS_API_ENDPOINT}/meta/domainProperties`, (req, res, ctx) =>
|
|
74
|
-
res(ctx.status(200), ctx.json(apiResponse.domainProperties)),
|
|
75
|
-
),
|
|
76
|
-
);
|
|
31
|
+
rest.get(`${AUTH_ENDPOINT}/org/users`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.authOrgUsersReonData))),
|
|
32
|
+
rest.get(`${API_ENDPOINT}/templates/Sms`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.smsTemplates))),
|
|
33
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Sms`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.smsTemplates))),
|
|
34
|
+
rest.get(`${API_ENDPOINT}/templates/Rcs`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.rcsTemplates))),
|
|
35
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Rcs`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.rcsTemplates))),
|
|
36
|
+
rest.get(`${API_ENDPOINT}/meta/wecrm`, (req, res, ctx) => {
|
|
37
|
+
const sourceName = req.url.searchParams.get('source_name');
|
|
38
|
+
switch (sourceName) {
|
|
39
|
+
case 'WHATSAPP':
|
|
40
|
+
return res(ctx.status(200), ctx.json(apiResponse.whatsappAccount));
|
|
41
|
+
case 'VIBER':
|
|
42
|
+
return res(ctx.status(200), ctx.json(apiResponse.viberAccount));
|
|
43
|
+
case MOBILE_PUSH:
|
|
44
|
+
return res(ctx.status(200), ctx.json(apiResponse.mpushAccount));
|
|
45
|
+
default:
|
|
46
|
+
return res(ctx.status(200), ctx.json(apiResponse.whatsappAccount));
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
rest.get(`${API_ENDPOINT}/assets/image`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.gallery))),
|
|
50
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Line`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.lineTemplates))),
|
|
51
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Viber`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.viberTemplates))),
|
|
52
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Email`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.emailTemplates))),
|
|
53
|
+
rest.get(`${API_ENDPOINT}/meta/TAG`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.tag))),
|
|
54
|
+
rest.get(`${CAMPAIGNS_API_ENDPOINT}/meta/domainProperties`, (req, res, ctx) => res(ctx.status(200), ctx.json(apiResponse.domainProperties))),
|
|
55
|
+
);
|
package/utils/common.js
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
BADGES_ISSUE,
|
|
23
23
|
ENABLE_WECHAT,
|
|
24
24
|
LIQUID_SUPPORT,
|
|
25
|
+
ENABLE_NEW_MPUSH,
|
|
25
26
|
} from '../containers/App/constants';
|
|
26
27
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
27
28
|
|
|
@@ -124,6 +125,12 @@ export const isEmailUnsubscribeTagMandatory = Auth.hasFeatureAccess.bind(
|
|
|
124
125
|
null,
|
|
125
126
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
126
127
|
);
|
|
128
|
+
|
|
129
|
+
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
130
|
+
null,
|
|
131
|
+
ENABLE_NEW_MPUSH,
|
|
132
|
+
);
|
|
133
|
+
|
|
127
134
|
//filtering tags based on scope
|
|
128
135
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
129
136
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
package/utils/commonUtils.js
CHANGED
|
@@ -35,7 +35,7 @@ export const addBaseToTemplate = (template) => {
|
|
|
35
35
|
...template.versions,
|
|
36
36
|
base: {
|
|
37
37
|
...history[0],
|
|
38
|
-
...( get(template, 'versions.base.subject') ? {subject
|
|
38
|
+
...( get(template, 'versions.base.subject') ? {subject: get(template, 'versions.base.subject')} : { subject: history?.[0]?.subject }),
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -151,7 +151,7 @@ export const validateLiquidTemplateContent = async (
|
|
|
151
151
|
const emptyBodyError = formatMessage(messages?.emailBodyEmptyError);
|
|
152
152
|
const somethingWrongMsg = formatMessage(messages?.somethingWentWrong);
|
|
153
153
|
// Empty content check
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
if (!content || content.trim() === "") {
|
|
156
156
|
onError({
|
|
157
157
|
standardErrors: [emptyBodyError],
|
|
@@ -170,7 +170,6 @@ export const validateLiquidTemplateContent = async (
|
|
|
170
170
|
|
|
171
171
|
const {askAiraResponse: result, isError} = await getLiquidTagsAsync(content);
|
|
172
172
|
const validString = /\S/.test(content);
|
|
173
|
-
|
|
174
173
|
// Handle API errors or empty content
|
|
175
174
|
if (result?.errors?.length > 0 || !validString || isError) {
|
|
176
175
|
let standardErrors = [];
|
|
@@ -302,7 +301,6 @@ export const _validatePlatformSpecificContent = async (
|
|
|
302
301
|
if (singleTab === IOS) {
|
|
303
302
|
isAndroidValid = true;
|
|
304
303
|
}
|
|
305
|
-
|
|
306
304
|
return isAndroidValid && isIosValid; // Overall success
|
|
307
305
|
};
|
|
308
306
|
|
|
@@ -340,7 +338,6 @@ export const validateMobilePushContent = async (formData, options) => {
|
|
|
340
338
|
if (iosContent) return [iosContent, IOS?.toLowerCase()];
|
|
341
339
|
return ["", ""];
|
|
342
340
|
};
|
|
343
|
-
|
|
344
341
|
if (overallSuccess) {
|
|
345
342
|
const [contentToSubmit, tabTypeToSubmit] = getContentToSubmit();
|
|
346
343
|
// Call the FINAL onSuccess only ONCE here
|
|
@@ -373,7 +370,6 @@ export const validateInAppContent = async (formData, options) => {
|
|
|
373
370
|
onSuccess, // FINAL success callback
|
|
374
371
|
...restOptions // Options for validateLiquidTemplateContent
|
|
375
372
|
} = options;
|
|
376
|
-
|
|
377
373
|
// Clear previous errors with new structure
|
|
378
374
|
onError({
|
|
379
375
|
standardErrors: {
|