@capillarytech/creatives-library 8.0.330-alpha.0 → 8.0.330

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 (122) hide show
  1. package/constants/unified.js +0 -18
  2. package/package.json +1 -1
  3. package/services/api.js +0 -17
  4. package/services/tests/api.test.js +0 -85
  5. package/utils/commonUtils.js +0 -28
  6. package/utils/tests/commonUtil.test.js +0 -169
  7. package/v2Components/CapTagList/index.js +0 -10
  8. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  13. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  14. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  15. package/v2Components/CommonTestAndPreview/SendTestMessage.js +53 -87
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
  17. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  18. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -145
  19. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  20. package/v2Components/CommonTestAndPreview/constants.js +1 -53
  21. package/v2Components/CommonTestAndPreview/index.js +168 -998
  22. package/v2Components/CommonTestAndPreview/messages.js +3 -147
  23. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  24. package/v2Components/CommonTestAndPreview/sagas.js +6 -15
  25. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +286 -328
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  27. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  28. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  29. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +24 -65
  30. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  31. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  32. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -168
  33. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  34. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  35. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  36. package/v2Components/FormBuilder/index.js +1 -7
  37. package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
  38. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  39. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  40. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  41. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
  42. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  43. package/v2Containers/CreativesContainer/constants.js +0 -9
  44. package/v2Containers/CreativesContainer/index.js +93 -292
  45. package/v2Containers/CreativesContainer/index.scss +1 -51
  46. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  47. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  48. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  49. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  50. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
  51. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  52. package/v2Containers/Rcs/constants.js +3 -40
  53. package/v2Containers/Rcs/index.js +895 -1145
  54. package/v2Containers/Rcs/index.scss +6 -85
  55. package/v2Containers/Rcs/messages.js +2 -12
  56. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +2236 -41719
  57. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  58. package/v2Containers/Rcs/tests/index.test.js +38 -41
  59. package/v2Containers/Rcs/tests/mockData.js +0 -38
  60. package/v2Containers/Rcs/tests/utils.test.js +1 -435
  61. package/v2Containers/Rcs/utils.js +10 -405
  62. package/v2Containers/Sms/Create/index.js +38 -100
  63. package/v2Containers/SmsTrai/Create/index.js +4 -9
  64. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  65. package/v2Containers/SmsTrai/Edit/index.js +128 -636
  66. package/v2Containers/SmsTrai/Edit/messages.js +4 -14
  67. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2604 -4590
  68. package/v2Containers/SmsWrapper/index.js +8 -37
  69. package/v2Containers/TagList/index.js +0 -6
  70. package/v2Containers/Templates/_templates.scss +2 -63
  71. package/v2Containers/Templates/actions.js +0 -11
  72. package/v2Containers/Templates/constants.js +0 -2
  73. package/v2Containers/Templates/index.js +40 -90
  74. package/v2Containers/Templates/sagas.js +12 -57
  75. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
  76. package/v2Containers/Templates/tests/sagas.test.js +123 -193
  77. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  78. package/v2Containers/TemplatesV2/index.js +23 -86
  79. package/v2Containers/Whatsapp/index.js +20 -3
  80. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5790
  81. package/utils/templateVarUtils.js +0 -201
  82. package/utils/tests/templateVarUtils.test.js +0 -204
  83. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  84. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -155
  85. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -93
  86. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  87. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  88. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -648
  89. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -174
  90. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  91. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  92. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  93. package/v2Components/SmsFallback/constants.js +0 -73
  94. package/v2Components/SmsFallback/index.js +0 -955
  95. package/v2Components/SmsFallback/index.scss +0 -265
  96. package/v2Components/SmsFallback/messages.js +0 -78
  97. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
  98. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  99. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  100. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  101. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  102. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
  103. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  104. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  105. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  106. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  107. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  108. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  109. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  110. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  111. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  112. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  113. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
  114. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
  115. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  116. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  117. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  118. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  119. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  120. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  121. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  122. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -1,174 +0,0 @@
