@capillarytech/creatives-library 8.0.345-alpha.13 → 8.0.345-alpha.15
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 +29 -0
- package/package.json +1 -1
- package/services/api.js +0 -20
- package/services/tests/api.test.js +13 -59
- package/utils/commonUtils.js +19 -1
- package/utils/rcsPayloadUtils.js +92 -0
- package/utils/templateVarUtils.js +201 -0
- package/utils/tests/templateVarUtils.test.js +204 -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/CapCustomSkeleton/index.js +1 -1
- package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
- package/v2Components/CapTagList/index.js +10 -0
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +8 -2
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +207 -21
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +16 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +85 -10
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +30 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +79 -11
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +10 -5
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +160 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +18 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +341 -76
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +11 -0
- package/v2Components/CommonTestAndPreview/constants.js +38 -2
- package/v2Components/CommonTestAndPreview/index.js +676 -186
- package/v2Components/CommonTestAndPreview/messages.js +49 -3
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/v2Components/CommonTestAndPreview/sagas.js +15 -6
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +308 -284
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +231 -65
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +118 -5
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +341 -0
- package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +34 -13
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
- package/v2Components/CommonTestAndPreview/tests/index.test.js +132 -4
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
- package/v2Components/FormBuilder/index.js +8 -10
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
- package/v2Components/SmsFallback/constants.js +73 -0
- package/v2Components/SmsFallback/index.js +955 -0
- package/v2Components/SmsFallback/index.scss +265 -0
- package/v2Components/SmsFallback/messages.js +78 -0
- package/v2Components/SmsFallback/smsFallbackUtils.js +118 -0
- package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +277 -0
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/v2Components/SmsFallback/useLocalTemplateList.js +92 -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/TestAndPreviewSlidebox/index.js +13 -1
- package/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +36 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +11 -4
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/v2Containers/CreativesContainer/constants.js +9 -0
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
- package/v2Containers/CreativesContainer/index.js +300 -108
- package/v2Containers/CreativesContainer/index.scss +51 -1
- package/v2Containers/CreativesContainer/messages.js +0 -4
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +78 -34
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +79 -16
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +8 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +357 -98
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +20 -18
- package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/v2Containers/Rcs/constants.js +119 -8
- package/v2Containers/Rcs/index.js +2379 -807
- package/v2Containers/Rcs/index.js.rej +1336 -0
- package/v2Containers/Rcs/index.scss +276 -6
- package/v2Containers/Rcs/index.scss.rej +74 -0
- package/v2Containers/Rcs/messages.js +38 -3
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +225 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +98018 -70073
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +128 -0
- package/v2Containers/Rcs/tests/index.test.js +152 -121
- package/v2Containers/Rcs/tests/mockData.js +38 -0
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +318 -0
- package/v2Containers/Rcs/tests/utils.test.js +646 -30
- package/v2Containers/Rcs/utils.js +478 -11
- package/v2Containers/Sms/Create/index.js +100 -40
- package/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/v2Containers/SmsTrai/Create/index.js +9 -4
- package/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/v2Containers/SmsTrai/Edit/index.js +636 -130
- package/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/v2Containers/SmsTrai/Edit/messages.js +14 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4328 -2375
- package/v2Containers/SmsWrapper/index.js +37 -8
- package/v2Containers/TagList/index.js +6 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
- package/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/v2Containers/Templates/_templates.scss +181 -126
- package/v2Containers/Templates/actions.js +11 -36
- package/v2Containers/Templates/constants.js +2 -23
- package/v2Containers/Templates/index.js +142 -333
- package/v2Containers/Templates/messages.js +0 -68
- package/v2Containers/Templates/reducer.js +0 -68
- package/v2Containers/Templates/sagas.js +55 -98
- package/v2Containers/Templates/selectors.js +0 -12
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
- package/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1042 -1256
- package/v2Containers/Templates/tests/index.test.js +0 -6
- package/v2Containers/Templates/tests/reducer.test.js +0 -178
- package/v2Containers/Templates/tests/sagas.test.js +200 -436
- package/v2Containers/Templates/tests/selector.test.js +0 -32
- package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/v2Containers/TemplatesV2/index.js +86 -23
- package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/v2Containers/Whatsapp/index.js +3 -20
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +578 -34
- package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { fromJS } from "immutable";
|
|
2
2
|
import { makeSelectTemplatesResponse } from "../selectors";
|
|
3
|
-
import { selectArchiveFilter, selectSelectedTemplateIds } from "../selectors";
|
|
4
3
|
|
|
5
4
|
describe("Template selectors", () => {
|
|
6
5
|
const mockState = fromJS({
|
|
@@ -16,34 +15,3 @@ describe("Template selectors", () => {
|
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
});
|
|
19
|
-
|
|
20
|
-
describe("selectArchiveFilter selector", () => {
|
|
21
|
-
it("should return archiveFilter from state", () => {
|
|
22
|
-
const state = fromJS({
|
|
23
|
-
templates: { archiveFilter: 'archived' },
|
|
24
|
-
});
|
|
25
|
-
const result = selectArchiveFilter().resultFunc(state.get('templates').toJS());
|
|
26
|
-
expect(result).toBe('archived');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should default to 'active' when archiveFilter is not set", () => {
|
|
30
|
-
const result = selectArchiveFilter().resultFunc({});
|
|
31
|
-
expect(result).toBe('active');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("selectSelectedTemplateIds selector", () => {
|
|
36
|
-
it("should return selectedTemplateIds from state", () => {
|
|
37
|
-
const ids = ['id1', 'id2'];
|
|
38
|
-
const state = fromJS({
|
|
39
|
-
templates: { selectedTemplateIds: ids },
|
|
40
|
-
});
|
|
41
|
-
const result = selectSelectedTemplateIds().resultFunc(state.get('templates').toJS());
|
|
42
|
-
expect(result).toEqual(ids);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should default to [] when selectedTemplateIds is not set", () => {
|
|
46
|
-
const result = selectSelectedTemplateIds().resultFunc({});
|
|
47
|
-
expect(result).toEqual([]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as Api from '../../../services/api';
|
|
2
|
+
import { isTraiDLTEnable } from '../../../utils/common';
|
|
3
|
+
|
|
4
|
+
jest.mock('../../../services/api', () => ({
|
|
5
|
+
getAllTemplates: jest.fn(),
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../utils/common', () => ({
|
|
9
|
+
isTraiDLTEnable: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
buildSmsTemplatesListQueryParams,
|
|
14
|
+
fetchSmsTemplatesFromQuery,
|
|
15
|
+
fetchSmsTemplatesListPage,
|
|
16
|
+
SMS_TEMPLATES_LIST_SORT_MOST_RECENT,
|
|
17
|
+
} from '../utils/smsTemplatesListApi';
|
|
18
|
+
|
|
19
|
+
describe('smsTemplatesListApi', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('buildSmsTemplatesListQueryParams', () => {
|
|
25
|
+
it('includes traiEnable when TRAI DLT is enabled', () => {
|
|
26
|
+
isTraiDLTEnable.mockReturnValue(true);
|
|
27
|
+
const q = buildSmsTemplatesListQueryParams({
|
|
28
|
+
page: 1,
|
|
29
|
+
perPage: 25,
|
|
30
|
+
name: 'x',
|
|
31
|
+
sortBy: SMS_TEMPLATES_LIST_SORT_MOST_RECENT,
|
|
32
|
+
isFullMode: true,
|
|
33
|
+
smsRegister: {},
|
|
34
|
+
});
|
|
35
|
+
expect(q).toEqual({
|
|
36
|
+
page: 1,
|
|
37
|
+
perPage: 25,
|
|
38
|
+
sortBy: SMS_TEMPLATES_LIST_SORT_MOST_RECENT,
|
|
39
|
+
name: 'x',
|
|
40
|
+
traiEnable: true,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('omits traiEnable when TRAI DLT is disabled', () => {
|
|
45
|
+
isTraiDLTEnable.mockReturnValue(false);
|
|
46
|
+
const q = buildSmsTemplatesListQueryParams({
|
|
47
|
+
page: 2,
|
|
48
|
+
perPage: 10,
|
|
49
|
+
isFullMode: false,
|
|
50
|
+
smsRegister: null,
|
|
51
|
+
});
|
|
52
|
+
expect(q.traiEnable).toBeUndefined();
|
|
53
|
+
expect(q.name).toBe('');
|
|
54
|
+
expect(q.sortBy).toBe(SMS_TEMPLATES_LIST_SORT_MOST_RECENT);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('fetchSmsTemplatesFromQuery', () => {
|
|
59
|
+
it('returns channelTemplates, weCRMTemplate, and raw; maps intl copy on names', async () => {
|
|
60
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
61
|
+
response: {
|
|
62
|
+
templates: [{ name: 'Copy of A', _id: '1' }],
|
|
63
|
+
unMapped: { u: 1 },
|
|
64
|
+
totalCount: 5,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const out = await fetchSmsTemplatesFromQuery(
|
|
69
|
+
{ page: 1, perPage: 25 },
|
|
70
|
+
'Kopie',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(Api.getAllTemplates).toHaveBeenCalledWith({
|
|
74
|
+
channel: 'Sms',
|
|
75
|
+
queryParams: { page: 1, perPage: 25 },
|
|
76
|
+
});
|
|
77
|
+
expect(out.weCRMTemplate).toEqual({ u: 1 });
|
|
78
|
+
expect(out.raw.response.templates[0].name).toBe('Copy of A');
|
|
79
|
+
expect(out.channelTemplates.templates[0].name).toBe('Kopie A');
|
|
80
|
+
expect(out.channelTemplates.totalCount).toBe(5);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('skips name mapping when intlCopyOf is empty', async () => {
|
|
84
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
85
|
+
response: {
|
|
86
|
+
templates: [{ name: 'Copy of A' }],
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
const out = await fetchSmsTemplatesFromQuery({ page: 1 }, '');
|
|
90
|
+
expect(out.channelTemplates.templates[0].name).toBe('Copy of A');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('handles missing response.templates', async () => {
|
|
94
|
+
Api.getAllTemplates.mockResolvedValue({ response: {} });
|
|
95
|
+
const out = await fetchSmsTemplatesFromQuery({}, '');
|
|
96
|
+
expect(out.channelTemplates.templates).toEqual([]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('uses empty response when raw.response is missing', async () => {
|
|
100
|
+
Api.getAllTemplates.mockResolvedValue({});
|
|
101
|
+
const out = await fetchSmsTemplatesFromQuery({}, '');
|
|
102
|
+
expect(out.channelTemplates.templates).toEqual([]);
|
|
103
|
+
expect(out.weCRMTemplate).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('does not map names when intlCopyOf is set but templates list is empty', async () => {
|
|
107
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
108
|
+
response: { templates: [] },
|
|
109
|
+
});
|
|
110
|
+
const out = await fetchSmsTemplatesFromQuery({ page: 1 }, 'X');
|
|
111
|
+
expect(out.channelTemplates.templates).toEqual([]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('uses empty string when template name is missing during intl mapping', async () => {
|
|
115
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
116
|
+
response: {
|
|
117
|
+
templates: [{ _id: 'n', name: undefined }],
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
const out = await fetchSmsTemplatesFromQuery({ page: 1 }, 'Lbl');
|
|
121
|
+
expect(out.channelTemplates.templates[0].name).toBe('');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('fetchSmsTemplatesListPage', () => {
|
|
126
|
+
it('falls back to total when totalCount is absent', async () => {
|
|
127
|
+
isTraiDLTEnable.mockReturnValue(false);
|
|
128
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
129
|
+
response: {
|
|
130
|
+
templates: [{ _id: 'a' }],
|
|
131
|
+
total: 7,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const page = await fetchSmsTemplatesListPage({
|
|
136
|
+
page: 1,
|
|
137
|
+
perPage: 25,
|
|
138
|
+
name: '',
|
|
139
|
+
sortBy: SMS_TEMPLATES_LIST_SORT_MOST_RECENT,
|
|
140
|
+
isFullMode: true,
|
|
141
|
+
smsRegister: {},
|
|
142
|
+
intlCopyOf: '',
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(page.templates).toEqual([{ _id: 'a' }]);
|
|
146
|
+
expect(page.totalCount).toBe(7);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('uses totalCount when set', async () => {
|
|
150
|
+
isTraiDLTEnable.mockReturnValue(false);
|
|
151
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
152
|
+
response: {
|
|
153
|
+
templates: [],
|
|
154
|
+
totalCount: 12,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
const page = await fetchSmsTemplatesListPage({
|
|
158
|
+
page: 1,
|
|
159
|
+
perPage: 25,
|
|
160
|
+
isFullMode: false,
|
|
161
|
+
smsRegister: {},
|
|
162
|
+
});
|
|
163
|
+
expect(page.totalCount).toBe(12);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('normalizes total to 0 when missing counts', async () => {
|
|
167
|
+
isTraiDLTEnable.mockReturnValue(false);
|
|
168
|
+
Api.getAllTemplates.mockResolvedValue({
|
|
169
|
+
response: { templates: [] },
|
|
170
|
+
});
|
|
171
|
+
const page = await fetchSmsTemplatesListPage({
|
|
172
|
+
page: 1,
|
|
173
|
+
perPage: 25,
|
|
174
|
+
isFullMode: false,
|
|
175
|
+
smsRegister: {},
|
|
176
|
+
});
|
|
177
|
+
expect(page.totalCount).toBe(0);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import * as Api from '../../../services/api';
|
|
3
|
+
import { COPY_OF } from '../../../constants/unified';
|
|
4
|
+
import { isTraiDLTEnable } from '../../../utils/common';
|
|
5
|
+
|
|
6
|
+
/** Matches Templates `getAllTemplates` default for SMS. */
|
|
7
|
+
export const SMS_TEMPLATES_LIST_SORT_MOST_RECENT = 'Most Recent';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Same query shape as Redux `GET_ALL_TEMPLATES` for channel Sms (DLT vs non-DLT via traiEnable).
|
|
11
|
+
*/
|
|
12
|
+
export function buildSmsTemplatesListQueryParams({
|
|
13
|
+
page,
|
|
14
|
+
perPage,
|
|
15
|
+
name = '',
|
|
16
|
+
sortBy = SMS_TEMPLATES_LIST_SORT_MOST_RECENT,
|
|
17
|
+
isFullMode,
|
|
18
|
+
smsRegister,
|
|
19
|
+
}) {
|
|
20
|
+
const traiDlt = isTraiDLTEnable(isFullMode, smsRegister);
|
|
21
|
+
return {
|
|
22
|
+
page,
|
|
23
|
+
perPage,
|
|
24
|
+
sortBy,
|
|
25
|
+
name: name || '',
|
|
26
|
+
...(traiDlt ? { traiEnable: true } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* SMS list for Redux saga: uses queryParams already built by Templates (incl. traiEnable).
|
|
32
|
+
* Applies the same "Copy of" → intl label as the former inline saga logic.
|
|
33
|
+
*/
|
|
34
|
+
export async function fetchSmsTemplatesFromQuery(queryParams, intlCopyOf = '') {
|
|
35
|
+
const raw = await Api.getAllTemplates({ channel: 'Sms', queryParams });
|
|
36
|
+
const response = raw.response || {};
|
|
37
|
+
let templates = get(response, 'templates', []) || [];
|
|
38
|
+
if (intlCopyOf && templates.length) {
|
|
39
|
+
templates = templates.map((template) => ({
|
|
40
|
+
...template,
|
|
41
|
+
name: (template.name || '').replace(new RegExp(COPY_OF, 'g'), intlCopyOf),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
const channelTemplates = { ...response, templates };
|
|
45
|
+
return {
|
|
46
|
+
channelTemplates,
|
|
47
|
+
weCRMTemplate: response.unMapped,
|
|
48
|
+
raw,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* SMS list for the RCS SMS fallback picker only.
|
|
54
|
+
* Called from `useLocalTemplateList` in SmsFallback — keeps data in component state and pairs with
|
|
55
|
+
* `localTemplatesConfig` / `useLocalTemplates` in TemplatesV2. Does **not** use GET_ALL_TEMPLATES saga.
|
|
56
|
+
* Same HTTP call shape as `fetchSmsTemplatesFromQuery` (used by the main SMS GET_ALL_TEMPLATES saga).
|
|
57
|
+
*/
|
|
58
|
+
export async function fetchSmsTemplatesListPage({
|
|
59
|
+
page,
|
|
60
|
+
perPage,
|
|
61
|
+
name,
|
|
62
|
+
sortBy,
|
|
63
|
+
isFullMode,
|
|
64
|
+
smsRegister,
|
|
65
|
+
intlCopyOf = '',
|
|
66
|
+
}) {
|
|
67
|
+
const queryParams = buildSmsTemplatesListQueryParams({
|
|
68
|
+
page,
|
|
69
|
+
perPage,
|
|
70
|
+
name,
|
|
71
|
+
sortBy,
|
|
72
|
+
isFullMode,
|
|
73
|
+
smsRegister,
|
|
74
|
+
});
|
|
75
|
+
const { channelTemplates } = await fetchSmsTemplatesFromQuery(queryParams, intlCopyOf);
|
|
76
|
+
const templates = channelTemplates.templates || [];
|
|
77
|
+
const totalCount = get(channelTemplates, 'totalCount', get(channelTemplates, 'total', 0)) || 0;
|
|
78
|
+
return { templates, totalCount };
|
|
79
|
+
}
|
|
@@ -10,7 +10,7 @@ export default css`
|
|
|
10
10
|
|
|
11
11
|
.component-wrapper {
|
|
12
12
|
${(props) => props.isFullMode ? `
|
|
13
|
-
max-width:
|
|
13
|
+
max-width: 71.25rem;
|
|
14
14
|
margin: 0 auto;
|
|
15
15
|
width: 100%;
|
|
16
16
|
padding: ${CAP_SPACE_24} 0;
|
|
@@ -23,6 +23,77 @@ export default css`
|
|
|
23
23
|
height: calc(100vh - 11.25rem);
|
|
24
24
|
} `}
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/* SMS fallback / local list: single pane skips .cap-tab-v2, so flex-fill the grid instead of viewport-fixed pagination height */
|
|
28
|
+
.creatives-templates-container--local-sms.library-mode {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-height: 0;
|
|
33
|
+
height: 100%;
|
|
34
|
+
|
|
35
|
+
.component-wrapper {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
flex: 1;
|
|
39
|
+
min-height: 0;
|
|
40
|
+
height: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.templates-v2-local-sms-pane {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
flex: 1;
|
|
47
|
+
min-height: 0;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
height: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.templates-v2-local-sms-pane .creatives-templates-list.library-mode {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
flex: 1;
|
|
56
|
+
min-height: 0;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
height: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.templates-v2-local-sms-pane .creatives-templates-list.library-mode > .cap-row:first-of-type {
|
|
62
|
+
flex: 1;
|
|
63
|
+
min-height: 0;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.templates-v2-local-sms-pane .creatives-templates-list.library-mode > .cap-row:first-of-type > div {
|
|
70
|
+
flex: 1;
|
|
71
|
+
min-height: 0;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.templates-v2-local-sms-pane .creatives-templates-list.library-mode > .cap-row:first-of-type > div > div:first-child {
|
|
78
|
+
flex: 1;
|
|
79
|
+
min-height: 0;
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.templates-v2-local-sms-pane .v2-pagination-container,
|
|
86
|
+
.templates-v2-local-sms-pane .v2-pagination-container-half {
|
|
87
|
+
/* Match _templates local-SMS: bounded height so overflow-y scroll works (flex+100% alone often doesn’t) */
|
|
88
|
+
flex: 0 1 auto;
|
|
89
|
+
min-height: 0;
|
|
90
|
+
height: calc(100vh - 12rem);
|
|
91
|
+
max-height: calc(100vh - 12rem);
|
|
92
|
+
overflow-y: auto;
|
|
93
|
+
overflow-x: hidden;
|
|
94
|
+
-webkit-overflow-scrolling: touch;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
26
97
|
`;
|
|
27
98
|
|
|
28
99
|
export const CapTabStyle = css`
|
|
@@ -10,8 +10,8 @@ import { connect } from 'react-redux';
|
|
|
10
10
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
11
11
|
import { createStructuredSelector } from 'reselect';
|
|
12
12
|
import { bindActionCreators, compose } from 'redux';
|
|
13
|
-
import { CapTab, CapCustomCard, CapButton, CapHeader,
|
|
14
|
-
import { find, get } from 'lodash';
|
|
13
|
+
import { CapTab, CapCustomCard, CapButton, CapHeader, CapIcon, CapSpin, CapTooltip } from '@capillarytech/cap-ui-library';
|
|
14
|
+
import { find, get, pick } from 'lodash';
|
|
15
15
|
import Helmet from 'react-helmet';
|
|
16
16
|
|
|
17
17
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
@@ -36,13 +36,14 @@ import { makeSelectAuthenticated, selectCurrentOrgDetails } from "../../v2Contai
|
|
|
36
36
|
import {
|
|
37
37
|
CALL_TASK,
|
|
38
38
|
COMMON_CHANNELS,
|
|
39
|
+
LOCAL_TEMPLATE_CONFIG_KEYS_FOR_PICK,
|
|
39
40
|
LOYALTY_SUPPORTED_ACTION,
|
|
40
41
|
MOBILE_PUSH,
|
|
41
42
|
NORMALIZED_CHANNEL_ALIASES,
|
|
42
43
|
SMS,
|
|
43
44
|
} from "../CreativesContainer/constants";
|
|
44
45
|
|
|
45
|
-
const {CapCustomCardList} = CapCustomCard;
|
|
46
|
+
const { CapCustomCardList } = CapCustomCard;
|
|
46
47
|
|
|
47
48
|
const StyledCapTab = withStyles(CapTab, CapTabStyle);
|
|
48
49
|
export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
@@ -119,9 +120,9 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
119
120
|
return !normalizedChannelsToHideSet.has(paneKey);
|
|
120
121
|
});
|
|
121
122
|
|
|
122
|
-
if (isFullMode) {
|
|
123
|
-
filteredPanes.push({ content: <div></div>, tab: intl.formatMessage(messages.gallery), key:
|
|
124
|
-
} else {
|
|
123
|
+
if (isFullMode && !normalizedChannelsToHideSet.has(normalizeChannel(ASSETS))) {
|
|
124
|
+
filteredPanes.push({ content: <div></div>, tab: intl.formatMessage(messages.gallery), key: ASSETS });
|
|
125
|
+
} else if (!isFullMode) {
|
|
125
126
|
// Add special-mode panes only when not hidden (use normalized checks)
|
|
126
127
|
if (!normalizedChannelsToHideSet.has(CALL_TASK.toLowerCase())) {
|
|
127
128
|
filteredPanes.push({ content: <div></div>, tab: intl.formatMessage(messages.callTask), key: CALL_TASK.toLowerCase() });
|
|
@@ -222,7 +223,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
222
223
|
this.setState({selectedChannel: nextProps.channel, panes });
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
|
-
|
|
226
|
+
|
|
227
|
+
getTemplateDataForGrid = ({ templates, handlers, filterContent, channel, isLoading, loadingTip }) => {
|
|
226
228
|
const currentChannel = channel.toUpperCase();
|
|
227
229
|
const cardDataList = templates.map((template) => {
|
|
228
230
|
const templateData =
|
|
@@ -248,7 +250,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
248
250
|
</CapSpin>
|
|
249
251
|
|
|
250
252
|
</div>);
|
|
251
|
-
}
|
|
253
|
+
};
|
|
254
|
+
|
|
252
255
|
getGalleryComponent = (location) => <Gallery location={location} isFullMode={this.props.isFullMode}/>
|
|
253
256
|
getCallTaskComponent = () => (
|
|
254
257
|
<CallTask
|
|
@@ -312,6 +315,29 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
312
315
|
if (messageStrategy !== "X_ENGAGE" && channel === 'facebook' && !isFullMode) {
|
|
313
316
|
return this.getFacebookComponent();
|
|
314
317
|
}
|
|
318
|
+
const localConfig = this.props.localTemplatesConfig || pick(this.props, LOCAL_TEMPLATE_CONFIG_KEYS_FOR_PICK);
|
|
319
|
+
const useLocalTemplates = localConfig.useLocalTemplates;
|
|
320
|
+
if (useLocalTemplates && channel === (this.props.channel || 'sms')) {
|
|
321
|
+
// Reuse full Templates component (same UI as Redux flow) with local data only
|
|
322
|
+
const location = { pathname: `/${channel}`, search: '', query: !this.props.isFullMode ? { type: 'embedded', module: 'library' } : {} };
|
|
323
|
+
return (
|
|
324
|
+
<Templates
|
|
325
|
+
key={`${channel}-local`}
|
|
326
|
+
location={location}
|
|
327
|
+
route={{ name: channel }}
|
|
328
|
+
router={this.props.router}
|
|
329
|
+
isFullMode={this.props.isFullMode}
|
|
330
|
+
createNew={this.props.createNew}
|
|
331
|
+
onSelectTemplate={this.props.onSelectTemplate}
|
|
332
|
+
handlePeviewTemplate={this.props.handlePeviewTemplate}
|
|
333
|
+
messageStrategy={this.props.messageStrategy}
|
|
334
|
+
smsRegister={this.props.smsRegister}
|
|
335
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
336
|
+
localTemplatesConfig={localConfig}
|
|
337
|
+
/>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
315
341
|
const location = {pathname: `/${channel}`, search: '', query};
|
|
316
342
|
switch (channel) {
|
|
317
343
|
case 'call_task':
|
|
@@ -361,29 +387,55 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
361
387
|
}
|
|
362
388
|
render() {
|
|
363
389
|
const { isFullMode, className, cap = {}, Global = {}} = this.props;
|
|
390
|
+
const useLocalTemplates = get(this.props, 'localTemplatesConfig.useLocalTemplates', false);
|
|
364
391
|
const { accessiblePermissions = []} = cap.user || Global.user || {};
|
|
365
392
|
let isCreativeAccessible = true;
|
|
366
393
|
if (!accessiblePermissions.includes(CREATIVES_UI_VIEW)) {
|
|
367
394
|
isCreativeAccessible = false;
|
|
368
395
|
}
|
|
396
|
+
// Recompute active pane content every render so local-list mode updates
|
|
397
|
+
// (templates/loading/search UI) are not stuck with the initial cached pane.
|
|
398
|
+
const panes = this.setChannelContent(this.state.selectedChannel, this.state.panes);
|
|
399
|
+
const hideChannelTabsForLocalSms = useLocalTemplates && panes.length === 1;
|
|
400
|
+
const activeLocalPane = hideChannelTabsForLocalSms
|
|
401
|
+
? (panes.find(
|
|
402
|
+
(p) => String(p.key).toLowerCase() === String(this.state.selectedChannel).toLowerCase(),
|
|
403
|
+
) || panes[0])
|
|
404
|
+
: null;
|
|
369
405
|
return (
|
|
370
406
|
!isCreativeAccessible ? <AccessForbidden /> : (
|
|
371
|
-
<div
|
|
372
|
-
{isFullMode
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
panes={this.state.panes}
|
|
382
|
-
onChange={this.channelChange}
|
|
383
|
-
activeKey={this.state.selectedChannel}
|
|
384
|
-
defaultActiveKey={this.state.selectedChannel}
|
|
385
|
-
isFullMode={isFullMode}
|
|
407
|
+
<div
|
|
408
|
+
className={`${className} creatives-templates-container ${isFullMode ? 'fullmode' : 'library-mode'}${useLocalTemplates ? ' creatives-templates-container--local-sms' : ''}`}
|
|
409
|
+
data-testid="cap-wrapper"
|
|
410
|
+
>
|
|
411
|
+
{isFullMode && !useLocalTemplates && (
|
|
412
|
+
<Helmet
|
|
413
|
+
title={this.props.intl.formatMessage(messages.creatives)}
|
|
414
|
+
meta={[
|
|
415
|
+
{ name: 'description', content: this.props.intl.formatMessage(messages.creativesDesc) },
|
|
416
|
+
]}
|
|
386
417
|
/>
|
|
418
|
+
)}
|
|
419
|
+
<div className="component-wrapper">
|
|
420
|
+
{isFullMode && (
|
|
421
|
+
<CapHeader
|
|
422
|
+
title={<FormattedMessage {...messages.creatives} />}
|
|
423
|
+
{...(!useLocalTemplates && {
|
|
424
|
+
description: <FormattedMessage {...messages.creativesDesc} />,
|
|
425
|
+
})}
|
|
426
|
+
/>
|
|
427
|
+
)}
|
|
428
|
+
{hideChannelTabsForLocalSms ? (
|
|
429
|
+
<div className="templates-v2-local-sms-pane">{activeLocalPane?.content}</div>
|
|
430
|
+
) : (
|
|
431
|
+
<StyledCapTab
|
|
432
|
+
panes={panes}
|
|
433
|
+
onChange={this.channelChange}
|
|
434
|
+
activeKey={this.state.selectedChannel}
|
|
435
|
+
defaultActiveKey={this.state.selectedChannel}
|
|
436
|
+
isFullMode={isFullMode}
|
|
437
|
+
/>
|
|
438
|
+
)}
|
|
387
439
|
</div>
|
|
388
440
|
</div>
|
|
389
441
|
)
|
|
@@ -415,6 +467,17 @@ TemplatesV2.propTypes = {
|
|
|
415
467
|
currentOrgDetails: PropTypes.object,
|
|
416
468
|
restrictPersonalization: PropTypes.bool,
|
|
417
469
|
isAnonymousType: PropTypes.bool,
|
|
470
|
+
// Optional: reuse grid UI with local template list (e.g. SMS fallback). Pass object or same keys as individual props.
|
|
471
|
+
localTemplatesConfig: PropTypes.shape({
|
|
472
|
+
useLocalTemplates: PropTypes.bool,
|
|
473
|
+
localTemplates: PropTypes.arrayOf(PropTypes.object),
|
|
474
|
+
localTemplatesLoading: PropTypes.bool,
|
|
475
|
+
localTemplatesLoadingTip: PropTypes.string,
|
|
476
|
+
localTemplatesFilterContent: PropTypes.node,
|
|
477
|
+
localTemplatesFooterContent: PropTypes.node,
|
|
478
|
+
localTemplatesOnPageChange: PropTypes.func,
|
|
479
|
+
localTemplatesUseSkeleton: PropTypes.bool,
|
|
480
|
+
}),
|
|
418
481
|
};
|
|
419
482
|
|
|
420
483
|
TemplatesV2.defaultProps = {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded SMS template list: localTemplatesConfig + SMS-only channel visibility (RCS SMS fallback).
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { injectIntl } from 'react-intl';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
8
|
+
import { Provider } from 'react-redux';
|
|
9
|
+
import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
10
|
+
import history from '../../../utils/history';
|
|
11
|
+
import { initialReducer } from '../../../initialReducer';
|
|
12
|
+
import { render, screen } from '../../../utils/test-utils';
|
|
13
|
+
import { TemplatesV2 } from '../index';
|
|
14
|
+
import { Templates, authData, currentOrgDetails as currentOrgDetailsMock } from './mockData';
|
|
15
|
+
import { CHANNELS_TO_HIDE_FOR_SMS_ONLY } from '../../../v2Components/SmsFallback/constants';
|
|
16
|
+
|
|
17
|
+
const mockTemplates = jest.fn(() => <div data-testid="templates-mock">Templates</div>);
|
|
18
|
+
jest.mock('v2Containers/Templates', () => ({
|
|
19
|
+
__esModule: true,
|
|
20
|
+
default: (props) => mockTemplates(props),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('../../../utils/authWrapper', () => ({
|
|
24
|
+
UserIsAuthenticated: jest.fn((config) => config),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const ComponentToRender = injectIntl(TemplatesV2);
|
|
28
|
+
const renderComponent = (p) => {
|
|
29
|
+
const store = configureStore({}, initialReducer, history);
|
|
30
|
+
return render(
|
|
31
|
+
<Provider store={store}>
|
|
32
|
+
<ComponentToRender {...p} />
|
|
33
|
+
</Provider>,
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('TemplatesV2 local SMS templates (embedded)', () => {
|
|
38
|
+
const templateActions = {
|
|
39
|
+
templateActions: jest.fn(),
|
|
40
|
+
deleteTemplate: jest.fn(),
|
|
41
|
+
getAccountsSettings: jest.fn(),
|
|
42
|
+
getAllTemplates: jest.fn(),
|
|
43
|
+
getCdnTransformationConfig: jest.fn(),
|
|
44
|
+
getDefaultBeeTemplates: jest.fn(),
|
|
45
|
+
getSenderDetails: jest.fn(),
|
|
46
|
+
getTemplateDetails: jest.fn(),
|
|
47
|
+
getUserList: jest.fn(),
|
|
48
|
+
getWeCrmAccounts: jest.fn(),
|
|
49
|
+
handleHtmlUpload: jest.fn(),
|
|
50
|
+
handleZipUpload: jest.fn(),
|
|
51
|
+
resetAccount: jest.fn(),
|
|
52
|
+
resetTemplate: jest.fn(),
|
|
53
|
+
resetTemplateData: jest.fn(),
|
|
54
|
+
resetTemplateStoreData: jest.fn(),
|
|
55
|
+
resetUploadData: jest.fn(),
|
|
56
|
+
setBEETemplate: jest.fn(),
|
|
57
|
+
setChannelAccount: jest.fn(),
|
|
58
|
+
setEdmTemplate: jest.fn(),
|
|
59
|
+
setFacebookAccount: jest.fn(),
|
|
60
|
+
setViberAccount: jest.fn(),
|
|
61
|
+
setWeChatAccount: jest.fn(),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const baseProps = {
|
|
65
|
+
cap: {
|
|
66
|
+
user: { accessiblePermissions: ['CREATIVES_UI_VIEW'] },
|
|
67
|
+
},
|
|
68
|
+
actions: { defaultAction: jest.fn(), getTemplates: jest.fn() },
|
|
69
|
+
Templates,
|
|
70
|
+
TemplatesList: Templates?.templates,
|
|
71
|
+
authData,
|
|
72
|
+
templateActions,
|
|
73
|
+
isFullMode: false,
|
|
74
|
+
className: 'embed-test',
|
|
75
|
+
channel: 'sms',
|
|
76
|
+
channelsToHide: CHANNELS_TO_HIDE_FOR_SMS_ONLY,
|
|
77
|
+
channelsToDisable: [],
|
|
78
|
+
onChannelChange: jest.fn(),
|
|
79
|
+
enableNewChannels: [],
|
|
80
|
+
/** Without JP_LOCALE_HIDE_FEATURE so SMS panes are not stripped to Email/Line/Gallery only */
|
|
81
|
+
currentOrgDetails: {
|
|
82
|
+
...currentOrgDetailsMock,
|
|
83
|
+
accessibleFeatures: (currentOrgDetailsMock.accessibleFeatures || []).filter(
|
|
84
|
+
(f) => f !== 'JP_LOCALE_HIDE_FEATURE',
|
|
85
|
+
),
|
|
86
|
+
},
|
|
87
|
+
location: {
|
|
88
|
+
pathname: 'v2',
|
|
89
|
+
basename: '/creatives/ui/',
|
|
90
|
+
query: {},
|
|
91
|
+
},
|
|
92
|
+
router: { push: jest.fn() },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
mockTemplates.mockClear();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('adds local-sms container class and single-pane layout when only SMS is visible', () => {
|
|
100
|
+
const p = cloneDeep(baseProps);
|
|
101
|
+
p.localTemplatesConfig = {
|
|
102
|
+
useLocalTemplates: true,
|
|
103
|
+
localTemplates: [],
|
|
104
|
+
localTemplatesLoading: false,
|
|
105
|
+
};
|
|
106
|
+
renderComponent(p);
|
|
107
|
+
|
|
108
|
+
const wrapper = screen.getByTestId('cap-wrapper');
|
|
109
|
+
expect(wrapper).toHaveClass('creatives-templates-container--local-sms');
|
|
110
|
+
expect(document.querySelector('.templates-v2-local-sms-pane')).toBeTruthy();
|
|
111
|
+
expect(mockTemplates).toHaveBeenCalled();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('passes localTemplatesConfig into Templates for the SMS pane', () => {
|
|
115
|
+
const localConfig = {
|
|
116
|
+
useLocalTemplates: true,
|
|
117
|
+
localTemplates: [{ _id: '1', name: 'A' }],
|
|
118
|
+
localTemplatesLoading: false,
|
|
119
|
+
};
|
|
120
|
+
const p = cloneDeep(baseProps);
|
|
121
|
+
p.localTemplatesConfig = localConfig;
|
|
122
|
+
renderComponent(p);
|
|
123
|
+
|
|
124
|
+
expect(mockTemplates).toHaveBeenCalled();
|
|
125
|
+
const passed = mockTemplates.mock.calls.find(
|
|
126
|
+
(call) => call[0] && call[0].localTemplatesConfig && call[0].localTemplatesConfig.useLocalTemplates,
|
|
127
|
+
);
|
|
128
|
+
expect(passed).toBeTruthy();
|
|
129
|
+
expect(passed[0].localTemplatesConfig).toMatchObject(localConfig);
|
|
130
|
+
});
|
|
131
|
+
});
|