@capillarytech/creatives-library 8.0.125-alpha.6 → 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 (105) hide show
  1. package/config/app.js +6 -0
  2. package/containers/App/constants.js +0 -1
  3. package/containers/Email/index.js +5 -5
  4. package/containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
  5. package/initialReducer.js +2 -0
  6. package/package.json +1 -1
  7. package/services/api.js +94 -1
  8. package/services/tests/api.test.js +191 -0
  9. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +3 -8
  10. package/tests/integration/TemplateCreation/api-response.js +0 -5
  11. package/tests/integration/TemplateCreation/msw-handler.js +63 -42
  12. package/utils/common.js +0 -7
  13. package/utils/commonUtils.js +6 -2
  14. package/v2Components/CapImageUpload/index.js +45 -51
  15. package/v2Components/CapInAppCTA/index.js +0 -1
  16. package/v2Components/CapTagList/index.js +120 -177
  17. package/v2Components/CapVideoUpload/constants.js +0 -3
  18. package/v2Components/CapVideoUpload/index.js +110 -167
  19. package/v2Components/CapVideoUpload/messages.js +0 -16
  20. package/v2Components/Carousel/index.js +13 -15
  21. package/v2Components/CustomerSearchSection/_customerSearch.scss +309 -0
  22. package/v2Components/CustomerSearchSection/constants.js +5 -0
  23. package/v2Components/CustomerSearchSection/index.js +362 -0
  24. package/v2Components/CustomerSearchSection/messages.js +20 -0
  25. package/v2Components/CustomerSearchSection/tests/utils.test.js +334 -0
  26. package/v2Components/CustomerSearchSection/utils.js +49 -0
  27. package/v2Components/ErrorInfoNote/style.scss +0 -1
  28. package/v2Components/MobilePushPreviewV2/index.js +5 -37
  29. package/v2Components/TemplatePreview/_templatePreview.scss +72 -114
  30. package/v2Components/TemplatePreview/index.js +50 -178
  31. package/v2Components/TemplatePreview/messages.js +0 -4
  32. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +543 -0
  33. package/v2Components/TestAndPreviewSlidebox/actions.js +67 -0
  34. package/v2Components/TestAndPreviewSlidebox/constants.js +67 -0
  35. package/v2Components/TestAndPreviewSlidebox/index.js +771 -0
  36. package/v2Components/TestAndPreviewSlidebox/messages.js +147 -0
  37. package/v2Components/TestAndPreviewSlidebox/reducer.js +233 -0
  38. package/v2Components/TestAndPreviewSlidebox/sagas.js +258 -0
  39. package/v2Components/TestAndPreviewSlidebox/selectors.js +142 -0
  40. package/v2Components/TestAndPreviewSlidebox/tests/actions.test.js +80 -0
  41. package/v2Components/TestAndPreviewSlidebox/tests/reducer.test.js +367 -0
  42. package/v2Components/TestAndPreviewSlidebox/tests/saga.rtl.test.js +192 -0
  43. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +652 -0
  44. package/v2Components/TestAndPreviewSlidebox/tests/selector.test.js +182 -0
  45. package/v2Containers/CreativesContainer/SlideBoxContent.js +21 -9
  46. package/v2Containers/CreativesContainer/SlideBoxFooter.js +23 -2
  47. package/v2Containers/CreativesContainer/index.js +160 -195
  48. package/v2Containers/CreativesContainer/messages.js +4 -0
  49. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +21 -0
  50. package/v2Containers/Email/index.js +18 -6
  51. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +10 -0
  52. package/v2Containers/EmailWrapper/index.js +6 -0
  53. package/v2Containers/InApp/constants.js +0 -1
  54. package/v2Containers/InApp/index.js +13 -13
  55. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  56. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  57. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
  58. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
  59. package/v2Containers/MobilePush/Create/index.js +0 -1
  60. package/v2Containers/MobilePush/commonMethods.js +14 -7
  61. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +23 -5
  62. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
  63. package/v2Containers/TagList/index.js +10 -56
  64. package/v2Containers/Templates/_templates.scss +1 -101
  65. package/v2Containers/Templates/index.js +35 -147
  66. package/v2Containers/Templates/messages.js +0 -8
  67. package/v2Containers/Templates/sagas.js +0 -2
  68. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
  69. package/v2Containers/Whatsapp/constants.js +0 -1
  70. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -0
  71. package/utils/createPayload.js +0 -270
  72. package/utils/tests/createPayload.test.js +0 -761
  73. package/v2Components/CapMpushCTA/constants.js +0 -25
  74. package/v2Components/CapMpushCTA/index.js +0 -332
  75. package/v2Components/CapMpushCTA/index.scss +0 -95
  76. package/v2Components/CapMpushCTA/messages.js +0 -89
  77. package/v2Components/TemplatePreview/assets/images/Android _ With date and time.svg +0 -29
  78. package/v2Components/TemplatePreview/assets/images/android.svg +0 -9
  79. package/v2Components/TemplatePreview/assets/images/iOS _ With date and time.svg +0 -26
  80. package/v2Components/TemplatePreview/assets/images/ios.svg +0 -9
  81. package/v2Containers/Email/tests/index.test.js +0 -35
  82. package/v2Containers/MobilePushNew/actions.js +0 -116
  83. package/v2Containers/MobilePushNew/components/CtaButtons.js +0 -170
  84. package/v2Containers/MobilePushNew/components/MediaUploaders.js +0 -686
  85. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +0 -279
  86. package/v2Containers/MobilePushNew/components/index.js +0 -5
  87. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +0 -779
  88. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +0 -2114
  89. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +0 -343
  90. package/v2Containers/MobilePushNew/constants.js +0 -115
  91. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +0 -1299
  92. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -1223
  93. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +0 -246
  94. package/v2Containers/MobilePushNew/hooks/useUpload.js +0 -709
  95. package/v2Containers/MobilePushNew/index.js +0 -2170
  96. package/v2Containers/MobilePushNew/index.scss +0 -308
  97. package/v2Containers/MobilePushNew/messages.js +0 -226
  98. package/v2Containers/MobilePushNew/reducer.js +0 -160
  99. package/v2Containers/MobilePushNew/sagas.js +0 -198
  100. package/v2Containers/MobilePushNew/selectors.js +0 -55
  101. package/v2Containers/MobilePushNew/tests/reducer.test.js +0 -741
  102. package/v2Containers/MobilePushNew/tests/sagas.test.js +0 -863
  103. package/v2Containers/MobilePushNew/tests/selectors.test.js +0 -425
  104. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -322
  105. package/v2Containers/MobilePushNew/utils.js +0 -33
