@capillarytech/creatives-library 8.0.309 → 8.0.310

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 (79) hide show
  1. package/constants/unified.js +1 -5
  2. package/initialState.js +2 -0
  3. package/package.json +1 -1
  4. package/services/api.js +0 -17
  5. package/services/tests/api.test.js +0 -85
  6. package/utils/common.js +8 -5
  7. package/utils/commonUtils.js +93 -46
  8. package/utils/tagValidations.js +223 -83
  9. package/utils/tests/commonUtil.test.js +124 -316
  10. package/utils/tests/tagValidations.test.js +358 -441
  11. package/v2Components/CommonTestAndPreview/SendTestMessage.js +49 -78
  12. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -134
  13. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  14. package/v2Components/CommonTestAndPreview/constants.js +1 -15
  15. package/v2Components/CommonTestAndPreview/index.js +19 -80
  16. package/v2Components/CommonTestAndPreview/messages.js +0 -94
  17. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  18. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -53
  19. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  20. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -36
  21. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  22. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -377
  23. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  24. package/v2Components/ErrorInfoNote/index.js +5 -2
  25. package/v2Components/FormBuilder/index.js +203 -137
  26. package/v2Components/FormBuilder/messages.js +8 -0
  27. package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
  28. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
  30. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
  31. package/v2Containers/Cap/mockData.js +14 -0
  32. package/v2Containers/Cap/reducer.js +55 -3
  33. package/v2Containers/Cap/tests/reducer.test.js +102 -0
  34. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
  35. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
  36. package/v2Containers/CreativesContainer/constants.js +0 -6
  37. package/v2Containers/CreativesContainer/index.js +7 -47
  38. package/v2Containers/Email/index.js +5 -1
  39. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
  40. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +120 -20
  41. package/v2Containers/FTP/index.js +51 -2
  42. package/v2Containers/FTP/messages.js +4 -0
  43. package/v2Containers/InApp/index.js +107 -35
  44. package/v2Containers/InApp/tests/index.test.js +6 -17
  45. package/v2Containers/InappAdvance/index.js +112 -4
  46. package/v2Containers/InappAdvance/tests/index.test.js +0 -2
  47. package/v2Containers/Line/Container/Text/index.js +1 -0
  48. package/v2Containers/MobilePush/Create/index.js +19 -59
  49. package/v2Containers/MobilePush/Edit/index.js +20 -48
  50. package/v2Containers/MobilePushNew/index.js +32 -12
  51. package/v2Containers/MobilepushWrapper/index.js +1 -3
  52. package/v2Containers/Rcs/index.js +37 -12
  53. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1276 -1408
  54. package/v2Containers/Sms/Create/index.js +3 -39
  55. package/v2Containers/Sms/Create/messages.js +0 -4
  56. package/v2Containers/Sms/Edit/index.js +3 -35
  57. package/v2Containers/Sms/commonMethods.js +6 -3
  58. package/v2Containers/SmsTrai/Edit/index.js +47 -11
  59. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +294 -327
  60. package/v2Containers/SmsWrapper/index.js +0 -2
  61. package/v2Containers/TemplatesV2/index.js +13 -28
  62. package/v2Containers/Viber/index.js +1 -0
  63. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
  64. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
  65. package/v2Containers/WebPush/Create/index.js +2 -2
  66. package/v2Containers/WebPush/Create/utils/validation.js +8 -17
  67. package/v2Containers/WebPush/Create/utils/validation.test.js +24 -44
  68. package/v2Containers/Whatsapp/index.js +17 -9
  69. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5246
  70. package/v2Containers/Zalo/index.js +11 -3
  71. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  72. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -284
  73. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -72
  74. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  75. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -657
  76. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +0 -172
  77. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -466
  78. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  79. package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
