@capillarytech/creatives-library 8.0.144 → 8.0.146

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 (48) hide show
  1. package/initialReducer.js +0 -2
  2. package/package.json +1 -1
  3. package/services/api.js +0 -5
  4. package/services/tests/api.test.js +0 -17
  5. package/v2Components/MobilePushPreviewV2/index.js +2 -10
  6. package/v2Components/NavigationBar/saga.js +1 -1
  7. package/v2Components/NavigationBar/tests/saga.test.js +2 -2
  8. package/v2Components/TemplatePreview/index.js +6 -32
  9. package/v2Components/TemplatePreview/messages.js +0 -4
  10. package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +1 -1
  11. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +1 -1
  12. package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -26
  13. package/v2Containers/CreativesContainer/index.js +14 -68
  14. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -5
  15. package/v2Containers/Email/index.js +1 -1
  16. package/v2Containers/InApp/actions.js +0 -7
  17. package/v2Containers/InApp/constants.js +1 -8
  18. package/v2Containers/InApp/index.js +53 -76
  19. package/v2Containers/InApp/reducer.js +0 -17
  20. package/v2Containers/InApp/sagas.js +0 -27
  21. package/v2Containers/InApp/selectors.js +1 -23
  22. package/v2Containers/InApp/tests/index.test.js +9 -0
  23. package/v2Containers/InApp/tests/reducer.test.js +0 -33
  24. package/v2Containers/InApp/tests/sagas.test.js +1 -57
  25. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
  26. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
  27. package/v2Containers/Line/Container/Text/index.js +6 -6
  28. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -2
  29. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -9
  30. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -18
  31. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -4
  32. package/v2Containers/Templates/_templates.scss +0 -3
  33. package/v2Containers/Templates/index.js +4 -4
  34. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -35
  35. package/v2Components/TemplatePreview/assets/images/empty_android.svg +0 -8
  36. package/v2Components/TemplatePreview/assets/images/empty_ios.svg +0 -5
  37. package/v2Components/TestAndPreviewSlidebox/tests/PreviewSection.test.js +0 -99
  38. package/v2Containers/BeePopupEditor/constants.js +0 -10
  39. package/v2Containers/BeePopupEditor/index.js +0 -169
  40. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -628
  41. package/v2Containers/InApp/tests/selector.test.js +0 -612
  42. package/v2Containers/InappAdvanced/index.js +0 -459
  43. package/v2Containers/InappAdvanced/index.scss +0 -11
  44. package/v2Containers/InappAdvanced/tests/index.test.js +0 -442
  45. package/v2Containers/InappWrapper/_inappWrapper.scss +0 -19
  46. package/v2Containers/InappWrapper/index.js +0 -195
  47. package/v2Containers/InappWrapper/messages.js +0 -38
  48. package/v2Containers/InappWrapper/tests/index.test.js +0 -247