@@ -1,322 +0,0 @@
1
- import {
2
- validateLink,
3
- validateExternalLink,
4
- validateDeepLink,
5
- } from "../utils";
6
- import { isUrl } from "../../Line/Container/Wrapper/utils";
7
-
8
- // Mock the isUrl utility function
9
- jest.mock("../../Line/Container/Wrapper/utils", () => ({
10
- isUrl: jest.fn(),
11
- }));
12
-
13
- describe("utils.js", () => {
14
- const mockFormatMessage = jest.fn();
15
- const mockMessages = {
16
- invalidUrl: {
17
- id: "invalidUrl",
18
- defaultMessage: "Invalid URL format",
19
- },
20
- };
21
-
22
- beforeEach(() => {
23
- jest.clearAllMocks();
24
- mockFormatMessage.mockImplementation((msg) => msg.defaultMessage);
25
- });
26
-
27
- describe("validateLink", () => {
28
- describe("Valid scenarios", () => {
29
- it("should return null for valid URL", () => {
30
- isUrl.mockReturnValue(true);
31
-
32
- const result = validateLink("https://example.com", mockFormatMessage, mockMessages);
33
-
34
- expect(result).toBeNull();
35
- expect(isUrl).toHaveBeenCalledWith("https://example.com");
36
- expect(mockFormatMessage).not.toHaveBeenCalled();
37
- });
38
-
39
- it("should return null for valid URL with whitespace", () => {
40
- isUrl.mockReturnValue(true);
41
-
42
- const result = validateLink(" https://example.com ", mockFormatMessage, mockMessages);
43
-
44
- expect(result).toBeNull();
45
- expect(isUrl).toHaveBeenCalledWith("https://example.com");
46
- expect(mockFormatMessage).not.toHaveBeenCalled();
47
- });
48
-
49
- it("should return null for empty URL", () => {
50
- const result = validateLink("", mockFormatMessage, mockMessages);
51
-
52
- expect(result).toBeNull();
53
- expect(isUrl).not.toHaveBeenCalled();
54
- expect(mockFormatMessage).not.toHaveBeenCalled();
55
- });
56
-
57
- it("should return null for null URL", () => {
58
- const result = validateLink(null, mockFormatMessage, mockMessages);
59
-
60
- expect(result).toBeNull();
61
- expect(isUrl).not.toHaveBeenCalled();
62
- expect(mockFormatMessage).not.toHaveBeenCalled();
63
- });
64
-
65
- it("should return null for undefined URL", () => {
66
- const result = validateLink(undefined, mockFormatMessage, mockMessages);
67
-
68
- expect(result).toBeNull();
69
- expect(isUrl).not.toHaveBeenCalled();
70
- expect(mockFormatMessage).not.toHaveBeenCalled();
71
- });
72
-
73
- it("should return null for whitespace-only URL", () => {
74
- const result = validateLink(" ", mockFormatMessage, mockMessages);
75
-
76
- expect(result).toBeNull();
77
- expect(isUrl).not.toHaveBeenCalled();
78
- expect(mockFormatMessage).not.toHaveBeenCalled();
79
- });
80
-
81
- it("should return null for tab and newline whitespace", () => {
82
- const result = validateLink("\t\n\r", mockFormatMessage, mockMessages);
83
-
84
- expect(result).toBeNull();
85
- expect(isUrl).not.toHaveBeenCalled();
86
- expect(mockFormatMessage).not.toHaveBeenCalled();
87
- });
88
- });
89
-
90
- describe("Invalid scenarios", () => {
91
- it("should return error message for invalid URL", () => {
92
- isUrl.mockReturnValue(false);
93
-
94
- const result = validateLink("invalid-url", mockFormatMessage, mockMessages);
95
-
96
- expect(result).toBe("Invalid URL format");
97
- expect(isUrl).toHaveBeenCalledWith("invalid-url");
98
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
99
- });
100
-
101
- it("should return error message for invalid URL with whitespace", () => {
102
- isUrl.mockReturnValue(false);
103
-
104
- const result = validateLink(" invalid-url ", mockFormatMessage, mockMessages);
105
-
106
- expect(result).toBe("Invalid URL format");
107
- expect(isUrl).toHaveBeenCalledWith("invalid-url");
108
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
109
- });
110
-
111
- it("should return error message for malformed URL", () => {
112
- isUrl.mockReturnValue(false);
113
-
114
- const result = validateLink("htp://malformed", mockFormatMessage, mockMessages);
115
-
116
- expect(result).toBe("Invalid URL format");
117
- expect(isUrl).toHaveBeenCalledWith("htp://malformed");
118
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
119
- });
120
-
121
- it("should return error message for URL without protocol", () => {
122
- isUrl.mockReturnValue(false);
123
-
124
- const result = validateLink("example.com", mockFormatMessage, mockMessages);
125
-
126
- expect(result).toBe("Invalid URL format");
127
- expect(isUrl).toHaveBeenCalledWith("example.com");
128
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
129
- });
130
-
131
- it("should handle special characters in invalid URL", () => {
132
- isUrl.mockReturnValue(false);
133
-
134
- const result = validateLink("http://ex@mple.com", mockFormatMessage, mockMessages);
135
-
136
- expect(result).toBe("Invalid URL format");
137
- expect(isUrl).toHaveBeenCalledWith("http://ex@mple.com");
138
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
139
- });
140
- });
141
-
142
- describe("Edge cases", () => {
143
- it("should handle custom formatMessage function", () => {
144
- const customFormatMessage = jest.fn().mockReturnValue("Custom error message");
145
- isUrl.mockReturnValue(false);
146
-
147
- const result = validateLink("invalid", customFormatMessage, mockMessages);
148
-
149
- expect(result).toBe("Custom error message");
150
- expect(customFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
151
- });
152
-
153
- it("should handle different message object structure", () => {
154
- const customMessages = {
155
- invalidUrl: {
156
- id: "custom.invalidUrl",
157
- defaultMessage: "Custom invalid URL message",
158
- },
159
- };
160
- isUrl.mockReturnValue(false);
161
-
162
- const result = validateLink("invalid", mockFormatMessage, customMessages);
163
-
164
- expect(result).toBe("Custom invalid URL message");
165
- expect(mockFormatMessage).toHaveBeenCalledWith(customMessages.invalidUrl);
166
- });
167
-
168
- it("should trim very long whitespace strings", () => {
169
- const longWhitespace = " ".repeat(100);
170
-
171
- const result = validateLink(longWhitespace, mockFormatMessage, mockMessages);
172
-
173
- expect(result).toBeNull();
174
- expect(isUrl).not.toHaveBeenCalled();
175
- });
176
- });
177
- });
178
-
179
- describe("validateExternalLink", () => {
180
- it("should call validateLink with correct parameters for valid URL", () => {
181
- isUrl.mockReturnValue(true);
182
-
183
- const result = validateExternalLink("https://external.com", mockFormatMessage, mockMessages);
184
-
185
- expect(result).toBeNull();
186
- expect(isUrl).toHaveBeenCalledWith("https://external.com");
187
- });
188
-
189
- it("should call validateLink with correct parameters for invalid URL", () => {
190
- isUrl.mockReturnValue(false);
191
-
192
- const result = validateExternalLink("invalid-external", mockFormatMessage, mockMessages);
193
-
194
- expect(result).toBe("Invalid URL format");
195
- expect(isUrl).toHaveBeenCalledWith("invalid-external");
196
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
197
- });
198
-
199
- it("should handle empty external link", () => {
200
- const result = validateExternalLink("", mockFormatMessage, mockMessages);
201
-
202
- expect(result).toBeNull();
203
- expect(isUrl).not.toHaveBeenCalled();
204
- });
205
-
206
- it("should handle null external link", () => {
207
- const result = validateExternalLink(null, mockFormatMessage, mockMessages);
208
-
209
- expect(result).toBeNull();
210
- expect(isUrl).not.toHaveBeenCalled();
211
- });
212
-
213
- it("should trim whitespace in external link", () => {
214
- isUrl.mockReturnValue(true);
215
-
216
- const result = validateExternalLink(" https://external.com ", mockFormatMessage, mockMessages);
217
-
218
- expect(result).toBeNull();
219
- expect(isUrl).toHaveBeenCalledWith("https://external.com");
220
- });
221
- });
222
-
223
- describe("validateDeepLink", () => {
224
- it("should call validateLink with correct parameters for valid deep link", () => {
225
- isUrl.mockReturnValue(true);
226
-
227
- const result = validateDeepLink("myapp://deeplink", mockFormatMessage, mockMessages);
228
-
229
- expect(result).toBeNull();
230
- expect(isUrl).toHaveBeenCalledWith("myapp://deeplink");
231
- });
232
-
233
- it("should call validateLink with correct parameters for invalid deep link", () => {
234
- isUrl.mockReturnValue(false);
235
-
236
- const result = validateDeepLink("invalid-deeplink", mockFormatMessage, mockMessages);
237
-
238
- expect(result).toBe("Invalid URL format");
239
- expect(isUrl).toHaveBeenCalledWith("invalid-deeplink");
240
- expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.invalidUrl);
241
- });
242
-
243
- it("should handle empty deep link", () => {
244
- const result = validateDeepLink("", mockFormatMessage, mockMessages);
245
-
246
- expect(result).toBeNull();
247
- expect(isUrl).not.toHaveBeenCalled();
248
- });
249
-
250
- it("should handle undefined deep link", () => {
251
- const result = validateDeepLink(undefined, mockFormatMessage, mockMessages);
252
-
253
- expect(result).toBeNull();
254
- expect(isUrl).not.toHaveBeenCalled();
255
- });
256
-
257
- it("should trim whitespace in deep link", () => {
258
- isUrl.mockReturnValue(true);
259
-
260
- const result = validateDeepLink(" myapp://deeplink ", mockFormatMessage, mockMessages);
261
-
262
- expect(result).toBeNull();
263
- expect(isUrl).toHaveBeenCalledWith("myapp://deeplink");
264
- });
265
-
266
- it("should handle custom scheme deep links", () => {
267
- isUrl.mockReturnValue(true);
268
-
269
- const result = validateDeepLink("customscheme://action/path", mockFormatMessage, mockMessages);
270
-
271
- expect(result).toBeNull();
272
- expect(isUrl).toHaveBeenCalledWith("customscheme://action/path");
273
- });
274
- });
275
-
276
- describe("Function independence", () => {
277
- it("should ensure validateExternalLink and validateDeepLink are independent", () => {
278
- isUrl.mockReturnValue(true);
279
-
280
- validateExternalLink("https://external.com", mockFormatMessage, mockMessages);
281
- validateDeepLink("myapp://deeplink", mockFormatMessage, mockMessages);
282
-
283
- expect(isUrl).toHaveBeenCalledTimes(2);
284
- expect(isUrl).toHaveBeenNthCalledWith(1, "https://external.com");
285
- expect(isUrl).toHaveBeenNthCalledWith(2, "myapp://deeplink");
286
- });
287
-
288
- it("should handle mixed valid and invalid calls", () => {
289
- isUrl.mockReturnValueOnce(true).mockReturnValueOnce(false);
290
-
291
- const result1 = validateExternalLink("https://valid.com", mockFormatMessage, mockMessages);
292
- const result2 = validateDeepLink("invalid", mockFormatMessage, mockMessages);
293
-
294
- expect(result1).toBeNull();
295
- expect(result2).toBe("Invalid URL format");
296
- expect(mockFormatMessage).toHaveBeenCalledTimes(1);
297
- });
298
- });
299
-
300
- describe("Error handling", () => {
301
- it("should handle isUrl throwing an error", () => {
302
- isUrl.mockImplementation(() => {
303
- throw new Error("isUrl error");
304
- });
305
-
306
- expect(() => {
307
- validateLink("https://example.com", mockFormatMessage, mockMessages);
308
- }).toThrow("isUrl error");
309
- });
310
-
311
- it("should handle formatMessage throwing an error", () => {
312
- isUrl.mockReturnValue(false);
313
- mockFormatMessage.mockImplementation(() => {
314
- throw new Error("formatMessage error");
315
- });
316
-
317
- expect(() => {
318
- validateLink("invalid", mockFormatMessage, mockMessages);
319
- }).toThrow("formatMessage error");
320
- });
321
- });
322
- });
@@ -1,33 +0,0 @@
1
- import { isUrl } from "../Line/Container/Wrapper/utils";
2
-
3
- /**
4
- * Common link validation function using isUrl utility
5
- * @param {string} url - The URL to validate
6
- * @param {Function} formatMessage - Function to format error messages
7
- * @param {Object} messages - Messages object containing invalidUrl message
8
- * @returns {string|null} - Error message if invalid, null if valid
9
- */
10
- export const validateLink = (url, formatMessage, messages) => {
11
- if (!url || url.trim() === "") {
12
- return null; // Empty URL is valid (optional field)
13
- }
14
- return isUrl(url.trim()) ? null : formatMessage(messages.invalidUrl);
15
- };
16
-
17
- /**
18
- * Validate external link specifically
19
- * @param {string} url - The external URL to validate
20
- * @param {Function} formatMessage - Function to format error messages
21
- * @param {Object} messages - Messages object containing invalidUrl message
22
- * @returns {string|null} - Error message if invalid, null if valid
23
- */
24
- export const validateExternalLink = (url, formatMessage, messages) => validateLink(url, formatMessage, messages);
25
-
26
- /**
27
- * Validate deep link specifically
28
- * @param {string} linkValue - The deep link to validate
29
- * @param {Function} formatMessage - Function to format error messages
30
- * @param {Object} messages - Messages object containing invalidUrl message
31
- * @returns {string|null} - Error message if invalid, null if valid
32
- */
33
- export const validateDeepLink = (linkValue, formatMessage, messages) => validateLink(linkValue, formatMessage, messages);