@capillarytech/creatives-library 8.0.125 → 8.0.126

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.
Files changed (40) hide show
  1. package/config/app.js +6 -0
  2. package/initialReducer.js +2 -0
  3. package/package.json +1 -1
  4. package/services/api.js +93 -0
  5. package/services/tests/api.test.js +191 -0
  6. package/v2Components/CustomerSearchSection/_customerSearch.scss +309 -0
  7. package/v2Components/CustomerSearchSection/constants.js +5 -0
  8. package/v2Components/CustomerSearchSection/index.js +362 -0
  9. package/v2Components/CustomerSearchSection/messages.js +20 -0
  10. package/v2Components/CustomerSearchSection/tests/utils.test.js +334 -0
  11. package/v2Components/CustomerSearchSection/utils.js +49 -0
  12. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +543 -0
  13. package/v2Components/TestAndPreviewSlidebox/actions.js +67 -0
  14. package/v2Components/TestAndPreviewSlidebox/constants.js +67 -0
  15. package/v2Components/TestAndPreviewSlidebox/index.js +771 -0
  16. package/v2Components/TestAndPreviewSlidebox/messages.js +147 -0
  17. package/v2Components/TestAndPreviewSlidebox/reducer.js +233 -0
  18. package/v2Components/TestAndPreviewSlidebox/sagas.js +258 -0
  19. package/v2Components/TestAndPreviewSlidebox/selectors.js +142 -0
  20. package/v2Components/TestAndPreviewSlidebox/tests/actions.test.js +80 -0
  21. package/v2Components/TestAndPreviewSlidebox/tests/reducer.test.js +367 -0
  22. package/v2Components/TestAndPreviewSlidebox/tests/saga.rtl.test.js +192 -0
  23. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +652 -0
  24. package/v2Components/TestAndPreviewSlidebox/tests/selector.test.js +182 -0
  25. package/v2Containers/CreativesContainer/SlideBoxContent.js +13 -1
  26. package/v2Containers/CreativesContainer/SlideBoxFooter.js +23 -2
  27. package/v2Containers/CreativesContainer/index.js +23 -2
  28. package/v2Containers/CreativesContainer/messages.js +4 -0
  29. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +21 -0
  30. package/v2Containers/Email/index.js +13 -1
  31. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +10 -0
  32. package/v2Containers/EmailWrapper/index.js +6 -0
  33. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  34. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  35. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
  36. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
  37. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +18 -0
  38. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
  39. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -0
  40. package/v2Containers/Email/tests/index.test.js +0 -35
