@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.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.
Files changed (87) hide show
  1. package/constants/unified.js +4 -0
  2. package/package.json +1 -1
  3. package/translations/en.json +1 -0
  4. package/translations/ja-JP.json +1 -0
  5. package/translations/zh.json +1 -0
  6. package/utils/common.js +6 -0
  7. package/utils/createMobilePushPayload.js +33 -50
  8. package/utils/tagValidations.js +35 -4
  9. package/utils/templateVarUtils.js +49 -0
  10. package/utils/tests/createMobilePushPayload.test.js +8 -113
  11. package/utils/tests/tagValidations.test.js +48 -0
  12. package/utils/tests/templateVarUtils.test.js +89 -0
  13. package/v2Components/CapMpushCTA/index.js +9 -10
  14. package/v2Components/CapMpushCTA/index.scss +3 -29
  15. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  16. package/v2Components/CapTagList/constants.js +5 -0
  17. package/v2Components/CapTagList/index.js +46 -7
  18. package/v2Components/CapTagList/messages.js +44 -0
  19. package/v2Components/CapTagList/style.scss +113 -1
  20. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  21. package/v2Components/CapTagList/utils.js +17 -0
  22. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
  23. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  24. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  25. package/v2Components/CommonTestAndPreview/index.js +61 -61
  26. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
  27. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  28. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  29. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  30. package/v2Components/FormBuilder/Classic.js +24 -14
  31. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  32. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  33. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  35. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  36. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  37. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  38. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  39. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  40. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  41. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  42. package/v2Components/TemplatePreview/index.js +16 -24
  43. package/v2Components/TemplatePreview/tests/index.test.js +0 -68
  44. package/v2Containers/Cap/messages.js +4 -0
  45. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  46. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
  47. package/v2Containers/CreativesContainer/index.js +1 -2
  48. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
  49. package/v2Containers/InApp/index.js +4 -1
  50. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  51. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  52. package/v2Containers/Line/Container/Text/index.js +3 -1
  53. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  54. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  55. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  56. package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
  57. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
  58. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  59. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
  60. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
  61. package/v2Containers/MobilePushNew/constants.js +0 -5
  62. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  63. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  64. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
  65. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  66. package/v2Containers/MobilePushNew/index.js +239 -488
  67. package/v2Containers/MobilePushNew/index.scss +4 -205
  68. package/v2Containers/MobilePushNew/messages.js +6 -106
  69. package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
  70. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
  71. package/v2Containers/MobilePushNew/utils.js +0 -56
  72. package/v2Containers/Rcs/index.js +8 -1
  73. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  74. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  75. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  76. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  77. package/v2Containers/Templates/_templates.scss +2 -10
  78. package/v2Containers/Templates/index.js +81 -83
  79. package/v2Containers/Templates/tests/index.test.js +0 -68
  80. package/v2Containers/Viber/index.js +3 -1
  81. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  82. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  83. package/v2Containers/Whatsapp/index.js +9 -5
  84. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  85. package/v2Containers/Zalo/index.js +4 -1
  86. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  87. package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
@@ -6,8 +6,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
6
6
  import history from '../../../utils/history';
7
7
  import { initialReducer } from '../../../initialReducer';
8
8
  import { MobilePushNew } from '..';
9
- import { render, screen, fireEvent, waitFor } from '../../../utils/test-utils';
10
- import * as commonUtils from '../../../utils/commonUtils';
9
+ import { render, screen, fireEvent } from '../../../utils/test-utils';
11
10
 
