@capillarytech/creatives-library 9.0.73-alpha.sprint-testpreview.22 → 9.1.1

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 (66) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +58 -1
  3. package/v2Components/CapTagListWithInput/index.js +64 -35
  4. package/v2Components/CapTagListWithInput/index.scss +9 -0
  5. package/v2Components/CommonTestAndPreview/UnifiedPreview/EmailPreviewContent.js +8 -0
  6. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +7 -0
  7. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +1 -0
  8. package/v2Components/CommonTestAndPreview/actions.js +1 -1
  9. package/v2Components/CommonTestAndPreview/index.js +36 -75
  10. package/v2Components/CommonTestAndPreview/sagas.js +2 -1
  11. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/EmailPreviewContent.test.js +27 -0
  12. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +40 -0
  13. package/v2Components/CommonTestAndPreview/tests/index.test.js +92 -97
  14. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +24 -0
  15. package/v2Components/CommonTestAndPreview/tests/utils.test.js +0 -66
  16. package/v2Components/CommonTestAndPreview/utils.js +0 -14
  17. package/v2Components/EmailMobilePreview/index.js +8 -1
  18. package/v2Components/EmailMobilePreview/index.scss +12 -3
  19. package/v2Components/EmailMobilePreview/tests/index.test.js +31 -0
  20. package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +37 -5
  21. package/v2Components/EmailPreviewV2/index.js +18 -6
  22. package/v2Components/EmailPreviewV2/messages.js +4 -0
  23. package/v2Components/EmailPreviewV2/tests/index.test.js +43 -0
  24. package/v2Components/FormBuilder/Classic.js +134 -14
  25. package/v2Components/FormBuilder/Functional/FormBuilderShell.js +9 -0
  26. package/v2Components/FormBuilder/Functional/layout/TabsContainer.js +11 -12
  27. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +144 -0
  28. package/v2Components/FormBuilder/Functional/tests/tabsContainer.test.js +17 -5
  29. package/v2Components/FormBuilder/_formBuilder.scss +21 -0
  30. package/v2Components/FormBuilder/messages.js +12 -0
  31. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +45 -0
  32. package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +2 -1
  33. package/v2Containers/CommunicationFlow/Tests/constants.test.js +4 -4
  34. package/v2Containers/CommunicationFlow/constants.js +1 -0
  35. package/v2Containers/CommunicationFlow/utils/Tests/mapCommDefinitionToStepData.test.js +2 -1
  36. package/v2Containers/CommunicationFlow/utils/mapCommDefinitionToStepData.js +1 -0
  37. package/v2Containers/CreativesContainer/SlideBoxContent.js +0 -2
  38. package/v2Containers/CreativesContainer/index.js +7 -1
  39. package/v2Containers/CreativesContainer/tests/index.test.js +81 -0
  40. package/v2Containers/Email/index.js +31 -4
  41. package/v2Containers/Email/initialSchema.js +30 -0
  42. package/v2Containers/Email/messages.js +8 -0
  43. package/v2Containers/Email/tests/index.test.js +107 -0
  44. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +172 -8
  45. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +264 -5
  46. package/v2Containers/EmailWrapper/components/_emailHTMLEditor.scss +29 -0
  47. package/v2Containers/EmailWrapper/constants.js +5 -0
  48. package/v2Containers/EmailWrapper/messages.js +24 -0
  49. package/v2Containers/MobilePush/Create/constants.js +1 -0
  50. package/v2Containers/MobilePush/Create/index.js +2 -2
  51. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +58 -0
  52. package/v2Containers/MobilePush/Edit/index.js +2 -2
  53. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +17 -0
  54. package/v2Containers/MobilePush/commonMethods.js +7 -8
  55. package/v2Containers/Rcs/index.js +1 -27
  56. package/v2Containers/TagList/index.js +7 -0
  57. package/v2Containers/TagList/tests/TagList.test.js +42 -0
  58. package/v2Containers/Templates/index.js +4 -9
  59. package/v2Containers/Templates/tests/index.test.js +35 -107
  60. package/v2Containers/Viber/index.scss +31 -0
  61. package/v2Containers/Whatsapp/index.js +1 -18
  62. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  63. package/v2Containers/Zalo/index.js +0 -18
  64. package/v2Containers/Rcs/tests/testAndPreviewFromListing.test.js +0 -132
  65. package/v2Containers/Whatsapp/tests/testAndPreviewFromListing.test.js +0 -91
  66. package/v2Containers/Zalo/tests/testAndPreviewFromListing.test.js +0 -98
@@ -3268,10 +3268,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
3268
3268
  accountData,