@@ -0,0 +1,334 @@
1
+ import {
2
+ checkForData,
3
+ removeExtraIdentifiers,
4
+ identifiersHighlight,
5
+ getNamingIcon,
6
+ } from '../utils';
7
+
8
+ describe('CustomerSearchSection Utils', () => {
9
+ describe('checkForData', () => {
10
+ it('should return filtered data based on source', () => {
11
+ const mockData = [
12
+ { source: 'INSTORE', value: 'test1' },
13
+ { source: 'ONLINE', value: 'test2' },
14
+ { source: 'INSTORE', value: 'test3' },
15
+ ];
16
+
17
+ const result = checkForData(mockData, 'INSTORE');
18
+
19
+ expect(result).toEqual([
20
+ { source: 'INSTORE', value: 'test1' },
21
+ { source: 'INSTORE', value: 'test3' },
22
+ ]);
23
+ expect(result).toHaveLength(2);
24
+ });
25
+
26
+ it('should return empty array when no matching source found', () => {
27
+ const mockData = [
28
+ { source: 'ONLINE', value: 'test1' },
29
+ { source: 'MOBILE', value: 'test2' },
30
+ ];
31
+
32
+ const result = checkForData(mockData, 'INSTORE');
33
+
34
+ expect(result).toEqual([]);
35
+ expect(result).toHaveLength(0);
36
+ });
37
+
38
+ it('should handle null/undefined data gracefully', () => {
39
+ expect(checkForData(null, 'INSTORE')).toBeUndefined();
40
+ expect(checkForData(undefined, 'INSTORE')).toBeUndefined();
41
+ expect(checkForData([], 'INSTORE')).toEqual([]);
42
+ });
43
+
44
+ it('should handle empty data array', () => {
45
+ const result = checkForData([], 'INSTORE');
46
+ expect(result).toEqual([]);
47
+ });
48
+
49
+ it('should handle case when source parameter is null/undefined', () => {
50
+ const mockData = [
51
+ { source: 'INSTORE', value: 'test1' },
52
+ { source: 'ONLINE', value: 'test2' },
53
+ ];
54
+
55
+ expect(checkForData(mockData, null)).toEqual([]);
56
+ expect(checkForData(mockData, undefined)).toEqual([]);
57
+ });
58
+ });
59
+
60
+ describe('removeExtraIdentifiers', () => {
61
+ const mockData = [
62
+ { idType: 'FIRSTNAME', idValue: 'John' },
63
+ { idType: 'LASTNAME', idValue: 'Doe' },
64
+ { idType: 'EMAIL', idValue: 'john@example.com' },
65
+ { idType: 'PHONE', idValue: '123456789' },
66
+ { idType: 'FIRSTNAME', idValue: 'Jane' },
67
+ ];
68
+
69
+ it('should remove identifiers with specified types', () => {
70
+ const result = removeExtraIdentifiers(mockData, 'FIRSTNAME', 'LASTNAME');
71
+
72
+ expect(result).toEqual([
73
+ { idType: 'EMAIL', idValue: 'john@example.com' },
74
+ { idType: 'PHONE', idValue: '123456789' },
75
+ ]);
76
+ expect(result).toHaveLength(2);
77
+ });
78
+
79
+ it('should return original data when no matching identifiers found', () => {
80
+ const result = removeExtraIdentifiers(mockData, 'NONEXISTENT', 'ALSO_NONEXISTENT');
81
+
82
+ expect(result).toEqual(mockData);
83
+ expect(result).toHaveLength(5);
84
+ });
85
+
86
+ it('should handle empty data array', () => {
87
+ const result = removeExtraIdentifiers([], 'FIRSTNAME', 'LASTNAME');
88
+ expect(result).toEqual([]);
89
+ });
90
+
91
+ it('should handle null/undefined data gracefully', () => {
92
+ expect(removeExtraIdentifiers(null, 'FIRSTNAME', 'LASTNAME')).toBeNull();
93
+ expect(removeExtraIdentifiers(undefined, 'FIRSTNAME', 'LASTNAME')).toBeUndefined();
94
+ });
95
+
96
+ it('should handle single identifier type to remove', () => {
97
+ const result = removeExtraIdentifiers(mockData, 'EMAIL', 'NONEXISTENT');
98
+
99
+ expect(result).toEqual([
100
+ { idType: 'FIRSTNAME', idValue: 'John' },
101
+ { idType: 'LASTNAME', idValue: 'Doe' },
102
+ { idType: 'PHONE', idValue: '123456789' },
103
+ { idType: 'FIRSTNAME', idValue: 'Jane' },
104
+ ]);
105
+ expect(result).toHaveLength(4);
106
+ });
107
+
108
+ it('should handle case when all identifiers match removal criteria', () => {
109
+ const onlyFirstLastData = [
110
+ { idType: 'FIRSTNAME', idValue: 'John' },
111
+ { idType: 'LASTNAME', idValue: 'Doe' },
112
+ ];
113
+
114
+ const result = removeExtraIdentifiers(onlyFirstLastData, 'FIRSTNAME', 'LASTNAME');
115
+
116
+ expect(result).toEqual([]);
117
+ expect(result).toHaveLength(0);
118
+ });
119
+ });
120
+
121
+ describe('identifiersHighlight', () => {
122
+ const mockData = [
123
+ { idValue: 'john@example.com' },
124
+ { idValue: 'jane.doe@test.com' },
125
+ { idValue: 'abcdefghijk' },
126
+ ];
127
+
128
+ it('should highlight search string in identifiers', () => {
129
+ const result = identifiersHighlight('john', mockData);
130
+
131
+ expect(result).toEqual([
132
+ {
133
+ firstString: '',
134
+ secondString: 'john',
135
+ thirdString: '@example.com',
136
+ },
137
+ {
138
+ firstString: '',
139
+ secondString: 'jan',
140
+ thirdString: 'e.doe@test.com',
141
+ },
142
+ {
143
+ firstString: '',
144
+ secondString: 'abc',
145
+ thirdString: 'defghijk',
146
+ },
147
+ ]);
148
+ });
149
+
150
+ it('should handle search string in middle of identifier', () => {
151
+ const result = identifiersHighlight('example', mockData);
152
+
153
+ expect(result).toEqual([
154
+ {
155
+ firstString: 'john@',
156
+ secondString: 'example',
157
+ thirdString: '.com',
158
+ },
159
+ {
160
+ firstString: '',
161
+ secondString: 'jane.d',
162
+ thirdString: 'oe@test.com',
163
+ },
164
+ {
165
+ firstString: '',
166
+ secondString: 'abcdef',
167
+ thirdString: 'ghijk',
168
+ },
169
+ ]);
170
+ });
171
+
172
+ it('should handle search string at end of identifier', () => {
173
+ const result = identifiersHighlight('com', mockData);
174
+
175
+ expect(result).toEqual([
176
+ {
177
+ firstString: 'john@example.',
178
+ secondString: 'com',
179
+ thirdString: '',
180
+ },
181
+ {
182
+ firstString: 'jane.doe@test.',
183
+ secondString: 'com',
184
+ thirdString: '',
185
+ },
186
+ {
187
+ firstString: '',
188
+ secondString: 'ab',
189
+ thirdString: 'cdefghijk',
190
+ },
191
+ ]);
192
+ });
193
+
194
+ it('should handle empty data array', () => {
195
+ const result = identifiersHighlight('john', []);
196
+ expect(result).toBeUndefined();
197
+ });
198
+
199
+ it('should handle null/undefined data gracefully', () => {
200
+ expect(identifiersHighlight('john', null)).toBeUndefined();
201
+ expect(identifiersHighlight('john', undefined)).toBeUndefined();
202
+ });
203
+
204
+ it('should handle empty search string', () => {
205
+ const result = identifiersHighlight('', mockData);
206
+
207
+ expect(result).toEqual([
208
+ {
209
+ firstString: '',
210
+ secondString: '',
211
+ thirdString: 'john@example.com',
212
+ },
213
+ {
214
+ firstString: '',
215
+ secondString: '',
216
+ thirdString: 'jane.doe@test.com',
217
+ },
218
+ {
219
+ firstString: '',
220
+ secondString: '',
221
+ thirdString: 'abcdefghijk',
222
+ },
223
+ ]);
224
+ });
225
+
226
+ it('should handle case when search string is not found', () => {
227
+ const result = identifiersHighlight('xyz', mockData);
228
+
229
+ expect(result).toEqual([
230
+ {
231
+ firstString: '',
232
+ secondString: 'jo',
233
+ thirdString: 'hn@example.com',
234
+ },
235
+ {
236
+ firstString: '',
237
+ secondString: 'ja',
238
+ thirdString: 'ne.doe@test.com',
239
+ },
240
+ {
241
+ firstString: '',
242
+ secondString: 'ab',
243
+ thirdString: 'cdefghijk',
244
+ },
245
+ ]);
246
+ });
247
+
248
+ it('should handle data with null/undefined idValue', () => {
249
+ const dataWithNullValues = [
250
+ { idValue: null },
251
+ { idValue: undefined },
252
+ { idValue: 'valid@email.com' },
253
+ ];
254
+
255
+ const result = identifiersHighlight('valid', dataWithNullValues);
256
+
257
+ expect(result).toEqual([
258
+ {
259
+ firstString: undefined,
260
+ secondString: undefined,
261
+ thirdString: undefined,
262
+ },
263
+ {
264
+ firstString: undefined,
265
+ secondString: undefined,
266
+ thirdString: undefined,
267
+ },
268
+ {
269
+ firstString: '',
270
+ secondString: 'valid',
271
+ thirdString: '@email.com',
272
+ },
273
+ ]);
274
+ });
275
+ });
276
+
277
+ describe('getNamingIcon', () => {
278
+ it('should return two uppercase initials for full name', () => {
279
+ expect(getNamingIcon('John Doe')).toBe('JD');
280
+ expect(getNamingIcon('Jane Smith')).toBe('JS');
281
+ expect(getNamingIcon('Mary Jane Watson')).toBe('MJ');
282
+ });
283
+
284
+ it('should return first two letters for single name', () => {
285
+ expect(getNamingIcon('John')).toBe('JO');
286
+ expect(getNamingIcon('Jane')).toBe('JA');
287
+ expect(getNamingIcon('Ab')).toBe('AB');
288
+ });
289
+
290
+ it('should handle names with extra spaces', () => {
291
+ expect(getNamingIcon('John Doe')).toBe('JD');
292
+ expect(getNamingIcon('Jane Smith')).toBe('JS');
293
+ });
294
+
295
+ it('should handle empty string', () => {
296
+ expect(getNamingIcon('')).toBe('');
297
+ });
298
+
299
+ it('should handle null/undefined gracefully', () => {
300
+ expect(() => getNamingIcon(null)).toThrow();
301
+ expect(() => getNamingIcon(undefined)).toThrow();
302
+ });
303
+
304
+ it('should handle lowercase names', () => {
305
+ expect(getNamingIcon('john doe')).toBe('JD');
306
+ expect(getNamingIcon('jane smith')).toBe('JS');
307
+ });
308
+
309
+ it('should handle mixed case names', () => {
310
+ expect(getNamingIcon('jOhN dOe')).toBe('JD');
311
+ expect(getNamingIcon('JaNe SmItH')).toBe('JS');
312
+ });
313
+
314
+ it('should handle special characters in names', () => {
315
+ expect(getNamingIcon('John-Doe')).toBe('JO');
316
+ expect(getNamingIcon("O'Connor Smith")).toBe('OS');
317
+ });
318
+
319
+ it('should handle very long names', () => {
320
+ expect(getNamingIcon('Johnathon Christopher')).toBe('JC');
321
+ expect(getNamingIcon('A B C D E F G')).toBe('AB');
322
+ });
323
+
324
+ it('should handle names with numbers', () => {
325
+ expect(getNamingIcon('John2 Doe3')).toBe('JD');
326
+ expect(getNamingIcon('User123')).toBe('US');
327
+ });
328
+
329
+ it('should handle single character names', () => {
330
+ expect(getNamingIcon('A')).toBe('A');
331
+ expect(getNamingIcon('X')).toBe('X');
332
+ });
333
+ });
334
+ });
@@ -0,0 +1,49 @@
1
+ export const checkForData = (data, source) => {
2
+ const expectedData = data?.filter((d) => d?.source === source);
3
+ return expectedData;
4
+ };
5
+
6
+ export const removeExtraIdentifiers = (
7
+ data,
8
+ identiferFirstKey,
9
+ identifiersSecondKey,
10
+ ) => {
11
+ let finalResult = data;
12
+ const extraIdentifiers = data?.filter(
13
+ (d) => d?.idType === identiferFirstKey || d?.idType === identifiersSecondKey,
14
+ );
15
+ finalResult = extraIdentifiers?.length > 0
16
+ ? data?.filter((item) => extraIdentifiers?.indexOf(item) === -1)
17
+ : data;
18
+
19
+ return finalResult;
20
+ };
21
+
22
+ export const identifiersHighlight = (searchString, data) => {
23
+ let finalResult;
24
+ if (data?.length > 0) {
25
+ finalResult = data?.map((d) => {
26
+ const searchedStringIndex = d?.idValue?.indexOf(searchString);
27
+ const searchStringLength = searchString?.length;
28
+ const sliceString = searchedStringIndex + searchStringLength;
29
+ return {
30
+ firstString: d?.idValue?.substring(0, searchedStringIndex),
31
+ secondString: d?.idValue?.substring(searchedStringIndex, sliceString),
32
+ thirdString: d?.idValue?.substring(sliceString),
33
+ };
34
+ });
35
+ }
36
+ return finalResult;
37
+ };
38
+
39
+ // Name breaking icon
40
+ export const getNamingIcon = (data) => {
41
+ let returnedString;
42
+ const splitStrings = data?.split(' ');
43
+ returnedString = splitStrings?.length > 1
44
+ ? splitStrings[0].charAt(0).toUpperCase()
45
+ + splitStrings[1].charAt(0).toUpperCase()
46
+ : splitStrings[0].charAt(0).toUpperCase()
47
+ + splitStrings[0].charAt(1).toUpperCase();
48
+ return returnedString;
49
+ };