12
11
  jest.mock('../../TagList/index.js', () => ({
13
12
  __esModule: true,
@@ -18,23 +17,6 @@ jest.mock('../../TagList/index.js', () => ({
18
17
  ),
19
18
  }));
20
19
 
21
- jest.mock('../../../v2Components/TestAndPreviewSlidebox', () => ({
22
- __esModule: true,
23
- default: ({
24
- show, onClose, content, formData,
25
- }) => (
26
- <button
27
- type="button"
28
- data-testid="test-preview-slidebox"
29
- data-show={String(!!show)}
30
- data-android-actions={JSON.stringify(content?.androidContent?.actions || [])}
31
- data-ios-actions={JSON.stringify(content?.iosContent?.actions || [])}
32
- data-form-data={JSON.stringify(formData || [])}
33
- onClick={onClose}
34
- />
35
- ),
36
- }));
37
-
38
20
  let store;
39
21
  beforeAll(() => {
40
22
  store = configureStore({}, initialReducer, history);
@@ -134,41 +116,6 @@ describe('MobilePushNew', () => {
134
116
 
135
117
  await screen.findByPlaceholderText('Enter title');
136
118
  });
137
-
138
- it('renders the Android and iOS tab labels when both platforms are supported', async () => {
139
- renderComponent({
140
- accountData: { configs: { android: '1', ios: '1' } },
141
- templateData: {},
142
- location: {},
143
- injectedTags: {},
144
- getDefaultTags: jest.fn(),
145
- globalActions,
146
- });
147
-
148
- expect((await screen.findAllByText('iOS')).length).toBeGreaterThan(0);
149
- expect(screen.getAllByText('Android').length).toBeGreaterThan(0);
150
- });
151
-
152
- it('runs liquid validation from the sticky Save row in library mode', async () => {
153
- const validateSpy = jest.spyOn(commonUtils, 'validateMobilePushContent').mockImplementation(() => {});
154
- renderComponent({
155
- accountData,
156
- templateData: {},
157
- location: {},
158
- injectedTags: {},
159
- getDefaultTags: jest.fn(),
160
- globalActions,
161
- });
162
-
163
- fireEvent.change(await screen.findByPlaceholderText('Enter title'), { target: { value: 'Hello' } });
164
- fireEvent.change(await screen.findByPlaceholderText('Enter message'), { target: { value: 'World' } });
165
- const saveButton = screen.getByRole('button', { name: 'Save Template' });
166
- expect(saveButton.closest('.mpush-save-section')).not.toBeNull();
167
-
168
- fireEvent.click(saveButton);
169
- expect(validateSpy).toHaveBeenCalledTimes(1);
170
- validateSpy.mockRestore();
171
- });
172
119
  });
173
120
 
174
121
  describe('MobilePushNew — full mode keeps the slidebox open after saving', () => {
@@ -230,419 +177,4 @@ describe('MobilePushNew — full mode keeps the slidebox open after saving', ()
230
177
  expect(props.mobilePushActions.editTemplate.mock.calls[0][0]._id).toBe('mp-1');
231
178
  expect(props.handleClose).not.toHaveBeenCalled();
232
179
  });
233
-
234
- it('saves directly from the sticky Save row in full mode', async () => {
235
- const props = buildProps();
236
- render(<ComponentWithStore {...props} />);
237
-
238
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
239
- fireEvent.change(await screen.findByPlaceholderText('Enter title'), { target: { value: 'Hello' } });
240
- fireEvent.change(await screen.findByPlaceholderText('Enter message'), { target: { value: 'World' } });
241
-
242
- fireEvent.click(screen.getByRole('button', { name: 'Save Template' }));
243
- expect(props.mobilePushActions.createTemplate).toHaveBeenCalledTimes(1);
244
- });
245
-
246
- describe('both platforms supported, only Android filled', () => {
247
- const bothPlatformsAccount = {
248
- configs: { android: '1', ios: '1' }, accountId: 'acc-1', licenseCode: 'lic-1', sourceType: 'FCM',
249
- };
250
-
251
- // Fills Android (and optionally an iOS title), then saves from the footer
252
- const fillAndroidAndFooterSave = async (props, iosTitle = '') => {
253
- const { rerender } = render(<ComponentWithStore {...props} />);
254
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
255
- fireEvent.change((await screen.findAllByPlaceholderText('Enter title'))[0], { target: { value: 'Hello' } });
256
- fireEvent.change(screen.getAllByPlaceholderText('Enter message')[0], { target: { value: 'World' } });
257
- if (iosTitle) {
258
- fireEvent.click(screen.getAllByText('iOS')[0]);
259
- const titleInputs = await screen.findAllByPlaceholderText('Enter title');
260
- fireEvent.change(titleInputs[titleInputs.length - 1], { target: { value: iosTitle } });
261
- fireEvent.click(screen.getAllByText('Android')[0]);
262
- }
263
- expect(screen.getByRole('button', { name: 'Save Template' })).toBeDisabled();
264
- rerender(<ComponentWithStore {...props} isGetFormData />);
265
- };
266
-
267
- it('does not save with iOS empty: opens the iOS tab with inline errors, no dialog', async () => {
268
- const props = buildProps({ accountData: bothPlatformsAccount });
269
- await fillAndroidAndFooterSave(props);
270
-
271
- expect((await screen.findAllByText('Template message cannot be empty')).length).toBe(2);
272
- expect(screen.getByRole('tab', { selected: true })).toHaveTextContent('iOS');
273
- expect(screen.queryByRole('dialog')).toBeNull();
274
- expect(props.mobilePushActions.createTemplate).not.toHaveBeenCalled();
275
- });
276
-
277
- it('does not save with iOS half filled: inline error on the iOS message', async () => {
278
- const props = buildProps({ accountData: bothPlatformsAccount });
279
- await fillAndroidAndFooterSave(props, 'Only a title');
280
-
281
- expect((await screen.findAllByText('Template message cannot be empty')).length).toBe(1);
282
- expect(screen.queryByRole('dialog')).toBeNull();
283
- expect(props.mobilePushActions.createTemplate).not.toHaveBeenCalled();
284
- });
285
- });
286
-
287
- describe('Notification tap', () => {
288
- const fillAndChooseTap = async (props, tapLabel) => {
289
- render(<ComponentWithStore {...props} />);
290
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
291
- fireEvent.change(await screen.findByPlaceholderText('Enter title'), { target: { value: 'Hello' } });
292
- fireEvent.change(screen.getByPlaceholderText('Enter message'), { target: { value: 'World' } });
293
-
294
- expect(screen.getByText('Opens your app. Choose a link to send people to a specific page instead.')).toBeInTheDocument();
295
- fireEvent.click(screen.getByText('App (default)'));
296
- const options = await screen.findAllByText(tapLabel);
297
- fireEvent.click(options[options.length - 1]);
298
- };
299
-
300
- it('an open External link blocks the template Save until its own Save is clicked', async () => {
301
- const props = buildProps();
302
- await fillAndChooseTap(props, 'External link');
303
- const urlInput = await screen.findByPlaceholderText('Enter URL');
304
-
305
- expect(screen.getByRole('button', { name: 'Save Template' })).toBeDisabled();
306
- expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
307
-
308
- fireEvent.change(urlInput, { target: { value: 'https://example.com' } });
309
- fireEvent.click(screen.getByRole('button', { name: 'Save' }));
310
-
311
- expect(await screen.findByText('https://example.com')).toBeInTheDocument();
312
- expect(screen.queryByPlaceholderText('Enter URL')).toBeNull();
313
- expect(screen.getByRole('button', { name: 'Save Template' })).not.toBeDisabled();
314
- });
315
-
316
- it('an open Deep link with none picked keeps both Saves off', async () => {
317
- const props = buildProps();
318
- await fillAndChooseTap(props, 'Deep link');
319
-
320
- expect(screen.getByRole('button', { name: 'Save Template' })).toBeDisabled();
321
- expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
322
- expect(props.mobilePushActions.createTemplate).not.toHaveBeenCalled();
323
- });
324
- });
325
-
326
- describe('Same content for both platforms', () => {
327
- const bothPlatformsAccount = {
328
- configs: { android: '1', ios: '1' }, accountId: 'acc-1', licenseCode: 'lic-1', sourceType: 'FCM',
329
- };
330
- const fillTab = async (tabLabel, title, message) => {
331
- fireEvent.click(screen.getAllByText(tabLabel)[0]);
332
- const titleInputs = await screen.findAllByPlaceholderText('Enter title');
333
- const messageInputs = screen.getAllByPlaceholderText('Enter message');
334
- const index = tabLabel === 'Android' ? 0 : titleInputs.length - 1;
335
- fireEvent.change(titleInputs[index], { target: { value: title } });
336
- fireEvent.change(messageInputs[index], { target: { value: message } });
337
- };
338
- const sameContentBox = () => screen.getByRole('checkbox', { name: 'Same content for both platforms' });
339
- const iosTitleValue = async () => {
340
- fireEvent.click(screen.getAllByText('iOS')[0]);
341
- const titleInputs = await screen.findAllByPlaceholderText('Enter title');
342
- return titleInputs[titleInputs.length - 1].value;
343
- };
344
-
345
- it('ticks straight away when the other tab is empty', async () => {
346
- render(<ComponentWithStore {...buildProps({ accountData: bothPlatformsAccount })} />);
347
- await screen.findByPlaceholderText('Enter creative name');
348
- await fillTab('Android', 'Android title', 'Android message');
349
-
350
- fireEvent.click(sameContentBox());
351
- expect(screen.queryByText('Replace iOS content?')).toBeNull();
352
- expect(sameContentBox()).toBeChecked();
353
- expect(await iosTitleValue()).toBe('Android title');
354
- });
355
-
356
- it('asks before replacing different content; Cancel keeps both, Replace copies', async () => {
357
- render(<ComponentWithStore {...buildProps({ accountData: bothPlatformsAccount })} />);
358
- await screen.findByPlaceholderText('Enter creative name');
359
- await fillTab('iOS', 'iOS title', 'iOS message');
360
- await fillTab('Android', 'Android title', 'Android message');
361
-
362
- fireEvent.click(sameContentBox());
363
- expect(await screen.findByText('Replace iOS content?')).toBeInTheDocument();
364
- fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
365
- expect(sameContentBox()).not.toBeChecked();
366
-
367
- fireEvent.click(screen.getAllByText('Android')[0]);
368
- fireEvent.click(sameContentBox());
369
- fireEvent.click(await screen.findByRole('button', { name: 'Replace' }));
370
- expect(sameContentBox()).toBeChecked();
371
- expect(await iosTitleValue()).toBe('Android title');
372
- });
373
- });
374
-
375
- describe('Platforms dropdown', () => {
376
- const bothPlatformsAccount = {
377
- configs: { android: '1', ios: '1' }, accountId: 'acc-1', licenseCode: 'lic-1', sourceType: 'FCM',
378
- };
379
-
380
- // Opens the dropdown from its shown value and picks an option
381
- const choosePlatform = async (currentLabel, nextLabel) => {
382
- fireEvent.click(screen.getAllByText(currentLabel)[0]);
383
- const options = await screen.findAllByText(nextLabel);
384
- fireEvent.click(options[options.length - 1]);
385
- };
386
-
387
- const fillVisibleForm = async (title, message) => {
388
- const titleInputs = await screen.findAllByPlaceholderText('Enter title');
389
- const messageInputs = screen.getAllByPlaceholderText('Enter message');
390
- fireEvent.change(titleInputs[titleInputs.length - 1], { target: { value: title } });
391
- fireEvent.change(messageInputs[messageInputs.length - 1], { target: { value: message } });
392
- };
393
-
394
- const createdPayload = (props) => props.mobilePushActions.createTemplate.mock.calls[0][0];
395
-
396
- it('Android and iOS with both tabs filled saves both platforms without the alert', async () => {
397
- const props = buildProps({ accountData: bothPlatformsAccount });
398
- render(<ComponentWithStore {...props} />);
399
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
400
-
401
- expect(screen.getByText('Same content for both platforms')).toBeInTheDocument();
402
- await fillVisibleForm('Android title', 'Android message');
403
- fireEvent.click(screen.getAllByText('iOS')[0]);
404
- await fillVisibleForm('iOS title', 'iOS message');
405
- fireEvent.click(screen.getByRole('button', { name: 'Save Template' }));
406
-
407
- expect(screen.queryByRole('dialog')).toBeNull();
408
- expect(props.mobilePushActions.createTemplate).toHaveBeenCalledTimes(1);
409
- const { versions } = createdPayload(props);
410
- expect(versions.base.ANDROID).toEqual(expect.objectContaining({ title: 'Android title', message: 'Android message' }));
411
- expect(versions.base.IOS).toEqual(expect.objectContaining({ title: 'iOS title', message: 'iOS message' }));
412
- });
413
-
414
- it('Android only hides the tabs and checkbox and saves only the ANDROID key', async () => {
415
- const props = buildProps({ accountData: bothPlatformsAccount });
416
- render(<ComponentWithStore {...props} />);
417
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
418
-
419
- await choosePlatform('Android and iOS', 'Android only');
420
- expect(screen.queryByText('Same content for both platforms')).toBeNull();
421
- expect(screen.getAllByPlaceholderText('Enter title')).toHaveLength(1);
422
-
423
- await fillVisibleForm('Android title', 'Android message');
424
- fireEvent.click(screen.getByRole('button', { name: 'Save Template' }));
425
-
426
- expect(screen.queryByRole('dialog')).toBeNull();
427
- const { versions, definition } = createdPayload(props);
428
- expect(Object.keys(versions.base)).toEqual(['ANDROID']);
429
- expect(definition.sameContent).toBe(false);
430
- });
431
-
432
- it('iOS only saves only the IOS key', async () => {
433
- const props = buildProps({ accountData: bothPlatformsAccount });
434
- render(<ComponentWithStore {...props} />);
435
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
436
-
437
- await choosePlatform('Android and iOS', 'iOS only');
438
- expect(screen.queryByText('Same content for both platforms')).toBeNull();
439
- await fillVisibleForm('iOS title', 'iOS message');
440
- fireEvent.click(screen.getByRole('button', { name: 'Save Template' }));
441
-
442
- const { versions } = createdPayload(props);
443
- expect(Object.keys(versions.base)).toEqual(['IOS']);
444
- expect(versions.base.IOS).toEqual(expect.objectContaining({ title: 'iOS title', message: 'iOS message' }));
445
- });
446
-
447
- it('a single platform with empty fields shows inline errors, not the alert', async () => {
448
- const props = buildProps({ accountData: bothPlatformsAccount });
449
- const { rerender } = render(<ComponentWithStore {...props} />);
450
- fireEvent.change(await screen.findByPlaceholderText('Enter creative name'), { target: { value: 'Promo push' } });
451
-
452
- await choosePlatform('Android and iOS', 'Android only');
453
- rerender(<ComponentWithStore {...props} isGetFormData />); // footer Save
454
-
455
- expect((await screen.findAllByText('Template message cannot be empty')).length).toBe(2);
456
- expect(screen.queryByRole('dialog')).toBeNull();
457
- expect(props.mobilePushActions.createTemplate).not.toHaveBeenCalled();
458
- });
459
-
460
- it('confirms before dropping the other platform\'s content; Cancel keeps Android and iOS', async () => {
461
- const props = buildProps({ accountData: bothPlatformsAccount });
462
- render(<ComponentWithStore {...props} />);
463
- await screen.findByPlaceholderText('Enter creative name');
464
- fireEvent.click(screen.getAllByText('iOS')[0]);
465
- await fillVisibleForm('iOS title', 'iOS message');
466
-
467
- await choosePlatform('Android and iOS', 'Android only');
468
- expect(await screen.findByText('Remove iOS content?')).toBeInTheDocument();
469
- fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
470
- expect(screen.getByText('Same content for both platforms')).toBeInTheDocument();
471
-
472
- await choosePlatform('Android and iOS', 'Android only');
473
- fireEvent.click(await screen.findByRole('button', { name: 'Remove content' }));
474
- expect(screen.queryByText('Same content for both platforms')).toBeNull();
475
-
476
- // Back to both: the iOS tab is empty
477
- await choosePlatform('Android only', 'Android and iOS');
478
- fireEvent.click(screen.getAllByText('iOS')[0]);
479
- const titleInputs = await screen.findAllByPlaceholderText('Enter title');
480
- expect(titleInputs[titleInputs.length - 1]).toHaveValue('');
481
- });
482
-
483
- it('opens a template saved with only Android as Android only', async () => {
484
- renderComponent({
485
- accountData: { configs: { android: '1', ios: '1' } },
486
- templateData: {
487
- name: 'Saved Android push',
488
- versions: { base: { ANDROID: { title: 'A title', message: 'A msg', expandableDetails: { style: 'BIG_TEXT' } } } },
489
- },
490
- location: {},
491
- injectedTags: {},
492
- getDefaultTags: jest.fn(),
493
- globalActions,
494
- mobilePushActions: { setTemplateDetails: jest.fn(), getTemplateDetails: jest.fn(), clearData: jest.fn() },
495
- });
496
-
497
- expect(await screen.findByText('Android only')).toBeInTheDocument();
498
- expect(screen.queryByText('Same content for both platforms')).toBeNull();
499
- await waitFor(() => expect(screen.getByPlaceholderText('Enter title')).toHaveValue('A title'));
500
- });
501
- });
502
-
503
- describe('Test & Preview from the edit footer', () => {
504
- const baseProps = {
505
- accountData,
506
- templateData: {},
507
- location: {},
508
- injectedTags: {},
509
- getDefaultTags: jest.fn(),
510
- globalActions,
511
- };
512
-
513
- it('opens the slidebox when the parent sets showTestAndPreviewSlidebox', async () => {
514
- renderComponent({ ...baseProps, showTestAndPreviewSlidebox: true });
515
- expect(await screen.findByTestId('test-preview-slidebox')).toHaveAttribute('data-show', 'true');
516
- });
517
-
518
- it('stays closed by default and tells the parent on close', async () => {
519
- const handleCloseTestAndPreview = jest.fn();
520
- renderComponent({ ...baseProps, handleCloseTestAndPreview });
521
- const slidebox = await screen.findByTestId('test-preview-slidebox');
522
-
523
- expect(slidebox).toHaveAttribute('data-show', 'false');
524
- fireEvent.click(slidebox);
525
- expect(handleCloseTestAndPreview).toHaveBeenCalledTimes(1);
526
- });
527
- });
528
-
529
- describe('saved template buttons in the preview', () => {
530
- const cta = (actionText) => ({ actionText, type: 'EXTERNAL_URL', actionLink: 'https://x.com' });
531
- const savedTemplate = {
532
- name: 'Saved push',
533
- versions: {
534
- base: {
535
- ANDROID: { title: 'A title', message: 'A msg', expandableDetails: { style: 'BIG_TEXT', ctas: [cta('AndPrim')] } },
536
- IOS: { title: 'I title', message: 'I msg', expandableDetails: { style: 'BIG_TEXT', ctas: [cta('IOSPrim')] } },
537
- },
538
- },
539
- };
540
-
541
- const renderSaved = () => renderComponent({
542
- accountData: { configs: { android: '1', ios: '1' } },
543
- templateData: savedTemplate,
544
- location: {},
545
- injectedTags: {},
546
- getDefaultTags: jest.fn(),
547
- globalActions,
548
- mobilePushActions: { setTemplateDetails: jest.fn(), getTemplateDetails: jest.fn(), clearData: jest.fn() },
549
- });
550
-
551
- it('passes saved buttons in the test payload formData', async () => {
552
- renderSaved();
553
- const slidebox = await screen.findByTestId('test-preview-slidebox');
554
-
555
- await waitFor(() => {
556
- const [android, ios] = JSON.parse(slidebox.getAttribute('data-form-data'));
557
- expect(android).toEqual(expect.objectContaining({
558
- 'secondary-cta-0-label': 'AndPrim',
559
- 'cta-deeplink-secondary-cta-0': 'External Link',
560
- 'cta-deeplink-secondary-cta-0-text': 'https://x.com',
561
- }));
562
- expect(ios).toEqual(expect.objectContaining({
563
- 'secondary-cta-1-label': 'IOSPrim',
564
- 'cta-deeplink-secondary-cta-1': 'External Link',
565
- 'cta-deeplink-secondary-cta-1-text': 'https://x.com',
566
- }));
567
- });
568
- });
569
-
570
- it('fills iOS buttons without opening the iOS tab', async () => {
571
- renderSaved();
572
- const slidebox = await screen.findByTestId('test-preview-slidebox');
573
-
574
- await waitFor(() => {
575
- expect(slidebox).toHaveAttribute('data-android-actions', JSON.stringify([{ label: 'AndPrim' }]));
576
- expect(slidebox).toHaveAttribute('data-ios-actions', JSON.stringify([{ label: 'IOSPrim' }]));
577
- });
578
- });
579
-
580
- it('passes each platform\'s own saved video in the test payload formData', async () => {
581
- const videoTemplate = {
582
- name: 'Saved video push',
583
- versions: {
584
- base: {
585
- ANDROID: {
586
- title: 'A title',
587
- message: 'A msg',
588
- type: 'VIDEO',
589
- expandableDetails: { style: 'VIDEO', media: [{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }] },
590
- },
591
- IOS: { title: 'I title', message: 'I msg', expandableDetails: { style: 'BIG_TEXT' } },
592
- },
593
- },
594
- };
595
- renderComponent({
596
- accountData: { configs: { android: '1', ios: '1' } },
597
- templateData: videoTemplate,
598
- location: {},
599
- injectedTags: {},
600
- getDefaultTags: jest.fn(),
601
- globalActions,
602
- mobilePushActions: { setTemplateDetails: jest.fn(), getTemplateDetails: jest.fn(), clearData: jest.fn() },
603
- });
604
- const slidebox = await screen.findByTestId('test-preview-slidebox');
605
-
606
- await waitFor(() => {
607
- const [android, ios] = JSON.parse(slidebox.getAttribute('data-form-data'));
608
- expect(android.video).toBe('https://s3/a.mp4');
609
- expect(ios.video).toBe('');
610
- });
611
- });
612
-
613
- it('passes saved carousel cards in the test payload formData', async () => {
614
- const card = {
615
- mediaType: 'video', imageUrl: '', videoSrc: 'https://s3/c.mp4', buttons: [],
616
- };
617
- renderComponent({
618
- accountData: { configs: { android: '1', ios: '1' } },
619
- templateData: {
620
- name: 'Saved carousel push',
621
- versions: {
622
- base: {
623
- ANDROID: {
624
- title: 'A title',
625
- message: 'A msg',
626
- type: 'CAROUSEL',
627
- expandableDetails: { style: 'MANUAL_CAROUSEL', carouselData: [card] },
628
- },
629
- IOS: { title: 'I title', message: 'I msg', expandableDetails: { style: 'BIG_TEXT' } },
630
- },
631
- },
632
- },
633
- location: {},
634
- injectedTags: {},
635
- getDefaultTags: jest.fn(),
636
- globalActions,
637
- mobilePushActions: { setTemplateDetails: jest.fn(), getTemplateDetails: jest.fn(), clearData: jest.fn() },
638
- });
639
- const slidebox = await screen.findByTestId('test-preview-slidebox');
640
-
641
- await waitFor(() => {
642
- const [android, ios] = JSON.parse(slidebox.getAttribute('data-form-data'));
643
- expect(android.carouselData).toEqual([expect.objectContaining({ mediaType: 'video', videoSrc: 'https://s3/c.mp4' })]);
644
- expect(ios.carouselData).toEqual([]);
645
- });
646
- });
647
- });
648
180
  });
@@ -5,10 +5,6 @@ import {
5
5
  isDeepLink,
6
6
  isPlatformFieldsMissing,
7
7
  computeIsContentEmpty,
8
- getContent,
9
- findSelectedDeepLink,
10
- getCarouselCardIssue,
11
- CAROUSEL_CARD_ISSUE,
12
8
  } from "../utils";
13
9
  import { isUrl } from "../../Line/Container/Wrapper/utils";
14
10
 
@@ -514,69 +510,3 @@ describe("utils.js", () => {
514
510
  });
515
511
  });