@@ -1,247 +0,0 @@
1
- import React from 'react';
2
- import { Provider } from 'react-redux';
3
- import '@testing-library/jest-dom';
4
- import { injectIntl } from 'react-intl';
5
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
6
- import history from '../../../utils/history';
7
- import { initialReducer } from '../../../initialReducer';
8
- import { InappWrapper } from '../index';
9
- import { render, screen, fireEvent } from '../../../utils/test-utils';
10
-
11
- // Mock child components
12
- jest.mock('../../InApp/index.js', () => ({
13
- __esModule: true,
14
- default: (props) => (
15
- <div data-testid="inapp-basic-editor">
16
- InApp Basic Editor
17
- </div>
18
- ),
19
- }));
20
-
21
- jest.mock('../../InappAdvanced/index.js', () => ({
22
- __esModule: true,
23
- default: (props) => (
24
- <div data-testid="inapp-advanced-editor">
25
- InApp Advanced Editor
26
- </div>
27
- ),
28
- }));
29
-
30
- let store;
31
- beforeAll(() => {
32
- store = configureStore({}, initialReducer, history);
33
- });
34
-
35
- const ComponentToRender = injectIntl(InappWrapper);
36
- const renderComponent = (props) =>
37
- render(
38
- <Provider store={store}>
39
- <ComponentToRender {...props} />
40
- </Provider>
41
- );
42
-
43
- describe('InappWrapper Component', () => {
44
- let defaultProps;
45
-
46
- beforeEach(() => {
47
- defaultProps = {
48
- inAppCreateMode: 'basicEditor',
49
- step: 'modeSelection',
50
- getFormData: jest.fn(),
51
- setIsLoadingContent: jest.fn(),
52
- isGetFormData: false,
53
- query: { type: 'inapp' },
54
- isFullMode: true,
55
- showTemplateName: jest.fn(),
56
- type: 'inapp',
57
- onValidationFail: jest.fn(),
58
- templateData: { id: 'test-template' },
59
- onInAppModeChange: jest.fn(),
60
- onEnterTemplateName: jest.fn(),
61
- onRemoveTemplateName: jest.fn(),
62
- forwardedTags: {},
63
- selectedOfferDetails: {},
64
- onCreateComplete: jest.fn(),
65
- };
66
- });
67
-
68
- describe('Mode Selection Step', () => {
69
-
70
- it('should render template name input when isFullMode is true', () => {
71
- renderComponent({
72
- ...defaultProps,
73
- step: 'modeSelection',
74
- isFullMode: true,
75
- });
76
-
77
- expect(screen.getByTestId('template-name-input')).toBeInTheDocument();
78
- });
79
-
80
- it('should not render template name input when isFullMode is false', () => {
81
- renderComponent({
82
- ...defaultProps,
83
- step: 'modeSelection',
84
- isFullMode: false,
85
- });
86
-
87
- expect(screen.queryByTestId('template-name-input')).not.toBeInTheDocument();
88
- });
89
-
90
- it('should update template name and call onEnterTemplateName when input value changes', () => {
91
- const mockOnEnterTemplateName = jest.fn();
92
- renderComponent({
93
- ...defaultProps,
94
- step: 'modeSelection',
95
- onEnterTemplateName: mockOnEnterTemplateName,
96
- });
97
-
98
- const input = screen.getByTestId('template-name-input');
99
- fireEvent.change(input, { target: { value: 'Test Template' } });
100
-
101
- expect(input.value).toBe('Test Template');
102
- expect(mockOnEnterTemplateName).toHaveBeenCalled();
103
- });
104
-
105
- it('should call onRemoveTemplateName when template name is cleared', () => {
106
- const mockOnRemoveTemplateName = jest.fn();
107
- renderComponent({
108
- ...defaultProps,
109
- step: 'modeSelection',
110
- onRemoveTemplateName: mockOnRemoveTemplateName,
111
- });
112
-
113
- const input = screen.getByTestId('template-name-input');
114
-
115
- // First add some text
116
- fireEvent.change(input, { target: { value: 'Test' } });
117
- // Then clear it
118
- fireEvent.change(input, { target: { value: '' } });
119
-
120
- expect(mockOnRemoveTemplateName).toHaveBeenCalled();
121
- });
122
- });
123
-
124
- describe('Editor Rendering', () => {
125
- it('should render InApp component when inAppCreateMode is "basicEditor" and step is not "modeSelection"', () => {
126
- renderComponent({
127
- ...defaultProps,
128
- step: 'editor',
129
- inAppCreateMode: 'basicEditor',
130
- });
131
-
132
- expect(screen.getByTestId('inapp-basic-editor')).toBeInTheDocument();
133
- expect(screen.queryByTestId('inapp-advanced-editor')).not.toBeInTheDocument();
134
- });
135
-
136
- it('should render InappAdvanced component when inAppCreateMode is "beeEditor" and step is not "modeSelection"', () => {
137
- renderComponent({
138
- ...defaultProps,
139
- step: 'editor',
140
- inAppCreateMode: 'beeEditor',
141
- });
142
-
143
- expect(screen.getByTestId('inapp-advanced-editor')).toBeInTheDocument();
144
- expect(screen.queryByTestId('inapp-basic-editor')).not.toBeInTheDocument();
145
- });
146
-
147
- it('should pass all required props to InApp component', () => {
148
- const customProps = {
149
- step: 'editor',
150
- inAppCreateMode: 'basicEditor',
151
- getFormData: jest.fn(),
152
- templateData: { id: 'test' },
153
- };
154
-
155
- renderComponent({ ...defaultProps, ...customProps });
156
-
157
- const inAppComponent = screen.getByTestId('inapp-basic-editor');
158
- expect(inAppComponent).toBeInTheDocument();
159
- });
160
-
161
- it('should pass all required props to InappAdvanced component', () => {
162
- const customProps = {
163
- step: 'editor',
164
- inAppCreateMode: 'beeEditor',
165
- getFormData: jest.fn(),
166
- templateData: { id: 'test' },
167
- };
168
-
169
- renderComponent({ ...defaultProps, ...customProps });
170
-
171
- const advancedComponent = screen.getByTestId('inapp-advanced-editor');
172
- expect(advancedComponent).toBeInTheDocument();
173
- });
174
- });
175
-
176
- describe('Component Structure', () => {
177
- it('should have the correct CSS class on the wrapper', () => {
178
- const { container } = renderComponent({ ...defaultProps });
179
-
180
- expect(container.firstChild).toHaveClass('inapp-wrapper');
181
- });
182
- });
183
-
184
- describe('Props Validation', () => {
185
- it('should handle missing optional props gracefully', () => {
186
- const minimalProps = {
187
- inAppCreateMode: 'basicEditor',
188
- step: 'modeSelection',
189
- };
190
-
191
- expect(() => {
192
- renderComponent({ ...defaultProps, ...minimalProps });
193
- }).not.toThrow();
194
- });
195
-
196
- it('should handle undefined values in props', () => {
197
- const propsWithUndefined = {
198
- ...defaultProps,
199
- templateData: undefined,
200
- query: undefined,
201
- };
202
-
203
- expect(() => {
204
- renderComponent({ ...defaultProps, ...propsWithUndefined });
205
- }).not.toThrow();
206
- });
207
- });
208
-
209
- describe('State Management', () => {
210
- it('should maintain internal template name state', () => {
211
- renderComponent({
212
- ...defaultProps,
213
- step: 'modeSelection'
214
- });
215
-
216
- const input = screen.getByTestId('template-name-input');
217
- fireEvent.change(input, { target: { value: 'My Template' } });
218
-
219
- expect(input.value).toBe('My Template');
220
- });
221
- });
222
-
223
- describe('Conditional Rendering', () => {
224
-
225
- it('should only render editor when step is not "modeSelection"', () => {
226
- renderComponent({
227
- ...defaultProps,
228
- step: 'editor',
229
- inAppCreateMode: 'basicEditor',
230
- });
231
-
232
- expect(screen.queryByTestId('cap-radio-card')).not.toBeInTheDocument();
233
- expect(screen.getByTestId('inapp-basic-editor')).toBeInTheDocument();
234
- });
235
-
236
- it('should not render any editor when no matching inAppCreateMode', () => {
237
- renderComponent({
238
- ...defaultProps,
239
- step: 'editor',
240
- inAppCreateMode: 'unknownMode',
241
- });
242
-
243
- expect(screen.queryByTestId('inapp-basic-editor')).not.toBeInTheDocument();
244
- expect(screen.queryByTestId('inapp-advanced-editor')).not.toBeInTheDocument();
245
- });
246
- });
247
- });