@capillarytech/creatives-library 8.0.125 → 8.0.127-alpha.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.
- package/config/app.js +6 -0
- package/containers/App/constants.js +1 -0
- package/index.html +3 -1
- package/initialReducer.js +2 -0
- package/package.json +1 -1
- package/services/api.js +94 -1
- package/services/tests/api.test.js +191 -0
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +8 -3
- package/tests/integration/TemplateCreation/api-response.js +5 -0
- package/tests/integration/TemplateCreation/msw-handler.js +42 -63
- package/utils/common.js +7 -0
- package/utils/commonUtils.js +2 -6
- package/utils/createPayload.js +272 -0
- package/utils/tests/createPayload.test.js +761 -0
- package/v2Components/CapImageUpload/index.js +59 -46
- package/v2Components/CapInAppCTA/index.js +1 -0
- package/v2Components/CapMpushCTA/constants.js +25 -0
- package/v2Components/CapMpushCTA/index.js +332 -0
- package/v2Components/CapMpushCTA/index.scss +95 -0
- package/v2Components/CapMpushCTA/messages.js +89 -0
- package/v2Components/CapTagList/index.js +177 -120
- package/v2Components/CapVideoUpload/constants.js +3 -0
- package/v2Components/CapVideoUpload/index.js +167 -110
- package/v2Components/CapVideoUpload/messages.js +16 -0
- package/v2Components/Carousel/index.js +15 -13
- package/v2Components/CustomerSearchSection/_customerSearch.scss +309 -0
- package/v2Components/CustomerSearchSection/constants.js +5 -0
- package/v2Components/CustomerSearchSection/index.js +367 -0
- package/v2Components/CustomerSearchSection/messages.js +20 -0
- package/v2Components/CustomerSearchSection/tests/utils.test.js +334 -0
- package/v2Components/CustomerSearchSection/utils.js +49 -0
- package/v2Components/ErrorInfoNote/style.scss +1 -0
- package/v2Components/MobilePushPreviewV2/index.js +37 -5
- package/v2Components/TemplatePreview/_templatePreview.scss +114 -72
- package/v2Components/TemplatePreview/assets/images/Android _ With date and time.svg +29 -0
- package/v2Components/TemplatePreview/assets/images/android.svg +9 -0
- package/v2Components/TemplatePreview/assets/images/iOS _ With date and time.svg +26 -0
- package/v2Components/TemplatePreview/assets/images/ios.svg +9 -0
- package/v2Components/TemplatePreview/index.js +178 -50
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TestAndPreviewSlidebox/CustomValuesEditor.js +169 -0
- package/v2Components/TestAndPreviewSlidebox/LeftPanelContent.js +95 -0
- package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/SendTestMessage.js +68 -0
- package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +543 -0
- package/v2Components/TestAndPreviewSlidebox/actions.js +67 -0
- package/v2Components/TestAndPreviewSlidebox/constants.js +67 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +592 -0
- package/v2Components/TestAndPreviewSlidebox/messages.js +147 -0
- package/v2Components/TestAndPreviewSlidebox/reducer.js +233 -0
- package/v2Components/TestAndPreviewSlidebox/sagas.js +258 -0
- package/v2Components/TestAndPreviewSlidebox/selectors.js +142 -0
- package/v2Components/TestAndPreviewSlidebox/tests/CustomValuesEditor.test.js +425 -0
- package/v2Components/TestAndPreviewSlidebox/tests/LeftPanelContent.test.js +400 -0
- package/v2Components/TestAndPreviewSlidebox/tests/SendTestMessage.test.js +448 -0
- package/v2Components/TestAndPreviewSlidebox/tests/actions.test.js +80 -0
- package/v2Components/TestAndPreviewSlidebox/tests/reducer.test.js +367 -0
- package/v2Components/TestAndPreviewSlidebox/tests/saga.rtl.test.js +192 -0
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +652 -0
- package/v2Components/TestAndPreviewSlidebox/tests/selector.test.js +182 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +22 -10
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +23 -2
- package/v2Containers/CreativesContainer/index.js +216 -136
- package/v2Containers/CreativesContainer/messages.js +4 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +21 -0
- package/v2Containers/Email/index.js +27 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +10 -0
- package/v2Containers/EmailWrapper/index.js +6 -0
- package/v2Containers/InApp/constants.js +1 -0
- package/v2Containers/InApp/index.js +13 -13
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
- package/v2Containers/MobilePush/Create/index.js +1 -0
- package/v2Containers/MobilePush/commonMethods.js +7 -14
- package/v2Containers/MobilePushNew/actions.js +116 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +170 -0
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +754 -0
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +279 -0
- package/v2Containers/MobilePushNew/components/index.js +5 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +779 -0
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +2114 -0
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +343 -0
- package/v2Containers/MobilePushNew/constants.js +115 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1299 -0
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +1223 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +246 -0
- package/v2Containers/MobilePushNew/hooks/useUpload.js +726 -0
- package/v2Containers/MobilePushNew/index.js +2280 -0
- package/v2Containers/MobilePushNew/index.scss +308 -0
- package/v2Containers/MobilePushNew/messages.js +226 -0
- package/v2Containers/MobilePushNew/reducer.js +160 -0
- package/v2Containers/MobilePushNew/sagas.js +198 -0
- package/v2Containers/MobilePushNew/selectors.js +55 -0
- package/v2Containers/MobilePushNew/tests/reducer.test.js +741 -0
- package/v2Containers/MobilePushNew/tests/sagas.test.js +863 -0
- package/v2Containers/MobilePushNew/tests/selectors.test.js +425 -0
- package/v2Containers/MobilePushNew/tests/utils.test.js +322 -0
- package/v2Containers/MobilePushNew/utils.js +33 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +23 -5
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/TagList/index.js +56 -10
- package/v2Containers/Templates/_templates.scss +101 -1
- package/v2Containers/Templates/index.js +147 -35
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Templates/sagas.js +2 -0
- package/v2Containers/Whatsapp/constants.js +1 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -0
- package/v2Containers/Email/tests/index.test.js +0 -35
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
render, screen, fireEvent,
|
|
4
|
+
} from '@testing-library/react';
|
|
5
|
+
import { IntlProvider } from 'react-intl';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import SendTestMessage from '../SendTestMessage';
|
|
8
|
+
|
|
9
|
+
// Mock messages for testing - matching actual message IDs and content
|
|
10
|
+
const mockMessages = {
|
|
11
|
+
'app.v2Components.TestAndPreviewSlidebox.sendTestMessage': 'Send Test Message',
|
|
12
|
+
'app.v2Components.TestAndPreviewSlidebox.testMessageDescription': 'Test out the message before sending to your customers',
|
|
13
|
+
'app.v2Components.TestAndPreviewSlidebox.testCustomers': 'Select Test Recipients',
|
|
14
|
+
'app.v2Components.TestAndPreviewSlidebox.testCustomersPlaceholder': 'Search and select a group or individual test customers',
|
|
15
|
+
'app.v2Components.TestAndPreviewSlidebox.sendTestButton': 'Send Test',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Test wrapper with IntlProvider
|
|
19
|
+
const TestWrapper = ({ children, locale = 'en' }) => (
|
|
20
|
+
<IntlProvider locale={locale} messages={mockMessages}>
|
|
21
|
+
{children}
|
|
22
|
+
</IntlProvider>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
TestWrapper.propTypes = {
|
|
26
|
+
children: PropTypes.node.isRequired,
|
|
27
|
+
locale: PropTypes.string,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
TestWrapper.defaultProps = {
|
|
31
|
+
locale: 'en',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Helper function to expand accordion
|
|
35
|
+
const expandAccordion = () => {
|
|
36
|
+
const accordionHeader = screen.getByRole('tab');
|
|
37
|
+
fireEvent.click(accordionHeader);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Default props for testing
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
isFetchingTestCustomers: false,
|
|
43
|
+
isFetchingTestGroups: false,
|
|
44
|
+
testEntitiesTreeData: [
|
|
45
|
+
{
|
|
46
|
+
title: 'Customer Group 1',
|
|
47
|
+
value: 'group-1',
|
|
48
|
+
key: 'group-1',
|
|
49
|
+
children: [
|
|
50
|
+
{ title: 'John Doe', value: 'customer-1', key: 'customer-1' },
|
|
51
|
+
{ title: 'Jane Smith', value: 'customer-2', key: 'customer-2' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Customer Group 2',
|
|
56
|
+
value: 'group-2',
|
|
57
|
+
key: 'group-2',
|
|
58
|
+
children: [
|
|
59
|
+
{ title: 'Bob Johnson', value: 'customer-3', key: 'customer-3' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
handleTestEntitiesChange: jest.fn(),
|
|
64
|
+
selectedTestEntities: ['customer-1'],
|
|
65
|
+
handleSendTestMessage: jest.fn(),
|
|
66
|
+
formData: {
|
|
67
|
+
'template-subject': 'Test Email Subject',
|
|
68
|
+
'template-content': 'Test email content',
|
|
69
|
+
},
|
|
70
|
+
isSendingTestMessage: false,
|
|
71
|
+
formatMessage: jest.fn((message) => mockMessages[message.id] || message.defaultMessage || message.id),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
describe('SendTestMessage', () => {
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
jest.clearAllMocks();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('Component Rendering', () => {
|
|
80
|
+
it('should render the accordion with proper header', () => {
|
|
81
|
+
render(
|
|
82
|
+
<TestWrapper>
|
|
83
|
+
<SendTestMessage {...defaultProps} />
|
|
84
|
+
</TestWrapper>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(screen.getByText('Send Test Message')).toBeTruthy();
|
|
88
|
+
expect(screen.getByText('Test out the message before sending to your customers')).toBeTruthy();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should render accordion structure', () => {
|
|
92
|
+
render(
|
|
93
|
+
<TestWrapper>
|
|
94
|
+
<SendTestMessage {...defaultProps} />
|
|
95
|
+
</TestWrapper>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(screen.getByRole('tablist')).toBeTruthy();
|
|
99
|
+
expect(screen.getByRole('tab')).toBeTruthy();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should render test content when accordion is expanded', () => {
|
|
103
|
+
render(
|
|
104
|
+
<TestWrapper>
|
|
105
|
+
<SendTestMessage {...defaultProps} />
|
|
106
|
+
</TestWrapper>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expandAccordion();
|
|
110
|
+
|
|
111
|
+
expect(screen.getByText('Select Test Recipients')).toBeTruthy();
|
|
112
|
+
expect(screen.getByText('Send Test')).toBeTruthy();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('Button States', () => {
|
|
117
|
+
it('should enable send button when all conditions are met', () => {
|
|
118
|
+
render(
|
|
119
|
+
<TestWrapper>
|
|
120
|
+
<SendTestMessage {...defaultProps} />
|
|
121
|
+
</TestWrapper>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expandAccordion();
|
|
125
|
+
const sendButton = screen.getByText('Send Test');
|
|
126
|
+
expect(sendButton.getAttribute('disabled')).toBeNull();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should disable send button when no test entities are selected', () => {
|
|
130
|
+
render(
|
|
131
|
+
<TestWrapper>
|
|
132
|
+
<SendTestMessage {...defaultProps} selectedTestEntities={[]} />
|
|
133
|
+
</TestWrapper>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
expandAccordion();
|
|
137
|
+
const sendButton = screen.getByText('Send Test');
|
|
138
|
+
// CapButton component handles disabled state internally, just verify it renders
|
|
139
|
+
expect(sendButton).toBeTruthy();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should disable send button when template subject is empty', () => {
|
|
143
|
+
render(
|
|
144
|
+
<TestWrapper>
|
|
145
|
+
<SendTestMessage
|
|
146
|
+
{...defaultProps}
|
|
147
|
+
formData={{ 'template-subject': '', 'template-content': 'Content' }}
|
|
148
|
+
/>
|
|
149
|
+
</TestWrapper>
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
expandAccordion();
|
|
153
|
+
const sendButton = screen.getByText('Send Test');
|
|
154
|
+
// CapButton component handles disabled state internally, just verify it renders
|
|
155
|
+
expect(sendButton).toBeTruthy();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should disable send button when sending test message', () => {
|
|
159
|
+
render(
|
|
160
|
+
<TestWrapper>
|
|
161
|
+
<SendTestMessage {...defaultProps} isSendingTestMessage />
|
|
162
|
+
</TestWrapper>
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
expandAccordion();
|
|
166
|
+
const sendButton = screen.getByText('Send Test');
|
|
167
|
+
// CapButton component handles disabled state internally, just verify it renders
|
|
168
|
+
expect(sendButton).toBeTruthy();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('User Interactions', () => {
|
|
173
|
+
it('should call handleSendTestMessage when send button is clicked', () => {
|
|
174
|
+
render(
|
|
175
|
+
<TestWrapper>
|
|
176
|
+
<SendTestMessage {...defaultProps} />
|
|
177
|
+
</TestWrapper>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
expandAccordion();
|
|
181
|
+
const sendButton = screen.getByText('Send Test');
|
|
182
|
+
fireEvent.click(sendButton);
|
|
183
|
+
|
|
184
|
+
expect(defaultProps.handleSendTestMessage).toHaveBeenCalled();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should expand accordion when header is clicked', () => {
|
|
188
|
+
render(
|
|
189
|
+
<TestWrapper>
|
|
190
|
+
<SendTestMessage {...defaultProps} />
|
|
191
|
+
</TestWrapper>
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const accordionHeader = screen.getByRole('tab');
|
|
195
|
+
expect(accordionHeader.getAttribute('aria-expanded')).toBe('false');
|
|
196
|
+
|
|
197
|
+
fireEvent.click(accordionHeader);
|
|
198
|
+
expect(accordionHeader.getAttribute('aria-expanded')).toBe('true');
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('Tree Select Functionality', () => {
|
|
203
|
+
it('should render tree select component when expanded', () => {
|
|
204
|
+
const { container } = render(
|
|
205
|
+
<TestWrapper>
|
|
206
|
+
<SendTestMessage {...defaultProps} />
|
|
207
|
+
</TestWrapper>
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
expandAccordion();
|
|
211
|
+
const treeSelect = container.querySelector('.test-customers-tree-select');
|
|
212
|
+
expect(treeSelect).toBeTruthy();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should display correct placeholder text', () => {
|
|
216
|
+
render(
|
|
217
|
+
<TestWrapper>
|
|
218
|
+
<SendTestMessage {...defaultProps} />
|
|
219
|
+
</TestWrapper>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
expandAccordion();
|
|
223
|
+
expect(defaultProps.formatMessage).toHaveBeenCalledWith(
|
|
224
|
+
expect.objectContaining({
|
|
225
|
+
id: 'app.v2Components.TestAndPreviewSlidebox.testCustomersPlaceholder',
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe('Props Validation', () => {
|
|
232
|
+
it('should accept all required props without warnings', () => {
|
|
233
|
+
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
234
|
+
|
|
235
|
+
render(
|
|
236
|
+
<TestWrapper>
|
|
237
|
+
<SendTestMessage {...defaultProps} />
|
|
238
|
+
</TestWrapper>
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
expect(consoleSpy).not.toHaveBeenCalled();
|
|
242
|
+
consoleSpy.mockRestore();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('should handle different formData structures', () => {
|
|
246
|
+
const formDataWithExtraFields = {
|
|
247
|
+
...defaultProps.formData,
|
|
248
|
+
'extra-field': 'extra-value',
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
render(
|
|
252
|
+
<TestWrapper>
|
|
253
|
+
<SendTestMessage {...defaultProps} formData={formDataWithExtraFields} />
|
|
254
|
+
</TestWrapper>
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
expandAccordion();
|
|
258
|
+
const sendButton = screen.getByText('Send Test');
|
|
259
|
+
expect(sendButton.getAttribute('disabled')).toBeNull();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe('Edge Cases', () => {
|
|
264
|
+
it('should handle empty testEntitiesTreeData', () => {
|
|
265
|
+
render(
|
|
266
|
+
<TestWrapper>
|
|
267
|
+
<SendTestMessage {...defaultProps} testEntitiesTreeData={[]} />
|
|
268
|
+
</TestWrapper>
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
expect(screen.getByText('Send Test Message')).toBeTruthy();
|
|
272
|
+
expandAccordion();
|
|
273
|
+
expect(screen.getByText('Select Test Recipients')).toBeTruthy();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should handle empty selectedTestEntities', () => {
|
|
277
|
+
render(
|
|
278
|
+
<TestWrapper>
|
|
279
|
+
<SendTestMessage {...defaultProps} selectedTestEntities={[]} />
|
|
280
|
+
</TestWrapper>
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
expandAccordion();
|
|
284
|
+
const sendButton = screen.getByText('Send Test');
|
|
285
|
+
// Button should render regardless of disabled state
|
|
286
|
+
expect(sendButton).toBeTruthy();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should handle null/undefined values in formData', () => {
|
|
290
|
+
const formDataWithNulls = {
|
|
291
|
+
'template-subject': null,
|
|
292
|
+
'template-content': undefined,
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
render(
|
|
296
|
+
<TestWrapper>
|
|
297
|
+
<SendTestMessage {...defaultProps} formData={formDataWithNulls} />
|
|
298
|
+
</TestWrapper>
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
expandAccordion();
|
|
302
|
+
const sendButton = screen.getByText('Send Test');
|
|
303
|
+
// Button should render regardless of disabled state
|
|
304
|
+
expect(sendButton).toBeTruthy();
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('should handle multiple selected entities', () => {
|
|
308
|
+
const multipleSelections = ['customer-1', 'customer-2', 'group-1'];
|
|
309
|
+
|
|
310
|
+
render(
|
|
311
|
+
<TestWrapper>
|
|
312
|
+
<SendTestMessage {...defaultProps} selectedTestEntities={multipleSelections} />
|
|
313
|
+
</TestWrapper>
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expandAccordion();
|
|
317
|
+
const sendButton = screen.getByText('Send Test');
|
|
318
|
+
expect(sendButton.getAttribute('disabled')).toBeNull();
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
describe('Accordion Structure', () => {
|
|
323
|
+
it('should render as accordion with correct configuration', () => {
|
|
324
|
+
const { container } = render(
|
|
325
|
+
<TestWrapper>
|
|
326
|
+
<SendTestMessage {...defaultProps} />
|
|
327
|
+
</TestWrapper>
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
expandAccordion();
|
|
331
|
+
expect(container.querySelector('.send-test-content')).toBeTruthy();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('should have chevron icon', () => {
|
|
335
|
+
const { container } = render(
|
|
336
|
+
<TestWrapper>
|
|
337
|
+
<SendTestMessage {...defaultProps} />
|
|
338
|
+
</TestWrapper>
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
const chevronIcon = container.querySelector('.ant-collapse-arrow');
|
|
342
|
+
expect(chevronIcon).toBeTruthy();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe('Accessibility', () => {
|
|
347
|
+
it('should have proper accordion role', () => {
|
|
348
|
+
render(
|
|
349
|
+
<TestWrapper>
|
|
350
|
+
<SendTestMessage {...defaultProps} />
|
|
351
|
+
</TestWrapper>
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
expect(screen.getByRole('tablist')).toBeTruthy();
|
|
355
|
+
expect(screen.getByRole('tab')).toBeTruthy();
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('should have descriptive text for the feature', () => {
|
|
359
|
+
render(
|
|
360
|
+
<TestWrapper>
|
|
361
|
+
<SendTestMessage {...defaultProps} />
|
|
362
|
+
</TestWrapper>
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
expect(screen.getByText('Test out the message before sending to your customers')).toBeTruthy();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('should have proper button when expanded', () => {
|
|
369
|
+
render(
|
|
370
|
+
<TestWrapper>
|
|
371
|
+
<SendTestMessage {...defaultProps} />
|
|
372
|
+
</TestWrapper>
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
expandAccordion();
|
|
376
|
+
const sendButton = screen.getByRole('button');
|
|
377
|
+
expect(sendButton).toBeTruthy();
|
|
378
|
+
expect(sendButton.textContent).toBe('Send Test');
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('should have clear labeling for form elements', () => {
|
|
382
|
+
render(
|
|
383
|
+
<TestWrapper>
|
|
384
|
+
<SendTestMessage {...defaultProps} />
|
|
385
|
+
</TestWrapper>
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
expandAccordion();
|
|
389
|
+
expect(screen.getByText('Select Test Recipients')).toBeTruthy();
|
|
390
|
+
expect(screen.getByText('Send Test')).toBeTruthy();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
describe('Integration', () => {
|
|
395
|
+
it('should work with all loading states simultaneously', () => {
|
|
396
|
+
render(
|
|
397
|
+
<TestWrapper>
|
|
398
|
+
<SendTestMessage
|
|
399
|
+
{...defaultProps}
|
|
400
|
+
isFetchingTestCustomers
|
|
401
|
+
isFetchingTestGroups
|
|
402
|
+
isSendingTestMessage
|
|
403
|
+
/>
|
|
404
|
+
</TestWrapper>
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
expandAccordion();
|
|
408
|
+
const sendButton = screen.getByText('Send Test');
|
|
409
|
+
// Button should render regardless of disabled state
|
|
410
|
+
expect(sendButton).toBeTruthy();
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('should handle formatMessage function correctly', () => {
|
|
414
|
+
render(
|
|
415
|
+
<TestWrapper>
|
|
416
|
+
<SendTestMessage {...defaultProps} />
|
|
417
|
+
</TestWrapper>
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
expandAccordion();
|
|
421
|
+
expect(defaultProps.formatMessage).toHaveBeenCalledWith(
|
|
422
|
+
expect.objectContaining({
|
|
423
|
+
id: 'app.v2Components.TestAndPreviewSlidebox.testCustomersPlaceholder',
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('should render correctly with minimal valid data', () => {
|
|
429
|
+
const minimalProps = {
|
|
430
|
+
...defaultProps,
|
|
431
|
+
testEntitiesTreeData: [{ title: 'Single Customer', value: 'single', key: 'single' }],
|
|
432
|
+
selectedTestEntities: ['single'],
|
|
433
|
+
formData: { 'template-subject': 'Subject' },
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
render(
|
|
437
|
+
<TestWrapper>
|
|
438
|
+
<SendTestMessage {...minimalProps} />
|
|
439
|
+
</TestWrapper>
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
expect(screen.getByText('Send Test Message')).toBeTruthy();
|
|
443
|
+
expandAccordion();
|
|
444
|
+
const sendButton = screen.getByText('Send Test');
|
|
445
|
+
expect(sendButton.getAttribute('disabled')).toBeNull();
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as actions from '../actions';
|
|
2
|
+
import * as types from '../constants';
|
|
3
|
+
|
|
4
|
+
describe('TestAndPreviewSlidebox actions', () => {
|
|
5
|
+
it('should have a type of SEARCH_CUSTOMERS_REQUESTED', () => {
|
|
6
|
+
const expected = {
|
|
7
|
+
type: types.SEARCH_CUSTOMERS_REQUESTED,
|
|
8
|
+
payload: { query: 'test' },
|
|
9
|
+
};
|
|
10
|
+
expect(actions.searchCustomersRequested('test')).toEqual(expected);
|
|
11
|
+
});
|
|
12
|
+
it('should have a type of EXTRACT_TAGS_REQUEST', () => {
|
|
13
|
+
const expected = {
|
|
14
|
+
type: types.EXTRACT_TAGS_REQUEST,
|
|
15
|
+
payload: { templateSubject: 'test', templateContent: 'test' },
|
|
16
|
+
};
|
|
17
|
+
expect(actions.extractTagsRequested('test', 'test')).toEqual(expected);
|
|
18
|
+
});
|
|
19
|
+
it('should have a type of UPDATE_PREVIEW_REQUEST', () => {
|
|
20
|
+
const expected = {
|
|
21
|
+
type: types.UPDATE_PREVIEW_REQUEST,
|
|
22
|
+
payload: 'test',
|
|
23
|
+
};
|
|
24
|
+
expect(actions.updatePreviewRequested('test')).toEqual(expected);
|
|
25
|
+
});
|
|
26
|
+
it('should have a type of SEND_TEST_MESSAGE_REQUESTED', () => {
|
|
27
|
+
const expected = {
|
|
28
|
+
type: types.SEND_TEST_MESSAGE_REQUESTED,
|
|
29
|
+
payload: 'test',
|
|
30
|
+
callback: undefined,
|
|
31
|
+
};
|
|
32
|
+
expect(actions.sendTestMessageRequested('test')).toEqual(expected);
|
|
33
|
+
});
|
|
34
|
+
it('should have a type of CLEAR_CUSTOMER_SEARCH_STATE', () => {
|
|
35
|
+
const expected = {
|
|
36
|
+
type: types.CLEAR_CUSTOMER_SEARCH_STATE,
|
|
37
|
+
};
|
|
38
|
+
expect(actions.clearCustomerSearchState()).toEqual(expected);
|
|
39
|
+
});
|
|
40
|
+
it('should have a type of CLEAR_SEARCH_RESULTS', () => {
|
|
41
|
+
const expected = {
|
|
42
|
+
type: types.CLEAR_SEARCH_RESULTS,
|
|
43
|
+
};
|
|
44
|
+
expect(actions.clearSearchResults()).toEqual(expected);
|
|
45
|
+
});
|
|
46
|
+
it('should have a type of FETCH_TEST_CUSTOMERS_REQUESTED', () => {
|
|
47
|
+
const expected = {
|
|
48
|
+
type: types.FETCH_TEST_CUSTOMERS_REQUESTED,
|
|
49
|
+
};
|
|
50
|
+
expect(actions.fetchTestCustomersRequested()).toEqual(expected);
|
|
51
|
+
});
|
|
52
|
+
it('should have a type of FETCH_TEST_GROUPS_REQUESTED', () => {
|
|
53
|
+
const expected = {
|
|
54
|
+
type: types.FETCH_TEST_GROUPS_REQUESTED,
|
|
55
|
+
};
|
|
56
|
+
expect(actions.fetchTestGroupsRequested()).toEqual(expected);
|
|
57
|
+
});
|
|
58
|
+
it('should have a type of CREATE_MESSAGE_META_REQUESTED', () => {
|
|
59
|
+
const expected = {
|
|
60
|
+
type: types.CREATE_MESSAGE_META_REQUESTED,
|
|
61
|
+
payload: 'test',
|
|
62
|
+
messageMetaConfigId: 'test',
|
|
63
|
+
callback: undefined,
|
|
64
|
+
};
|
|
65
|
+
expect(actions.createMessageMetaRequested('test', 'test')).toEqual(expected);
|
|
66
|
+
});
|
|
67
|
+
it('should have a type of GET_PREFILLED_VALUES_REQUESTED', () => {
|
|
68
|
+
const expected = {
|
|
69
|
+
type: types.GET_PREFILLED_VALUES_REQUESTED,
|
|
70
|
+
payload: 'test',
|
|
71
|
+
};
|
|
72
|
+
expect(actions.getPrefilledValuesRequested('test')).toEqual(expected);
|
|
73
|
+
});
|
|
74
|
+
it('should have a type of CLEAR_PREFILLED_VALUES', () => {
|
|
75
|
+
const expected = {
|
|
76
|
+
type: types.CLEAR_PREFILLED_VALUES,
|
|
77
|
+
};
|
|
78
|
+
expect(actions.clearPrefilledValues()).toEqual(expected);
|
|
79
|
+
});
|
|
80
|
+
});
|