516
512
  });
517
-
518
- describe("getContent", () => {
519
- it("returns three spaces when there is no content", () => {
520
- expect(getContent(null)).toBe(" ");
521
- expect(getContent({ versions: { base: {} } })).toBe(" ");
522
- });
523
-
524
- it("joins Android and iOS title and message", () => {
525
- const payload = {
526
- versions: {
527
- base: {
528
- ANDROID: { title: "A title", message: "A msg" },
529
- IOS: { title: "I title", message: "I msg" },
530
- },
531
- },
532
- };
533
- expect(getContent(payload)).toBe("A title A msg I title I msg");
534
- });
535
-
536
- it("leaves an empty slot for a missing platform", () => {
537
- const payload = { versions: { base: { ANDROID: { title: "A", message: "B" } } } };
538
- expect(getContent(payload)).toBe("A B ");
539
- });
540
- });
541
-
542
- describe("findSelectedDeepLink", () => {
543
- const links = [{ value: "app://offer", keys: ["offerId"] }];
544
-
545
- it("matches exactly, then without query params", () => {
546
- expect(findSelectedDeepLink(links, "app://offer")).toBe(links[0]);
547
- expect(findSelectedDeepLink(links, "app://offer?offerId=offerId")).toBe(links[0]);
548
- expect(findSelectedDeepLink(links, "app://other")).toBeUndefined();
549
- expect(findSelectedDeepLink(undefined, "app://offer")).toBeUndefined();
550
- });
551
- });
552
-
553
- describe("getCarouselCardIssue", () => {
554
- const links = [{ value: "app://offer", keys: ["offerId"] }, { value: "app://home" }];
555
- const card = (button = {}, media = { mediaType: "image", imageUrl: "a.jpg" }) => ({
556
- ...media,
557
- buttons: [{
558
- actionOnClick: true, linkType: "DEEP_LINK", deepLinkValue: "", deepLinkKeys: [], externalLinkValue: "", ...button,
559
- }],
560
- });
561
-
562
- it("is complete with media and App as the tap action", () => {
563
- expect(getCarouselCardIssue(card({ actionOnClick: false }), links)).toBeNull();
564
- });
565
-
566
- it("flags missing media", () => {
567
- expect(getCarouselCardIssue(card({ actionOnClick: false }, { mediaType: "image", imageUrl: "" }), links)).toBe(CAROUSEL_CARD_ISSUE.MEDIA);
568
- expect(getCarouselCardIssue(card({ actionOnClick: false }, { mediaType: "video", videoSrc: "" }), links)).toBe(CAROUSEL_CARD_ISSUE.MEDIA);
569
- });
570
-
571
- it("flags an empty deep link or URL before missing media", () => {
572
- const noMedia = { mediaType: "image", imageUrl: "" };
573
- expect(getCarouselCardIssue(card({}, noMedia), links)).toBe(CAROUSEL_CARD_ISSUE.DEEP_LINK);
574
- expect(getCarouselCardIssue(card({ linkType: "EXTERNAL_LINK", externalLinkValue: " " }), links)).toBe(CAROUSEL_CARD_ISSUE.EXTERNAL_LINK);
575
- });
576
-
577
- it("needs keys only when the chosen deep link has them", () => {
578
- expect(getCarouselCardIssue(card({ deepLinkValue: "app://offer" }), links)).toBe(CAROUSEL_CARD_ISSUE.DEEP_LINK_KEYS);
579
- expect(getCarouselCardIssue(card({ deepLinkValue: "app://offer", deepLinkKeys: ["offerId"] }), links)).toBeNull();
580
- expect(getCarouselCardIssue(card({ deepLinkValue: "app://home" }), links)).toBeNull();
581
- });
582
- });
@@ -1,52 +1,4 @@
1
1
  import { isUrl } from "../Line/Container/Wrapper/utils";