1
- /**
2
- * Unit tests for CustomerCreationModal
3
- *
4
- * Email/mobile are read-only; lookup runs in parent (index.js) before the modal opens.
5
- */
6
-
7
- import React from 'react';
8
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
9
- import { IntlProvider } from 'react-intl';
10
- import PropTypes from 'prop-types';
11
- import CustomerCreationModal from '../CustomerCreationModal';
12
- import { CHANNELS, CUSTOMER_MODAL_NEW } from '../constants';
13
-
14
- const mockMessages = {
15
- 'app.v2Components.TestAndPreviewSlidebox.customerCreationModalTitle': 'Add new test customer',
16
- 'app.v2Components.TestAndPreviewSlidebox.customerCreationModalDescription': 'This customer profile will be available for testing.',
17
- 'app.v2Components.TestAndPreviewSlidebox.customerName': 'Name',
18
- 'app.v2Components.TestAndPreviewSlidebox.customerNameOptional': '(Optional)',
19
- 'app.v2Components.TestAndPreviewSlidebox.customerNamePlaceholder': 'Enter the name',
20
- 'app.v2Components.TestAndPreviewSlidebox.customerEmailPlaceholder': 'Enter the Email',
21
- 'app.v2Components.TestAndPreviewSlidebox.customerMobilePlaceholder': 'Enter the Mobile Number',
22
- 'app.v2Components.TestAndPreviewSlidebox.saveButton': 'Save',
23
- 'app.v2Components.TestAndPreviewSlidebox.cancelButton': 'Cancel',
24
- 'app.v2Components.TestAndPreviewSlidebox.customerEmail': 'Email',
25
- 'app.v2Components.TestAndPreviewSlidebox.customerMobileNumber': 'Mobile Number',
26
- };
27
-
28
- const TestWrapper = ({ children }) => (
29
- <IntlProvider locale="en" messages={mockMessages}>
30
- {children}
31
- </IntlProvider>
32
- );
33
- TestWrapper.propTypes = { children: PropTypes.node };
34
-
35
- describe('CustomerCreationModal', () => {
36
- const defaultProps = {
37
- customerModal: [true, CUSTOMER_MODAL_NEW],
38
- onCloseCustomerModal: jest.fn(),
39
- channel: CHANNELS.EMAIL,
40
- customerData: { name: '', email: '', mobile: '' },
41
- setCustomerData: jest.fn(),
42
- onSave: jest.fn(),
43
- };
44
-
45
- beforeEach(() => {
46
- jest.clearAllMocks();
47
- });
48
-
49
- it('renders modal with title and form fields when visible (EMAIL)', () => {
50
- render(
51
- <TestWrapper>
52
- <CustomerCreationModal {...defaultProps} channel={CHANNELS.EMAIL} />
53
- </TestWrapper>
54
- );
55
- expect(screen.getByText(/add new test customer/i)).toBeTruthy();
56
- expect(screen.getByPlaceholderText(/enter the name/i)).toBeTruthy();
57
- expect(screen.getByPlaceholderText(/enter the email/i)).toBeTruthy();
58
- expect(screen.queryByPlaceholderText(/enter the mobile number/i)).toBeNull();
59
- expect(screen.getByRole('button', { name: /save/i })).toBeTruthy();
60
- expect(screen.getByRole('button', { name: /cancel/i })).toBeTruthy();
61
- });
62
-
63
- it('renders mobile field when channel is SMS', () => {
64
- render(
65
- <TestWrapper>
66
- <CustomerCreationModal
67
- {...defaultProps}
68
- channel={CHANNELS.SMS}
69
- customerData={{ name: '', email: '', mobile: '' }}
70
- />
71
- </TestWrapper>
72
- );
73
- expect(screen.getByPlaceholderText(/enter the mobile number/i)).toBeTruthy();
74
- expect(screen.queryByPlaceholderText(/enter the email/i)).toBeNull();
75
- });
76
-
77
- it('calls onCloseCustomerModal when Cancel is clicked', () => {
78
- render(
79
- <TestWrapper>
80
- <CustomerCreationModal {...defaultProps} />
81
- </TestWrapper>
82
- );
83
- fireEvent.click(screen.getByRole('button', { name: /cancel/i }));
84
- expect(defaultProps.onCloseCustomerModal).toHaveBeenCalled();
85
- });
86
-
87
- it('calls setCustomerData when name input changes', () => {
88
- render(
89
- <TestWrapper>
90
- <CustomerCreationModal {...defaultProps} />
91
- </TestWrapper>
92
- );
93
- fireEvent.change(screen.getByPlaceholderText(/enter the name/i), { target: { value: 'John' } });
94
- expect(defaultProps.setCustomerData).toHaveBeenCalledWith(expect.objectContaining({ name: 'John' }));
95
- });
96
-
97
- it('calls onSave when Save is clicked with empty validation object', async () => {
98
- render(
99
- <TestWrapper>
100
- <CustomerCreationModal {...defaultProps} customerData={{ name: '', email: 'a@b.co', mobile: '' }} />
101
- </TestWrapper>
102
- );
103
- const saveBtn = screen.getByRole('button', { name: /save/i });
104
- fireEvent.click(saveBtn);
105
- await waitFor(() => expect(defaultProps.onSave).toHaveBeenCalled());
106
- expect(defaultProps.onSave).toHaveBeenCalledWith(
107
- { email: '', mobile: '' },
108
- expect.any(Function),
109
- );
110
- });
111
-
112
- it('disables Save when required email is missing (EMAIL channel)', () => {
113
- render(
114
- <TestWrapper>
115
- <CustomerCreationModal
116
- {...defaultProps}
117
- channel={CHANNELS.EMAIL}
118
- customerData={{ name: '', email: '', mobile: '' }}
119
- />
120
- </TestWrapper>
121
- );
122
- const saveBtn = screen.getByRole('button', { name: /save/i });
123
- expect(saveBtn.disabled).toBe(true);
124
- });
125
-
126
- it('disables Save when required mobile is missing (SMS channel)', () => {
127
- render(
128
- <TestWrapper>
129
- <CustomerCreationModal
130
- {...defaultProps}
131
- channel={CHANNELS.SMS}
132
- customerData={{ name: '', email: '', mobile: '' }}
133
- />
134
- </TestWrapper>
135
- );
136
- const saveBtn = screen.getByRole('button', { name: /save/i });
137
- expect(saveBtn.disabled).toBe(true);
138
- });
139
-
140
- it('shows (Optional) on name label when channel is SMS', () => {
141
- render(
142
- <TestWrapper>
143
- <CustomerCreationModal
144
- {...defaultProps}
145
- channel={CHANNELS.SMS}
146
- customerData={{ name: '', email: '', mobile: '' }}
147
- />
148
- </TestWrapper>
149
- );
150
- expect(screen.getAllByText(/\(optional\)/i)).toHaveLength(1);
151
- });
152
-
153
- it('shows (Optional) on name label when channel is EMAIL', () => {
154
- render(
155
- <TestWrapper>
156
- <CustomerCreationModal
157
- {...defaultProps}
158
- channel={CHANNELS.EMAIL}
159
- customerData={{ name: '', email: '', mobile: '' }}
160
- />
161
- </TestWrapper>
162
- );
163
- expect(screen.getAllByText(/\(optional\)/i)).toHaveLength(1);
164
- });
165
-
166
- it('renders modal description', () => {
167
- render(
168
- <TestWrapper>
169
- <CustomerCreationModal {...defaultProps} />
170
- </TestWrapper>
171
- );
172
- expect(screen.getByText(/this customer profile will be available for testing/i)).toBeTruthy();
173
- });
174
- });
@@ -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
- onCloseCustomerModal: 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 onCloseCustomerModal 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.onCloseCustomerModal).toHaveBeenCalled();
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,67 +0,0 @@
1
- import {
2
- normalizePreviewApiPayload,
3
- extractPreviewFromLiquidResponse,
4
- getSmsFallbackTextForTagExtraction,
5
- } from '../previewApiUtils';
6
- import { RCS_SMS_FALLBACK_VAR_MAPPED_PROP } from '../constants';
7
-
8
- describe('previewApiUtils', () => {
9
- describe('normalizePreviewApiPayload', () => {
10
- it('maps messageBody to resolvedBody when resolvedBody is missing', () => {
11
- expect(normalizePreviewApiPayload({ messageBody: 'Hello' }).resolvedBody).toBe('Hello');
12
- });
13
- });
14
-
15
- describe('extractPreviewFromLiquidResponse', () => {
16
- it('accepts nested data shape', () => {
17
- const r = { data: { resolvedBody: 'ok' } };
18
- expect(extractPreviewFromLiquidResponse(r)).toEqual({ resolvedBody: 'ok' });
19
- });
20
-
21
- it('accepts top-level preview (typical SMS)', () => {
22
- const r = { messageBody: 'sms text' };
23
- expect(extractPreviewFromLiquidResponse(r)).toMatchObject({
24
- messageBody: 'sms text',
25
- resolvedBody: 'sms text',
26
- });
27
- });
28
-
29
- it('returns null when errors array is non-empty', () => {
30
- expect(extractPreviewFromLiquidResponse({ errors: [{ code: 1 }] })).toBeNull();
31
- });
32
- });
33
-
34
- describe('getSmsFallbackTextForTagExtraction', () => {
35
- it('returns empty string when context is missing or has no template body', () => {
36
- expect(getSmsFallbackTextForTagExtraction(null)).toBe('');
37
- expect(getSmsFallbackTextForTagExtraction({})).toBe('');
38
- expect(getSmsFallbackTextForTagExtraction({ templateContent: '', content: '' })).toBe('');
39
- });
40
-
41
- it('returns raw template when rcsSmsFallbackVarMapped is absent or empty', () => {
42
- const raw = '{{optout}} {{fullname}} test SMS';
43
- expect(getSmsFallbackTextForTagExtraction({ templateContent: raw })).toBe(raw);
44
- expect(getSmsFallbackTextForTagExtraction({
45
- content: raw,
46
- [RCS_SMS_FALLBACK_VAR_MAPPED_PROP]: {},
47
- })).toBe(raw);
48
- });
49
-
50
- it('prefers templateContent over content when both are set', () => {
51
- expect(getSmsFallbackTextForTagExtraction({
52
- templateContent: 'A',
53
- content: 'B',
54
- })).toBe('A');
55
- });
56
-
57
- it('applies VarSegment slot map so preview / meta payloads are not stale vs raw template', () => {
58
- const rawTemplateWithSlots = '{{optout}} tail';
59
- const rcsSmsFallbackVarMappedSlots = { '{{optout}}_0': 'STOP' };
60
- const resolvedFallbackText = getSmsFallbackTextForTagExtraction({
61
- templateContent: rawTemplateWithSlots,
62
- [RCS_SMS_FALLBACK_VAR_MAPPED_PROP]: rcsSmsFallbackVarMappedSlots,
63
- });
64
- expect(resolvedFallbackText).toBe('STOP tail');
65
- });
66
- });
67
- });
@@ -1,87 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import CreativesContainer from '../../v2Containers/CreativesContainer';
4
- import CapPageSpinner from '../CapPageSpinner';
5
- import {
6
- EMBEDDED_SMS_CREATIVES_LOCATION,
7
- SMS_FALLBACK_CHANNEL_KEY,
8
- SMS_FALLBACK_CREATIVE_EDITOR,
9
- SMS_FALLBACK_ENABLE_NEW_CHANNELS,
10
- } from './constants';
11
-
12
- /**
13
- * Reuse the exact embedded CreativesContainer SMS flow (same as normal SMS create).
14
- * Avoid overriding Templates with local config so "Create new" follows built-in createTemplate path.
15
- */
16
- export function SmsFallbackLocalSelector({
17
- hidden,
18
- fetchDetailsLoading,
19
- templateList,
20
- channelsToHide,
21
- smsRegister,
22
- onCloseCreatives,
23
- onSelectTemplate,
24
- filterContent,
25
- location,
26
- /** Required when user completes embedded SMS create/edit — `CreativesContainer` calls this on save (see `processCentralCommsMetaId`). */
27
- getCreativesData,
28
- }) {
29
- const rootClassName = [
30
- 'sms-fallback-selector',
31
- hidden ? 'sms-fallback-selector--visually-hidden' : '',
32
- ]
33
- .filter(Boolean)
34
- .join(' ');
35
-
36
- return (
37
- <div className={rootClassName}>
38
- {fetchDetailsLoading && (
39
- <div className="sms-fallback-selector__loading" aria-busy="true" aria-live="polite">
40
- <CapPageSpinner spinning />
41
- </div>
42
- )}
43
- <CreativesContainer
44
- creativesMode="create"
45
- location={location || EMBEDDED_SMS_CREATIVES_LOCATION}
46
- templateData={null}
47
- handleCloseCreatives={onCloseCreatives}
48
- isFullMode={false}
49
- smsRegister={smsRegister}
50
- editor={SMS_FALLBACK_CREATIVE_EDITOR}
51
- enableNewChannels={SMS_FALLBACK_ENABLE_NEW_CHANNELS}
52
- channel={SMS_FALLBACK_CHANNEL_KEY}
53
- channelsToHide={channelsToHide}
54
- selectedBadges={[]}
55
- localTemplatesConfig={{
56
- useLocalTemplates: true,
57
- localTemplates: templateList.templates,
58
- localTemplatesLoading: templateList.loading,
59
- localTemplatesFilterContent: filterContent,
60
- localTemplatesOnPageChange: templateList.loadMore,
61
- localTemplatesUseSkeleton: true,
62
- }}
63
- onSelectTemplate={onSelectTemplate}
64
- getCreativesData={getCreativesData}
65
- />
66
- </div>
67
- );
68
- }
69
-
70
- SmsFallbackLocalSelector.propTypes = {
71
- hidden: PropTypes.bool,
72
- fetchDetailsLoading: PropTypes.bool,
73
- templateList: PropTypes.shape({
74
- templates: PropTypes.array,
75
- loading: PropTypes.bool,
76
- loadMore: PropTypes.func,
77
- }).isRequired,
78
- channelsToHide: PropTypes.arrayOf(PropTypes.string),
79
- smsRegister: PropTypes.any,
80
- onCloseCreatives: PropTypes.func.isRequired,
81
- onSelectTemplate: PropTypes.func.isRequired,
82
- filterContent: PropTypes.node,
83
- location: PropTypes.object,
84
- getCreativesData: PropTypes.func.isRequired,
85
- };
86
-
87
- export default SmsFallbackLocalSelector;
@@ -1,73 +0,0 @@
1
- import {
2
- WHATSAPP,
3
- RCS,
4
- ZALO,
5
- WEBPUSH,
6
- } from '../../v2Containers/CreativesContainer/constants';
7
-
8
- /**
9
- * View modes for the SMS fallback slidebox (template list, create, edit).
10
- * Used by SmsFallback and any channel that reuses it (RCS, etc.).
11
- */
12
- export const SMS_FALLBACK_VIEW = {
13
- SELECTING: 'selecting',
14
- CREATING: 'creating',
15
- EDITING: 'editing',
16
- };
17
-
18
- /**
19
- * Channel keys to hide in TemplatesV2 so only SMS tab is shown.
20
- * Uses normalized keys matching TemplatesV2 pane.key normalization (lowercase).
21
- * Parent can override via channelsToHide prop.
22
- */
23
- export const CHANNELS_TO_HIDE_FOR_SMS_ONLY = [
24
- 'email',
25
- 'mobilepush',
26
- 'webpush',
27
- 'viber',
28
- 'whatsapp',
29
- 'zalo',
30
- 'facebook',
31
- 'rcs',
32
- 'inapp',
33
- 'line',
34
- 'wechat',
35
- 'call_task',
36
- 'ftp',
37
- 'assets',
38
- ];
39
-
40
- /** DLT category filter values — aligned with Templates `SMS_FILTERS` / `filterSMSTemplates`. */
41
- export const SMS_CATEGORY_FILTERS = {
42
- ALL: 'all',
43
- PROMOTIONAL: 'promo',
44
- SERVICE_EXPLICIT: 'explicit',
45
- SERVICE_IMPLICIT: 'implicit',
46
- };
47
-
48
- /** `location` for embedded SMS creatives picker (CreativesContainer / TemplatesV2). */
49
- export const EMBEDDED_SMS_CREATIVES_LOCATION = {
50
- pathname: '/sms/create',
51
- query: { type: 'embedded', module: 'library' },
52
- search: '',
53
- };
54
-
55
- /** `location` for embedded SMS TRAI edit inside slidebox. */
56
- export const EMBEDDED_SMS_CREATIVES_EDIT_LOCATION = {
57
- pathname: '/sms/edit',
58
- query: { type: 'embedded', module: 'library' },
59
- search: '',
60
- };
61
-
62
- /** API `channel` param for `getTemplateDetails` when loading an SMS template by id. */
63
- export const SMS_TEMPLATE_DETAILS_API_CHANNEL = 'Sms';
64
-
65
- export const SMS_FALLBACK_CREATIVE_EDITOR = 'BEE';
66
-
67
- export const SMS_FALLBACK_CHANNEL_KEY = 'sms';
68
-
69
- /** Route shape passed to SmsWrapper / SmsTraiEdit for embedded SMS flows. */
70
- export const SMS_FALLBACK_ROUTE = { name: SMS_FALLBACK_CHANNEL_KEY };
71
-
72
- /** Channels enabled in the SMS-only embedded picker (hide others via `channelsToHide`). */
73
- export const SMS_FALLBACK_ENABLE_NEW_CHANNELS = [WHATSAPP, RCS, ZALO, WEBPUSH];