3269
3269
  ]);
3270
3270
 
3271
- // Set when opened from listing "Preview and test"; closing then returns to the listing.
3272
- const isTestAndPreviewFromListingRef = useRef(false);
3273
- const hasAutoOpenedTestAndPreviewRef = useRef(false);
3274
-
3275
3271
  // Handle Test and Preview button click
3276
3272
  const handleTestAndPreview = useCallback(() => {
3277
3273
  setShowTestAndPreviewSlidebox(true);
@@ -3288,20 +3284,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
3288
3284
  if (propsHandleCloseTestAndPreview) {
3289
3285
  propsHandleCloseTestAndPreview();
3290
3286
  }
3291
- if (isTestAndPreviewFromListingRef.current && handleClose) {
3292
- isTestAndPreviewFromListingRef.current = false;
3293
- handleClose();
3294
- }
3295
- }, [propsHandleCloseTestAndPreview, handleClose]);
3296
-
3297
- // Listing "Preview and test": open Test & Preview once the template is hydrated.
3298
- useEffect(() => {
3299
- if (!isFullMode || !templateData?.openTestAndPreview || hasAutoOpenedTestAndPreviewRef.current) return;
3300
- if (spin || !isEditFlow || templateStatus !== WHATSAPP_STATUSES.approved) return;
3301
- hasAutoOpenedTestAndPreviewRef.current = true;
3302
- isTestAndPreviewFromListingRef.current = true;
3303
- handleTestAndPreview();
3304
- }, [isFullMode, templateData?.openTestAndPreview, spin, isEditFlow, templateStatus, handleTestAndPreview]);
3287
+ }, [propsHandleCloseTestAndPreview]);
3305
3288
 