2
- import { EXTERNAL_LINK, VIDEO } from "./constants";
3
-
4
- // Deep link option for a saved value; falls back to matching without query params
5
- export const findSelectedDeepLink = (links, value) => {
6
- if (!links || !value) return undefined;
7
- const exactMatch = links.find((link) => link?.value === value);
8
- if (exactMatch || !value.includes('?')) return exactMatch;
9
- const baseDeepLinkValue = value.split('?')[0];
10
- return links.find((link) => link?.value === baseDeepLinkValue);
11
- };
12
-
13
- export const CAROUSEL_CARD_ISSUE = {
14
- MEDIA: 'media',
15
- DEEP_LINK: 'deepLink',
16
- DEEP_LINK_KEYS: 'deepLinkKeys',
17
- EXTERNAL_LINK: 'externalLink',
18
- UNSAVED_LINK: 'unsavedLink',
19
- };
20
-
21
- /**
22
- * What a carousel card still needs before it can be saved. Link issues come first so the
23
- * card can show them while its media is still being added.
24
- * @param {Object} card - Editor carousel card
25
- * @param {Array} deepLinks - Deep link options ({ value, keys })
26
- * @returns {string|null} - A CAROUSEL_CARD_ISSUE value, or null when the card is complete
27
- */
28
- export const getCarouselCardIssue = (card, deepLinks) => {
29
- const buttons = card?.buttons || [];
30
- for (let i = 0; i < buttons.length; i += 1) {
31
- const button = buttons[i];
32
- if (button?.actionOnClick) {
33
- if (button.linkType === EXTERNAL_LINK) {
34
- if (!button.externalLinkValue?.trim()) return CAROUSEL_CARD_ISSUE.EXTERNAL_LINK;
35
- } else if (!button.deepLinkValue) {
36
- return CAROUSEL_CARD_ISSUE.DEEP_LINK;
37
- } else {
38
- const keysFromSelection = findSelectedDeepLink(deepLinks, button.deepLinkValue)?.keys;
39
- const hasKeys = Array.isArray(keysFromSelection) ? keysFromSelection.length > 0 : !!keysFromSelection;
40
- const hasSavedKeys = Array.isArray(button.deepLinkKeys) && button.deepLinkKeys.length > 0;
41
- if (hasKeys && !hasSavedKeys) return CAROUSEL_CARD_ISSUE.DEEP_LINK_KEYS;
42
- }
43
- // Filled in but its Save not clicked yet (links loaded from a saved template have no flag)
44
- if (button.isSaved === false) return CAROUSEL_CARD_ISSUE.UNSAVED_LINK;
45
- }
46
- }
47
- const isMediaMissing = card?.mediaType === VIDEO.toLowerCase() ? !card?.videoSrc : !card?.imageUrl;
48
- return isMediaMissing ? CAROUSEL_CARD_ISSUE.MEDIA : null;
49
- };
50
2
 