@@ -1,114 +0,0 @@
1
- /**
2
- * Unit tests for ExistingCustomerModal
3
- */
4
-
5
- import React from 'react';
6
- import { render, screen, fireEvent } from '@testing-library/react';
7
- import { IntlProvider } from 'react-intl';
8
- import PropTypes from 'prop-types';
9
- import ExistingCustomerModal from '../ExistingCustomerModal';
10
- import { CHANNELS, CUSTOMER_MODAL_EXISTING } from '../constants';
11
-
12
- const mockMessages = {
13
- 'app.v2Components.TestAndPreviewSlidebox.customerCreationModalTitle': 'Add new test customer',
14
- 'app.v2Components.TestAndPreviewSlidebox.existingCustomerModalDescription': 'This user profile already exists in the system.',
15
- 'app.v2Components.TestAndPreviewSlidebox.saveButton': 'Save',
16
- 'app.v2Components.TestAndPreviewSlidebox.cancelButton': 'Cancel',
17
- 'app.v2Components.TestAndPreviewSlidebox.customerEmail': 'Email',
18
- 'app.v2Components.TestAndPreviewSlidebox.customerMobileNumber': 'Mobile Number',
19
- 'app.v2Components.TestAndPreviewSlidebox.customerID': 'Customer ID',
20
- };
21
-
22
- const TestWrapper = ({ children }) => (
23
- <IntlProvider locale="en" messages={mockMessages}>
24
- {children}
25
- </IntlProvider>
26
- );
27
- TestWrapper.propTypes = { children: PropTypes.node };
28
-
29
- describe('ExistingCustomerModal', () => {
30
- const defaultProps = {
31
- customerModal: [true, CUSTOMER_MODAL_EXISTING],
32
- setCustomerModal: jest.fn(),
33
- customerData: { name: 'John Doe', email: 'john@example.com', mobile: '', customerId: 'cust-123' },
34
- channel: CHANNELS.EMAIL,
35
- onSave: jest.fn(),
36
- };
37
-
38
- beforeEach(() => {
39
- jest.clearAllMocks();
40
- });
41
-
42
- it('renders modal with customer details when visible', () => {
43
- render(
44
- <TestWrapper>
45
- <ExistingCustomerModal {...defaultProps} />
46
- </TestWrapper>
47
- );
48
- expect(screen.getByText(/add new test customer/i)).toBeTruthy();
49
- expect(screen.getByText(/this user profile already exists/i)).toBeTruthy();
50
- expect(screen.getByText('John Doe')).toBeTruthy();
51
- expect(screen.getByText(/john@example.com/)).toBeTruthy();
52
- expect(screen.getByText(/cust-123/)).toBeTruthy();
53
- expect(screen.getByRole('button', { name: /save/i })).toBeTruthy();
54
- expect(screen.getByRole('button', { name: /cancel/i })).toBeTruthy();
55
- });
56
-
57
- it('shows mobile when channel is SMS', () => {
58
- render(
59
- <TestWrapper>
60
- <ExistingCustomerModal
61
- {...defaultProps}
62
- channel={CHANNELS.SMS}
63
- customerData={{ name: 'Jane', email: '', mobile: '9123456789', customerId: 'cust-456' }}
64
- />
65
- </TestWrapper>
66
- );
67
- expect(screen.getByText(/9123456789/)).toBeTruthy();
68
- });
69
-
70
- it('calls setCustomerModal when Cancel is clicked', () => {
71
- render(
72
- <TestWrapper>
73
- <ExistingCustomerModal {...defaultProps} />
74
- </TestWrapper>
75
- );
76
- fireEvent.click(screen.getByRole('button', { name: /cancel/i }));
77
- expect(defaultProps.setCustomerModal).toHaveBeenCalledWith([false, '']);
78
- });
79
-
80
- it('calls onSave when Save is clicked', () => {
81
- render(
82
- <TestWrapper>
83
- <ExistingCustomerModal {...defaultProps} />
84
- </TestWrapper>
85
- );
86
- fireEvent.click(screen.getByRole('button', { name: /save/i }));
87
- expect(defaultProps.onSave).toHaveBeenCalled();
88
- expect(defaultProps.onSave.mock.calls[0][0]).toEqual({});
89
- expect(typeof defaultProps.onSave.mock.calls[0][1]).toBe('function');
90
- });
91
-
92
- it('shows dash for missing name', () => {
93
- render(
94
- <TestWrapper>
95
- <ExistingCustomerModal {...defaultProps} customerData={{ name: '', email: 'a@b.co', mobile: '', customerId: 'c1' }} />
96
- </TestWrapper>
97
- );
98
- expect(screen.getByText('-')).toBeTruthy();
99
- });
100
-
101
- it('does not show email row when channel is EMAIL but customerData.email is empty', () => {
102
- render(
103
- <TestWrapper>
104
- <ExistingCustomerModal
105
- {...defaultProps}
106
- customerData={{ name: 'No Email', email: '', mobile: '', customerId: 'c2' }}
107
- />
108
- </TestWrapper>
109
- );
110
- expect(screen.getByText('No Email')).toBeTruthy();
111
- expect(screen.getByText('Customer ID')).toBeTruthy();
112
- expect(screen.getByText('c2')).toBeTruthy();
113
- });
114
- });
@@ -1,122 +0,0 @@
1
- import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
2
- import { showError } from '../commonMethods';
3
-
4
- jest.mock('@capillarytech/cap-ui-library/CapNotification', () => ({
5
- error: jest.fn(),
6
- }));
7
-
8
- jest.mock('../Create/messages', () => ({
9
- __esModule: true,
10
- default: {
11
- validationError: { defaultMessage: 'Validation error' },
12
- },
13
- }));
14
-
15
- describe('Sms commonMethods', () => {
16
- describe('showError', () => {
17
- beforeEach(() => {
18
- jest.clearAllMocks();
19
- });
20
-
21
- it('should call CapNotification.error when formData is not empty, isFormValid is false, and errorData has at least one true value', () => {
22
- const context = {
23
- props: {
24
- intl: { formatMessage: jest.fn((msg) => msg.defaultMessage || 'Validation error') },
25
- },
26
- state: {
27
- formData: { message: 'test' },
28
- isFormValid: false,
29
- errorData: [{ message: true }],
30
- },
31
- };
32
- showError.call(context);
33
- expect(CapNotification.error).toHaveBeenCalledWith({
34
- key: 'validation-error',
35
- message: 'Validation error',
36
- });
37
- });
38
-
39
- it('should not call CapNotification.error when formData is empty', () => {
40
- const context = {
41
- props: { intl: { formatMessage: jest.fn() } },
42
- state: {
43
- formData: {},
44
- isFormValid: false,
45
- errorData: [{ message: true }],
46
- },
47
- };
48
- showError.call(context);
49
- expect(CapNotification.error).not.toHaveBeenCalled();
50
- });
51
-
52
- it('should not call CapNotification.error when isFormValid is true', () => {
53
- const context = {
54
- props: { intl: { formatMessage: jest.fn() } },
55
- state: {
56
- formData: { message: 'test' },
57
- isFormValid: true,
58
- errorData: [{ message: true }],
59
- },
60
- };
61
- showError.call(context);
62
- expect(CapNotification.error).not.toHaveBeenCalled();
63
- });
64
-
65
- it('should not call CapNotification.error when no errorData entry has a true value', () => {
66
- const context = {
67
- props: { intl: { formatMessage: jest.fn() } },
68
- state: {
69
- formData: { message: 'test' },
70
- isFormValid: false,
71
- errorData: [{ message: false, title: false }],
72
- },
73
- };
74
- showError.call(context);
75
- expect(CapNotification.error).not.toHaveBeenCalled();
76
- });
77
-
78
- it('should not call CapNotification.error when errorData is empty', () => {
79
- const context = {
80
- props: { intl: { formatMessage: jest.fn() } },
81
- state: {
82
- formData: { message: 'test' },
83
- isFormValid: false,
84
- errorData: [],
85
- },
86
- };
87
- showError.call(context);
88
- expect(CapNotification.error).not.toHaveBeenCalled();
89
- });
90
-
91
- it('should not call CapNotification.error when errorData[0] is undefined', () => {
92
- const context = {
93
- props: { intl: { formatMessage: jest.fn() } },
94
- state: {
95
- formData: { message: 'test' },
96
- isFormValid: false,
97
- errorData: [],
98
- },
99
- };
100
- showError.call(context);
101
- expect(CapNotification.error).not.toHaveBeenCalled();
102
- });
103
-
104
- it('should call CapNotification.error when errorData[0] has multiple keys and one is true', () => {
105
- const context = {
106
- props: {
107
- intl: { formatMessage: jest.fn((msg) => msg.defaultMessage || 'Validation error') },
108
- },
109
- state: {
110
- formData: { message: 'hello' },
111
- isFormValid: false,
112
- errorData: [{ message: false, title: true }],
113
- },
114
- };
115
- showError.call(context);
116
- expect(CapNotification.error).toHaveBeenCalledWith({
117
- key: 'validation-error',
118
- message: 'Validation error',
119
- });
120
- });
121
- });
122
- });