3306
3289
  return (
3307
3290
  <CapSpin spinning={spin || metaDataStatus === REQUEST}>
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap
3
- size: 57271855 bytes
4
- sha256: d1e9c0cd51e8b68c9acd1ddeee01866302a054ed135d594d34509d92a3e39124
3
+ size: 57265074 bytes
4
+ sha256: 0c93028e0289bec64b42e30d37d66d0dddeaff992fb34ccc59499c9c2015f430
@@ -30,7 +30,6 @@ import './index.scss';
30
30
  import {
31
31
  SUCCESS_ALERT,
32
32
  REQUEST,
33
- SUCCESS,
34
33
  EMBEDDED,
35
34
  DEFAULT,
36
35
  TAG,
@@ -83,7 +82,6 @@ export const Zalo = (props) => {
83
82
  showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
84
83
  handleTestAndPreview: propsHandleTestAndPreview,
85
84
  handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
86
- handleClose,
87
85
  onContentValidityChange,
88
86
  } = props || {};
89
87
  // Since zalo supports now multiple accounts, we need to get the hostname from the selected account or passed props.
@@ -97,9 +95,6 @@ export const Zalo = (props) => {
97
95
  const [templateListParams, setTemplateListParams] = useState([]);
98
96
  const [templatePreviewUrl, setTemplatePreviewUrl] = useState('');
99
97
  const [showTestAndPreviewSlidebox, setShowTestAndPreviewSlidebox] = useState(false);
100
- // Set when opened from listing "Preview and test"; closing then returns to the listing.
101
- const isTestAndPreviewFromListingRef = useRef(false);
102
- const hasAutoOpenedTestAndPreviewRef = useRef(false);
103
98
  const [templateStatus, setZaloTemplateStatus] = useState(
104
99
  ZALO_STATUSES.ENABLE,
105
100
  );
@@ -515,21 +510,8 @@ export const Zalo = (props) => {
515
510
  if (propsHandleCloseTestAndPreview) {
516
511
  propsHandleCloseTestAndPreview();
517
512
  }
518
- if (isTestAndPreviewFromListingRef.current && handleClose) {
519
- isTestAndPreviewFromListingRef.current = false;
520
- handleClose();
521
- }
522
513
  };
523
514
 
524
- // Listing "Preview and test": open Test & Preview once the template is loaded.
525
- useEffect(() => {
526
- if (!isFullMode || !templateData?.openTestAndPreview || hasAutoOpenedTestAndPreviewRef.current) return;
527
- if (zaloTemplateInfoStatus !== SUCCESS || !templateId) return;
528
- hasAutoOpenedTestAndPreviewRef.current = true;
529
- isTestAndPreviewFromListingRef.current = true;
530
- handleTestAndPreview();
531
- }, [isFullMode, templateData?.openTestAndPreview, zaloTemplateInfoStatus, templateId]);
532
-
533
515
  return (
534
516
  <CapSpin spinning={[zaloTemplateInfoStatus, metaDataStatus].includes(REQUEST)}>
535
517
  <CapRow type="flex" className="cap-zalo-creatives">
@@ -1,132 +0,0 @@
1
- import React from 'react';
2
- import { Provider } from 'react-redux';
3
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
4
- import { initialReducer } from '../../../initialReducer';
5
- import { mountWithIntl } from '../../../../app/helpers/intl-enzym-test-helpers';
6
- import { Rcs } from '../index';
7
- import history from '../../../utils/history';
8
-
9
- jest.mock('react-redux', () => {
10
- const actual = jest.requireActual('react-redux');
11
- return { ...actual, useDispatch: jest.fn(() => jest.fn()) };
12
- });
13
- jest.mock('../../../v2Containers/TagList/index.js', () => ({
14
- __esModule: true,
15
- default: () => <div className="tag-mock">TagList</div>,
16
- }));
17
- jest.mock('../../../v2Components/CapImageUpload', () => ({
18
- __esModule: true,
19
- default: () => <div className="cap-image-upload-mock" />,
20
- }));
21
- jest.mock('../../../v2Components/CapVideoUpload', () => ({
22
- __esModule: true,
23
- default: () => <div className="cap-video-upload-mock" />,
24
- }));
25
- jest.mock('../../../v2Components/CapActionButton', () => ({
26
- __esModule: true,
27
- default: () => <div className="cap-action-button-mock" />,
28
- }));
29
- jest.mock('@capillarytech/cap-ui-library/CapIcon', () => ({
30
- __esModule: true,
31
- default: () => <span className="cap-icon-mock" />,
32
- }));
33
- jest.mock('../../CreativesContainer', () => ({
34
- __esModule: true,
35
- default: () => <div className="creatives-container-mock" />,
36
- }));
37
- // Stub exposes only open state + close action.
38
- jest.mock('../../../v2Components/TestAndPreviewSlidebox', () => ({
39
- __esModule: true,
40
- default: ({ show, onClose }) => (show ? <button type="button" className="mock-test-preview-close" onClick={onClose} /> : null),
41
- }));
42
-
43
- let store;
44
- beforeAll(() => {
45
- store = configureStore({}, initialReducer, history);
46
- });
47
-
48
- const buildTemplateDetails = (status) => ({
49
- _id: 'rcs_1',
50
- name: 'RcsTemplate',
51
- type: 'RCS',
52
- versions: {
53
- base: {
54
- content: {
55
- RCS: {
56
- rcsContent: {
57
- cardType: 'STANDALONE',
58
- cardSettings: { cardOrientation: 'VERTICAL' },
59
- contentType: 'text_message',
60
- cardContent: [{ title: '', description: 'Hello there', mediaType: 'NONE', Status: status }],
61
- },
62
- },
63
- },
64
- },
65
- },
66
- });
67
-
68
- describe('Rcs - Preview and test from listing', () => {
69
- const handleClose = jest.fn();
70
-
71
- const renderEdit = (templateData, status = 'approved') => {
72
- const wrapper = mountWithIntl(
73
- <Provider store={store}>
74
- <Rcs
75
- actions={{
76
- uploadRcsAsset: jest.fn(),
77
- clearRcsMediaAsset: jest.fn(),
78
- createTemplate: jest.fn(),
79
- clearCreateResponse: jest.fn(),
80
- // Details come in via rcsData; just release the spinner.
81
- getTemplateDetails: jest.fn((id, setSpin) => setSpin && setSpin(false)),
82
- editTemplate: jest.fn(),
83
- clearEditResponse: jest.fn(),
84
- }}
85
- globalActions={{ fetchSchemaForEntity: jest.fn() }}
86
- onCreateComplete={jest.fn()}
87
- handleClose={handleClose}
88
- intl={{ formatMessage: jest.fn() }}
89
- location={{ pathname: '/rcs/edit', query: { type: false, module: 'default' }, search: '' }}
90
- params={{ id: 'rcs_1' }}
91
- rcsData={{ templateDetails: buildTemplateDetails(status) }}
92
- templateData={templateData}
93
- isFullMode
94
- loadingTags={false}
95
- metaEntities={[]}
96
- getDefaultTags
97
- smsRegister="DLT"
98
- />
99
- </Provider>,
100
- );
101
- wrapper.update();
102
- return wrapper;
103
- };
104
-
105
- it('auto-opens Test & Preview for an approved template and returns to the listing on close', () => {
106
- const wrapper = renderEdit({ openTestAndPreview: true });
107
- const closeButton = wrapper.find('button.mock-test-preview-close');
108
- expect(closeButton.exists()).toBe(true);
109
-
110
- closeButton.simulate('click');
111
- expect(handleClose).toHaveBeenCalledTimes(1);
112
- });
113
-
114
- it('does not auto-open without the listing flag', () => {
115
- const wrapper = renderEdit({});
116
- expect(wrapper.find('button.mock-test-preview-close').exists()).toBe(false);
117
- });
118
-
119
- it('does not auto-open for a template that is not approved', () => {
120
- const wrapper = renderEdit({ openTestAndPreview: true }, 'pending');
121
- expect(wrapper.find('button.mock-test-preview-close').exists()).toBe(false);
122
- });
123
-
124
- it('keeps the editor open when Test & Preview was opened from the footer', () => {
125
- const wrapper = renderEdit({});
126
- wrapper.find('button.rcs-test-preview-btn').last().simulate('click');
127
- wrapper.update();
128
-
129
- wrapper.find('button.mock-test-preview-close').simulate('click');
130
- expect(handleClose).not.toHaveBeenCalled();
131
- });
132
- });
@@ -1,91 +0,0 @@
1
- import React from 'react';
2
- import { cloneDeep } from 'lodash';
3
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
4
- import { Provider } from 'react-redux';
5
- import history from '../../../utils/history';
6
- import { initialReducer } from '../../../initialReducer';
7
- import { mountWithIntl } from '../../../../app/helpers/intl-enzym-test-helpers';
8
- import { Whatsapp } from '../index';
9
- import { mockData } from './mockData';
10
-
11
- jest.mock('../../../v2Containers/TagList/index.js', () => ({
12
- __esModule: true,
13
- default: () => <div className="tag-mock">TagList</div>,
14
- }));
15
- // Stub exposes only open state + close action.
16
- jest.mock('../../../v2Components/TestAndPreviewSlidebox', () => ({
17
- __esModule: true,
18
- default: ({ show, onClose }) => (show ? <button type="button" className="mock-test-preview-close" onClick={onClose} /> : null),
19
- }));
20
-
21
- let store;
22
- beforeAll(() => {
23
- store = configureStore({}, initialReducer, history);
24
- });
25
-
26
- describe('Whatsapp - Preview and test from listing', () => {
27
- const handleClose = jest.fn();
28
-
29
- // Fresh fixture per render: the editor mutates nested template data.
30
- const renderEdit = (templateData, editData = cloneDeep(mockData.editData1)) => {
31
- const wrapper = mountWithIntl(
32
- <Provider store={store}>
33
- <Whatsapp
34
- actions={{
35
- createWhatsappTemplate: jest.fn(),
36
- clearCreateResponse: jest.fn(),
37
- getTemplateDetails: jest.fn(),
38
- resetEditTemplate: jest.fn(),
39
- getMetaTags: jest.fn(),
40
- resetMetaTags: jest.fn(),
41
- }}
42
- globalActions={{ fetchSchemaForEntity: jest.fn() }}
43
- onCreateComplete={jest.fn()}
44
- handleClose={handleClose}
45
- getFormData={jest.fn()}
46
- params={{ id: editData.templateDetails._id }}
47
- editData={editData}
48
- templateData={templateData}
49
- accountData={mockData.accountData1}
50
- location={mockData.location}
51
- intl={{ formatMessage: jest.fn() }}
52
- isFullMode
53
- loadingTags={false}
54
- metaEntities={[]}
55
- getDefaultTags
56
- Templates={{}}
57
- />
58
- </Provider>,
59
- );
60
- wrapper.update();
61
- return wrapper;
62
- };
63
-
64
- it('auto-opens Test & Preview for an approved template and returns to the listing on close', () => {
65
- const wrapper = renderEdit({ openTestAndPreview: true });
66
- const closeButton = wrapper.find('button.mock-test-preview-close');
67
- expect(closeButton.exists()).toBe(true);
68
-
69
- closeButton.simulate('click');
70
- expect(handleClose).toHaveBeenCalledTimes(1);
71
- });
72
-
73
- it('does not auto-open without the listing flag', () => {
74
- const wrapper = renderEdit({});
75
- expect(wrapper.find('button.mock-test-preview-close').exists()).toBe(false);
76
- });
77
-
78
- it('does not auto-open for a template that is not approved', () => {
79
- const wrapper = renderEdit({ openTestAndPreview: true }, cloneDeep(mockData.editData2));
80
- expect(wrapper.find('button.mock-test-preview-close').exists()).toBe(false);
81
- });
82
-
83
- it('keeps the editor open when Test & Preview was opened from the footer', () => {
84
- const wrapper = renderEdit({});
85
- wrapper.find('button.whatsapp-test-preview-btn').simulate('click');
86
- wrapper.update();
87
-
88
- wrapper.find('button.mock-test-preview-close').simulate('click');
89
- expect(handleClose).not.toHaveBeenCalled();
90
- });
91
- });
@@ -1,98 +0,0 @@
1
- import React from 'react';
2
- import { injectIntl } from 'react-intl';
3
- import '@testing-library/jest-dom';
4
- import { Provider } from 'react-redux';
5
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
6
- import history from '../../../utils/history';
7
- import { initialReducer } from '../../../initialReducer';
8
- import { Zalo } from '..';
9
- import { SUCCESS } from '../constants';
10
- import { metaEntities, location, getDefaultTags, injectedTags, accountData } from './mockData';
11
- import { render, screen, fireEvent } from '../../../utils/test-utils';
12
-
13
- jest.mock('../../../v2Containers/TagList/index.js', () => ({
14
- __esModule: true,
15
- default: () => <div className="tag-mock">TagList</div>,
16
- }));
17
- // Stub exposes only open state + close action.
18
- jest.mock('../../../v2Components/TestAndPreviewSlidebox', () => ({
19
- __esModule: true,
20
- default: ({ show, onClose }) => (show ? <button type="button" data-testid="mock-test-preview-close" onClick={onClose} /> : null),
21
- }));
22
-
23
- let store;
24
- beforeAll(() => {
25
- store = configureStore({}, initialReducer, history);
26
- });
27
-
28
- const buildEditData = () => ({
29
- zaloTemplateInfoStatus: SUCCESS,
30
- zaloTemplateInfoValue: {
31
- _id: 'zalo_1',
32
- name: 'Zalo Template',
33
- versions: {
34
- base: {
35
- content: {
36
- zalo: {
37
- templateId: '1',
38
- listParams: [
39
- { name: 'danh_xung', require: true, type: 'STRING', maxLength: 30, minLength: 0, error: '', value: '' },
40
- ],
41
- previewUrl: 'https://account.zalo.cloud/preview',
42
- status: 'ENABLE',
43
- },
44
- },
45
- },
46
- },
47
- },
48
- zaloTemplateInfoError: null,
49
- });
50
-
51
- const ComponentToRender = injectIntl(Zalo);
52
-
53
- describe('Zalo - Preview and test from listing', () => {
54
- const handleClose = jest.fn();
55
- const handleTestAndPreview = jest.fn();
56
-
57
- const renderZalo = (templateData) => render(
58
- <Provider store={store}>
59
- <ComponentToRender
60
- actions={{ getTemplateInfoById: jest.fn(), resetTemplateInfoData: jest.fn() }}
61
- globalActions={{ fetchSchemaForEntity: jest.fn() }}
62
- editData={buildEditData()}
63
- metaEntities={metaEntities}
64
- location={location}
65
- getDefaultTags={getDefaultTags}
66
- injectedTags={injectedTags}
67
- accountData={accountData}
68
- templateData={templateData}
69
- isFullMode
70
- handleClose={handleClose}
71
- handleTestAndPreview={handleTestAndPreview}
72
- />
73
- </Provider>,
74
- );
75
-
76
- it('auto-opens Test & Preview and returns to the listing on close', async () => {
77
- renderZalo({ _id: 'zalo_1', templateConfigs: { id: '', varMapped: {} }, openTestAndPreview: true });
78
- const closeButton = await screen.findByTestId('mock-test-preview-close');
79
- expect(handleTestAndPreview).toHaveBeenCalledTimes(1);
80
-
81
- fireEvent.click(closeButton);
82
- expect(handleClose).toHaveBeenCalledTimes(1);
83
- });
84
-
85
- it('does not auto-open without the listing flag', () => {
86
- renderZalo({ _id: 'zalo_1', templateConfigs: { id: '', varMapped: {} } });
87
- expect(screen.queryByTestId('mock-test-preview-close')).not.toBeInTheDocument();
88
- expect(handleTestAndPreview).not.toHaveBeenCalled();
89
- });
90
-
91
- it('keeps the editor open when Test & Preview was opened from the footer', async () => {
92
- const { container } = renderZalo({ _id: 'zalo_1', templateConfigs: { id: '', varMapped: {} } });
93
- fireEvent.click(container.querySelector('.test-and-preview-button-zalo'));
94
-
95
- fireEvent.click(await screen.findByTestId('mock-test-preview-close'));
96
- expect(handleClose).not.toHaveBeenCalled();
97
- });
98
- });