51
3
  /**
52
4
  * Validate deep link format - supports custom schemes, HTTP/HTTPS, and relative paths
@@ -167,11 +119,3 @@ export const computeIsContentEmpty = ({
167
119
  const isIosMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
168
120
  return (!isAndroidSupported || isAndroidMissing) && (!isIosSupported || isIosMissing);
169
121
  };
170
-
171
- // Android and iOS title + message joined, for the create GA event
172
- export const getContent = (obj) => {
173
- const base = obj?.versions?.base || {};
174
- const android = base.ANDROID || {};
175
- const ios = base.IOS || {};
176
- return `${android.title || ''} ${android.message || ''} ${ios.title || ''} ${ios.message || ''}`;
177
- };
@@ -800,6 +800,8 @@ export const Rcs = (props) => {
800
800
  })) ||
801
801
  (validationResponse.isBraceError &&
802
802
  formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
803
+ (validationResponse.isDefaultQuoteError &&
804
+ formatMessage(globalMessages.unquotedTagDefaultValue)) ||
803
805
  false;
804
806
  if (type === TITLE_TEXT) setTemplateTitleError(errorMsg);
805
807
  if (type === MESSAGE_TEXT) setTemplateDescError(errorMsg);
@@ -851,6 +853,8 @@ export const Rcs = (props) => {
851
853
  })) ||
852
854
  (validationResponse.isBraceError &&
853
855
  formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
856
+ (validationResponse.isDefaultQuoteError &&
857
+ formatMessage(globalMessages.unquotedTagDefaultValue)) ||
854
858
  false;
855
859
  updateCarouselErrors(idx, { [field]: errorMsg });
856
860
  });
@@ -1808,7 +1812,7 @@ export const Rcs = (props) => {
1808
1812
 
1809
1813
  const templateDescErrorHandler = (value) => {
1810
1814
  let errorMessage = false;
1811
- const { unsupportedTags, isBraceError } = validateTags({
1815
+ const { unsupportedTags, isBraceError, isDefaultQuoteError } = validateTags({
1812
1816
  content: value,
1813
1817
  tagsParam: tags,
1814
1818
  injectedTagsParams: injectedTags,
@@ -1829,6 +1833,9 @@ export const Rcs = (props) => {
1829
1833
  if (isBraceError) {
1830
1834
  errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
1831
1835
  }
1836
+ if (isDefaultQuoteError) {
1837
+ errorMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
1838
+ }
1832
1839
  return errorMessage;
1833
1840
  };
1834
1841