@capillarytech/creatives-library 8.0.242-alpha.3 → 8.0.242-alpha.4
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/package.json
CHANGED
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
.preview-pane {
|
|
55
55
|
max-height: calc(107vh);
|
|
56
56
|
|
|
57
|
+
&__content {
|
|
58
|
+
height: calc(95vh - 5%); // Same as editor pane - maximize to full available height
|
|
59
|
+
max-height: calc(95vh - 50%);
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
iframe {
|
|
58
63
|
height: calc(95vh - 5%); // Same as editor pane - maximize to full available height
|
|
59
64
|
max-height: calc(95vh - 50%);
|
|
@@ -48,33 +48,6 @@ describe('ValidationErrorDisplay', () => {
|
|
|
48
48
|
expect(screen.getByText('Invalid attribute')).toBeInTheDocument();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
it('renders liquid errors separately', () => {
|
|
52
|
-
const mockValidation = {
|
|
53
|
-
getAllIssues: () => [
|
|
54
|
-
{
|
|
55
|
-
message: 'Invalid liquid syntax', severity: 'error', source: 'liquid-validator', line: 3,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
message: 'HTML error', severity: 'error', source: 'htmlhint', line: 10,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
isClean: () => false,
|
|
62
|
-
isValidating: false,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const { container } = render(
|
|
66
|
-
<TestWrapper>
|
|
67
|
-
<ValidationErrorDisplay validation={mockValidation} />
|
|
68
|
-
</TestWrapper>
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// Check for validation-error-display wrapper
|
|
72
|
-
expect(container.querySelector('.validation-error-display')).toBeInTheDocument();
|
|
73
|
-
// Check that both errors are rendered
|
|
74
|
-
expect(screen.getByText('Invalid liquid syntax')).toBeInTheDocument();
|
|
75
|
-
expect(screen.getByText('HTML error')).toBeInTheDocument();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
51
|
it('does not render when validation has no errors', () => {
|
|
79
52
|
const mockValidation = {
|
|
80
53
|
getAllIssues: () => [],
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent, within, screen } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { IntlProvider } from 'react-intl';
|
|
5
|
-
import { Provider } from 'react-redux';
|
|
6
|
-
import { configureStore } from '@capillarytech/vulcan-react-sdk/utils'
|
|
7
|
-
import { initialReducer } from '../../../initialReducer';
|
|
8
|
-
import history from '../../../utils/history';
|
|
9
|
-
import EmailWrapperView from '../components/EmailWrapperView';
|
|
10
|
-
import { EmailWrapperViewMockProps } from '../mockdata/mockdata';
|
|
11
|
-
import { EMAIL_CREATE_MODES } from '../constants';
|
|
12
|
-
|
|
13
|
-
// Mock pathConfig before history import - must be a string, not undefined
|
|
14
|
-
jest.mock('../../../config/path', () => ({
|
|
15
|
-
publicPath: '/creatives/ui',
|
|
16
|
-
engagePlusPublicPath: '/campaigns/ui',
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
// Mock window.location for createBrowserHistory
|
|
20
|
-
const originalLocation = window.location;
|
|
21
|
-
beforeAll(() => {
|
|
22
|
-
delete window.location;
|
|
23
|
-
window.location = {
|
|
24
|
-
...originalLocation,
|
|
25
|
-
pathname: '/',
|
|
26
|
-
search: '',
|
|
27
|
-
hash: '',
|
|
28
|
-
href: 'http://localhost/',
|
|
29
|
-
replace: jest.fn(),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
afterAll(() => {
|
|
34
|
-
window.location = originalLocation;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// This mock needs to be before any imports
|
|
38
|
-
jest.mock('../../../v2Containers/Email', () => ({
|
|
39
|
-
__esModule: true,
|
|
40
|
-
default: () => <div data-testid="email-create-container" />,
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
// Mock react-router
|
|
44
|
-
jest.mock('react-router-dom', () => ({
|
|
45
|
-
...jest.requireActual('react-router-dom'),
|
|
46
|
-
useHistory: () => ({
|
|
47
|
-
push: jest.fn(),
|
|
48
|
-
replace: jest.fn(),
|
|
49
|
-
go: jest.fn(),
|
|
50
|
-
goBack: jest.fn(),
|
|
51
|
-
goForward: jest.fn(),
|
|
52
|
-
location: { search: '' }
|
|
53
|
-
}),
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
// Mock redux-auth-wrapper
|
|
57
|
-
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
58
|
-
connectedRouterRedirect: () => (Component) => Component,
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
// Mock react-router
|
|
62
|
-
jest.mock('connected-react-router', () => ({
|
|
63
|
-
push: jest.fn(),
|
|
64
|
-
replace: jest.fn(),
|
|
65
|
-
go: jest.fn(),
|
|
66
|
-
goBack: jest.fn(),
|
|
67
|
-
goForward: jest.fn(),
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
// Mock the saga injector
|
|
71
|
-
jest.mock('@capillarytech/vulcan-react-sdk/utils/injectSaga', () => ({
|
|
72
|
-
__esModule: true,
|
|
73
|
-
default: () => (Component) => Component,
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const initialState = {
|
|
78
|
-
cap: { loading: false, error: null },
|
|
79
|
-
router: { location: { pathname: '/' } }
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
describe('EmailWrapperView', () => {
|
|
83
|
-
let store;
|
|
84
|
-
|
|
85
|
-
beforeAll(() => {
|
|
86
|
-
// Use the real history (pathConfig is mocked, so it should work)
|
|
87
|
-
store = configureStore(initialState, initialReducer, history);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const renderWithProviders = (component) => {
|
|
91
|
-
return render(
|
|
92
|
-
<Provider store={store}>
|
|
93
|
-
<IntlProvider locale="en" messages={{}}>
|
|
94
|
-
{component}
|
|
95
|
-
</IntlProvider>
|
|
96
|
-
</Provider>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
it('renders mode selection UI when step is modeSelection', () => {
|
|
101
|
-
const props = {
|
|
102
|
-
...EmailWrapperViewMockProps,
|
|
103
|
-
step: 'modeSelection',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const { getByText } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
107
|
-
expect(getByText('Create using editor')).toBeInTheDocument();
|
|
108
|
-
expect(getByText('Upload zip file')).toBeInTheDocument();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('shows template name input in full mode', () => {
|
|
112
|
-
const props = {
|
|
113
|
-
...EmailWrapperViewMockProps,
|
|
114
|
-
isFullMode: true,
|
|
115
|
-
step: 'modeSelection',
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const { container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
119
|
-
const input = container.querySelector('.ant-input');
|
|
120
|
-
expect(input).toBeInTheDocument();
|
|
121
|
-
expect(input.value).toBe(props.templateName);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('handles template name changes', () => {
|
|
125
|
-
const props = {
|
|
126
|
-
...EmailWrapperViewMockProps,
|
|
127
|
-
isFullMode: true,
|
|
128
|
-
step: 'modeSelection',
|
|
129
|
-
onTemplateNameChange: jest.fn(),
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const { container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
133
|
-
const input = container.querySelector('.ant-input');
|
|
134
|
-
expect(input).toBeInTheDocument();
|
|
135
|
-
|
|
136
|
-
// Create a change event and fire it
|
|
137
|
-
fireEvent.change(input, { target: { value: 'New Template Name' } });
|
|
138
|
-
|
|
139
|
-
// Just verify that the function was called
|
|
140
|
-
expect(props.onTemplateNameChange).toHaveBeenCalled();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('shows upload button when in upload mode', () => {
|
|
144
|
-
const props = {
|
|
145
|
-
...EmailWrapperViewMockProps,
|
|
146
|
-
step: 'modeSelection',
|
|
147
|
-
emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
|
|
148
|
-
uploadButtonLabel: 'Upload',
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const { getByText, container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
152
|
-
|
|
153
|
-
// Find the "Upload zip file" section
|
|
154
|
-
const modeSelectionSection = getByText('Upload zip file').closest('div');
|
|
155
|
-
|
|
156
|
-
// Find any button in the upload section
|
|
157
|
-
const uploadButton = container.querySelector('.ant-btn');
|
|
158
|
-
|
|
159
|
-
// Verify that we found an upload button
|
|
160
|
-
expect(uploadButton).toBeInTheDocument();
|
|
161
|
-
expect(uploadButton.textContent).toContain('Upload');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('shows loading spinner when uploading', () => {
|
|
165
|
-
const props = {
|
|
166
|
-
...EmailWrapperViewMockProps,
|
|
167
|
-
isUploading: true,
|
|
168
|
-
emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
|
|
169
|
-
step: 'modeSelection',
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const { container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
173
|
-
const spinner = container.querySelector('.ant-spin');
|
|
174
|
-
expect(spinner).toBeInTheDocument();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('shows content creation UI when not in mode selection', () => {
|
|
178
|
-
const props = {
|
|
179
|
-
...EmailWrapperViewMockProps,
|
|
180
|
-
step: 'contentCreation',
|
|
181
|
-
isShowEmailCreate: true,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const { getByTestId } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
185
|
-
expect(getByTestId('email-create-container')).toBeInTheDocument();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('disables upload button when template name is empty in full mode', () => {
|
|
189
|
-
const props = {
|
|
190
|
-
...EmailWrapperViewMockProps,
|
|
191
|
-
isFullMode: true,
|
|
192
|
-
step: 'modeSelection',
|
|
193
|
-
emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
|
|
194
|
-
templateName: '',
|
|
195
|
-
isTemplateNameEmpty: true,
|
|
196
|
-
uploadButtonLabel: 'Upload',
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const { getByText, container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
200
|
-
|
|
201
|
-
// Find the Upload section
|
|
202
|
-
getByText('Upload zip file');
|
|
203
|
-
|
|
204
|
-
// Find button in the container
|
|
205
|
-
const uploadButton = container.querySelector('.ant-btn');
|
|
206
|
-
|
|
207
|
-
// Check if the button is disabled
|
|
208
|
-
expect(uploadButton).toBeDisabled();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('shows error message when template name is empty during upload', () => {
|
|
212
|
-
const props = {
|
|
213
|
-
...EmailWrapperViewMockProps,
|
|
214
|
-
isFullMode: true,
|
|
215
|
-
step: 'modeSelection',
|
|
216
|
-
emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
|
|
217
|
-
templateName: '',
|
|
218
|
-
isTemplateNameEmpty: true,
|
|
219
|
-
// Add errorMessage directly to the props
|
|
220
|
-
errorMessage: 'Please enter template name',
|
|
221
|
-
intl: {
|
|
222
|
-
formatMessage: () => 'Please enter template name',
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const { container } = renderWithProviders(<EmailWrapperView {...props} />);
|
|
227
|
-
|
|
228
|
-
// Look for error feedback in the Ant Design form
|
|
229
|
-
const errorElement = container.querySelector('.ant-form-item-explain');
|
|
230
|
-
|
|
231
|
-
if (errorElement) {
|
|
232
|
-
expect(errorElement.textContent).toContain('Please enter template name');
|
|
233
|
-
} else {
|
|
234
|
-
// If the standard error element is not found, look for any element containing the error text
|
|
235
|
-
const allText = container.textContent;
|
|
236
|
-
expect(allText).toContain('Please enter template name');
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|