@capillarytech/creatives-library 8.0.303 → 8.0.304
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +1 -7
- package/v2Components/CapDeviceContent/index.js +7 -10
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -3
- package/v2Components/FormBuilder/index.js +1 -1
- package/v2Components/HtmlEditor/HTMLEditor.js +0 -1
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +0 -1
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +3 -132
- package/v2Components/HtmlEditor/hooks/useValidation.js +9 -12
- package/v2Components/HtmlEditor/utils/htmlValidator.js +2 -4
- package/v2Containers/BeePopupEditor/index.js +2 -9
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -35
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +1 -69
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +4 -121
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +2 -2
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +18 -110
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +155 -110
- package/v2Containers/InApp/index.js +14 -183
- package/v2Containers/InApp/tests/mockData.js +1 -1
package/constants/unified.js
CHANGED
|
@@ -45,7 +45,6 @@ export const GIFT_CARDS = 'GIFT_CARDS';
|
|
|
45
45
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
46
46
|
export const LIQUID_SUPPORT = 'ENABLE_LIQUID_SUPPORT';
|
|
47
47
|
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
48
|
-
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
49
48
|
export const SUPPORT_CK_EDITOR = 'SUPPORT_CK_EDITOR';
|
|
50
49
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
51
50
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -24,8 +24,7 @@ import {
|
|
|
24
24
|
ENABLE_WEBPUSH,
|
|
25
25
|
LIQUID_SUPPORT,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
-
ENABLE_NEW_MPUSH
|
|
28
|
-
ENABLE_NEW_EDITOR_FLOW_INAPP
|
|
27
|
+
ENABLE_NEW_MPUSH
|
|
29
28
|
} from '../constants/unified';
|
|
30
29
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
31
30
|
|
|
@@ -143,11 +142,6 @@ export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
|
143
142
|
ENABLE_NEW_MPUSH,
|
|
144
143
|
);
|
|
145
144
|
|
|
146
|
-
export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
147
|
-
null,
|
|
148
|
-
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
149
|
-
);
|
|
150
|
-
|
|
151
145
|
//filtering tags based on scope
|
|
152
146
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
153
147
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
|
@@ -63,7 +63,6 @@ const CapDeviceContent = (props) => {
|
|
|
63
63
|
deepLinkValue,
|
|
64
64
|
setDeepLinkValue,
|
|
65
65
|
onCopyTitleAndContent,
|
|
66
|
-
isOtherDeviceSupported,
|
|
67
66
|
tags,
|
|
68
67
|
onTagSelect,
|
|
69
68
|
handleOnTagsContextChange,
|
|
@@ -168,15 +167,13 @@ const CapDeviceContent = (props) => {
|
|
|
168
167
|
return (
|
|
169
168
|
<>
|
|
170
169
|
<CapRow className="creatives-device-content">
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/>
|
|
179
|
-
)}
|
|
170
|
+
<CapLink
|
|
171
|
+
title={isAndroid
|
|
172
|
+
? formatMessage(messages.copyContentFromIOS)
|
|
173
|
+
: formatMessage(messages.copyCotentFromAndroid)}
|
|
174
|
+
className="inapp-copy-content"
|
|
175
|
+
onClick={onCopyTitleAndContent}
|
|
176
|
+
/>
|
|
180
177
|
<CapRow className="creatives-inapp-title">
|
|
181
178
|
<CapColumn
|
|
182
179
|
className="inapp-content-main"
|
|
@@ -1331,7 +1331,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1331
1331
|
}
|
|
1332
1332
|
onSubmitWrapper = (args) => {
|
|
1333
1333
|
const {singleTab = null} = args || {};
|
|
1334
|
-
if (this.liquidFlow()
|
|
1334
|
+
if (this.liquidFlow()) {
|
|
1335
1335
|
// For MPUSH, we need to validate both Android and iOS content separately
|
|
1336
1336
|
if (this.props.channel === MOBILE_PUSH || this.props?.schema?.channel?.toUpperCase() === MOBILE_PUSH) {
|
|
1337
1337
|
this.validateFormBuilderMPush(this.state.formData, singleTab);
|
|
@@ -294,7 +294,6 @@ const HTMLEditor = forwardRef(({
|
|
|
294
294
|
enableSanitization: true,
|
|
295
295
|
securityLevel: 'standard',
|
|
296
296
|
apiValidationErrors, // Pass API validation errors to merge with client-side validation
|
|
297
|
-
isFullMode, // Skip liquid validation in standalone/full mode
|
|
298
297
|
}, formatSanitizerMessage, formatValidatorMessage);
|
|
299
298
|
|
|
300
299
|
// Expose validation and content state via ref
|
|
@@ -155,7 +155,7 @@ describe('useValidation', () => {
|
|
|
155
155
|
await Promise.resolve();
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'email', null
|
|
158
|
+
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'email', null);
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
it('updates validation when content changes', async () => {
|
|
@@ -472,7 +472,7 @@ describe('useValidation', () => {
|
|
|
472
472
|
await Promise.resolve();
|
|
473
473
|
});
|
|
474
474
|
|
|
475
|
-
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'inapp', null
|
|
475
|
+
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'inapp', null);
|
|
476
476
|
});
|
|
477
477
|
|
|
478
478
|
it('defaults to email variant', async () => {
|
|
@@ -487,7 +487,7 @@ describe('useValidation', () => {
|
|
|
487
487
|
await Promise.resolve();
|
|
488
488
|
});
|
|
489
489
|
|
|
490
|
-
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'email', null
|
|
490
|
+
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'email', null);
|
|
491
491
|
});
|
|
492
492
|
});
|
|
493
493
|
|
|
@@ -1242,133 +1242,4 @@ describe('useValidation', () => {
|
|
|
1242
1242
|
});
|
|
1243
1243
|
});
|
|
1244
1244
|
});
|
|
1245
|
-
|
|
1246
|
-
describe('isFullMode - skip liquid validation', () => {
|
|
1247
|
-
it('passes skipLiquidValidation: true to validateHTML when isFullMode is true', async () => {
|
|
1248
|
-
const { validateHTML } = require('../../utils/htmlValidator');
|
|
1249
|
-
|
|
1250
|
-
render(<TestComponent content="<p>Test</p>" options={{ isFullMode: true }} />);
|
|
1251
|
-
|
|
1252
|
-
await act(async () => {
|
|
1253
|
-
jest.advanceTimersByTime(500);
|
|
1254
|
-
await Promise.resolve();
|
|
1255
|
-
await Promise.resolve();
|
|
1256
|
-
await Promise.resolve();
|
|
1257
|
-
});
|
|
1258
|
-
|
|
1259
|
-
expect(validateHTML).toHaveBeenCalledWith('<p>Test</p>', 'email', null, { skipLiquidValidation: true });
|
|
1260
|
-
});
|
|
1261
|
-
|
|
1262
|
-
it('excludes API liquid errors from getAllIssues when isFullMode is true', async () => {
|
|
1263
|
-
let validationState;
|
|
1264
|
-
const onStateChange = (state) => { validationState = state; };
|
|
1265
|
-
|
|
1266
|
-
const apiValidationErrors = {
|
|
1267
|
-
liquidErrors: ['Unsupported tag: points_balance'],
|
|
1268
|
-
standardErrors: [],
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
render(
|
|
1272
|
-
<TestComponent
|
|
1273
|
-
content="<p>Test</p>"
|
|
1274
|
-
options={{ apiValidationErrors, isFullMode: true }}
|
|
1275
|
-
onStateChange={onStateChange}
|
|
1276
|
-
/>
|
|
1277
|
-
);
|
|
1278
|
-
|
|
1279
|
-
await act(async () => {
|
|
1280
|
-
jest.advanceTimersByTime(500);
|
|
1281
|
-
await Promise.resolve();
|
|
1282
|
-
await Promise.resolve();
|
|
1283
|
-
await Promise.resolve();
|
|
1284
|
-
});
|
|
1285
|
-
|
|
1286
|
-
await waitFor(() => {
|
|
1287
|
-
expect(validationState).toBeDefined();
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
const issues = validationState.getAllIssues();
|
|
1291
|
-
const liquidIssues = issues.filter((i) => i.source === 'liquid-validator');
|
|
1292
|
-
expect(liquidIssues).toHaveLength(0);
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
it('returns isClean true when only liquid errors exist and isFullMode is true', () => {
|
|
1296
|
-
const apiValidationErrors = {
|
|
1297
|
-
liquidErrors: ['Unsupported tag: points_balance'],
|
|
1298
|
-
standardErrors: [],
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
render(
|
|
1302
|
-
<TestComponent
|
|
1303
|
-
content=""
|
|
1304
|
-
options={{ apiValidationErrors, isFullMode: true }}
|
|
1305
|
-
/>
|
|
1306
|
-
);
|
|
1307
|
-
|
|
1308
|
-
// Before validation runs, isClean should be true because liquid errors are ignored in full mode
|
|
1309
|
-
expect(screen.getByTestId('is-clean')).toHaveTextContent('true');
|
|
1310
|
-
});
|
|
1311
|
-
|
|
1312
|
-
it('does not treat liquid errors as blocking when isFullMode is true', async () => {
|
|
1313
|
-
let validationState;
|
|
1314
|
-
const onStateChange = (state) => { validationState = state; };
|
|
1315
|
-
|
|
1316
|
-
const apiValidationErrors = {
|
|
1317
|
-
liquidErrors: ['Unsupported tag: points_balance'],
|
|
1318
|
-
standardErrors: [],
|
|
1319
|
-
};
|
|
1320
|
-
|
|
1321
|
-
render(
|
|
1322
|
-
<TestComponent
|
|
1323
|
-
content="<p>Valid</p>"
|
|
1324
|
-
options={{ apiValidationErrors, isFullMode: true }}
|
|
1325
|
-
onStateChange={onStateChange}
|
|
1326
|
-
/>
|
|
1327
|
-
);
|
|
1328
|
-
|
|
1329
|
-
await act(async () => {
|
|
1330
|
-
jest.advanceTimersByTime(500);
|
|
1331
|
-
await Promise.resolve();
|
|
1332
|
-
await Promise.resolve();
|
|
1333
|
-
await Promise.resolve();
|
|
1334
|
-
});
|
|
1335
|
-
|
|
1336
|
-
await waitFor(() => {
|
|
1337
|
-
expect(validationState).toBeDefined();
|
|
1338
|
-
});
|
|
1339
|
-
|
|
1340
|
-
expect(validationState.hasBlockingErrors).toBe(false);
|
|
1341
|
-
});
|
|
1342
|
-
|
|
1343
|
-
it('still treats standard API errors as blocking when isFullMode is true', async () => {
|
|
1344
|
-
let validationState;
|
|
1345
|
-
const onStateChange = (state) => { validationState = state; };
|
|
1346
|
-
|
|
1347
|
-
const apiValidationErrors = {
|
|
1348
|
-
liquidErrors: ['Liquid error'],
|
|
1349
|
-
standardErrors: ['Standard error'],
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
render(
|
|
1353
|
-
<TestComponent
|
|
1354
|
-
content="<p>Valid</p>"
|
|
1355
|
-
options={{ apiValidationErrors, isFullMode: true }}
|
|
1356
|
-
onStateChange={onStateChange}
|
|
1357
|
-
/>
|
|
1358
|
-
);
|
|
1359
|
-
|
|
1360
|
-
await act(async () => {
|
|
1361
|
-
jest.advanceTimersByTime(500);
|
|
1362
|
-
await Promise.resolve();
|
|
1363
|
-
await Promise.resolve();
|
|
1364
|
-
await Promise.resolve();
|
|
1365
|
-
});
|
|
1366
|
-
|
|
1367
|
-
await waitFor(() => {
|
|
1368
|
-
expect(validationState).toBeDefined();
|
|
1369
|
-
});
|
|
1370
|
-
|
|
1371
|
-
expect(validationState.hasBlockingErrors).toBe(true);
|
|
1372
|
-
});
|
|
1373
|
-
});
|
|
1374
1245
|
});
|
|
@@ -77,7 +77,6 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
77
77
|
enableSanitization = true,
|
|
78
78
|
securityLevel = 'standard',
|
|
79
79
|
apiValidationErrors = null, // API validation errors from validateLiquidTemplateContent
|
|
80
|
-
isFullMode = false, // When true, skip liquid validation (standalone/full mode)
|
|
81
80
|
} = options;
|
|
82
81
|
|
|
83
82
|
// Validation state
|
|
@@ -138,7 +137,7 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
138
137
|
|
|
139
138
|
try {
|
|
140
139
|
// 1. HTML Validation
|
|
141
|
-
const htmlValidation = validateHTML(htmlContent, variant, formatValidatorMessage
|
|
140
|
+
const htmlValidation = validateHTML(htmlContent, variant, formatValidatorMessage);
|
|
142
141
|
|
|
143
142
|
// 2. CSS Validation (extract from HTML)
|
|
144
143
|
const cssValidation = extractAndValidateCSS(htmlContent, formatValidatorMessage);
|
|
@@ -207,7 +206,7 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
207
206
|
},
|
|
208
207
|
}));
|
|
209
208
|
}
|
|
210
|
-
}, [variant, enableSanitization, securityLevel, formatSanitizerMessage, formatValidatorMessage
|
|
209
|
+
}, [variant, enableSanitization, securityLevel, formatSanitizerMessage, formatValidatorMessage]);
|
|
211
210
|
|
|
212
211
|
/**
|
|
213
212
|
* Validates content with debouncing
|
|
@@ -340,7 +339,7 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
340
339
|
*/
|
|
341
340
|
const getAllIssues = useCallback(() => {
|
|
342
341
|
// API errors (liquid + standard) are blocking – they block Save/Update/Preview/Test
|
|
343
|
-
const apiLiquidErrors = (
|
|
342
|
+
const apiLiquidErrors = (apiValidationErrors?.liquidErrors || []).map((errorMessage) => {
|
|
344
343
|
const extractedLine = extractLineNumberFromMessage(errorMessage);
|
|
345
344
|
return {
|
|
346
345
|
type: VALIDATION_SEVERITY.ERROR,
|
|
@@ -421,20 +420,19 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
421
420
|
|
|
422
421
|
// Ensure we always return an array
|
|
423
422
|
return Array.isArray(allIssues) ? allIssues : [];
|
|
424
|
-
}, [validationState, apiValidationErrors, extractLineNumberFromMessage, content
|
|
423
|
+
}, [validationState, apiValidationErrors, extractLineNumberFromMessage, content]);
|
|
425
424
|
|
|
426
425
|
/**
|
|
427
426
|
* Check if validation is clean (no errors or warnings)
|
|
428
427
|
* Includes API validation errors in the check
|
|
429
428
|
*/
|
|
430
429
|
const isClean = useCallback(() => {
|
|
431
|
-
const
|
|
432
|
-
const hasApiErrors = liquidErrorCount + (apiValidationErrors?.standardErrors?.length || 0) > 0;
|
|
430
|
+
const hasApiErrors = (apiValidationErrors?.liquidErrors?.length || 0) + (apiValidationErrors?.standardErrors?.length || 0) > 0;
|
|
433
431
|
return validationState.summary.totalErrors === 0
|
|
434
432
|
&& validationState.summary.totalWarnings === 0
|
|
435
433
|
&& !validationState.summary.hasSecurityIssues
|
|
436
434
|
&& !hasApiErrors;
|
|
437
|
-
}, [validationState.summary, apiValidationErrors
|
|
435
|
+
}, [validationState.summary, apiValidationErrors]);
|
|
438
436
|
|
|
439
437
|
// Effect to validate content when it changes
|
|
440
438
|
useEffect(() => {
|
|
@@ -450,12 +448,11 @@ export const useValidation = (content, variant = 'email', options = {}, formatSa
|
|
|
450
448
|
}
|
|
451
449
|
}, []);
|
|
452
450
|
|
|
453
|
-
const
|
|
454
|
-
const hasApiErrors = hasApiLiquidErrors || (apiValidationErrors?.standardErrors?.length || 0) > 0;
|
|
451
|
+
const hasApiErrors = (apiValidationErrors?.liquidErrors?.length || 0) + (apiValidationErrors?.standardErrors?.length || 0) > 0;
|
|
455
452
|
|
|
456
453
|
const protocolTypes = ['JavaScript Protocol', 'Data URL', 'VBScript Protocol'];
|
|
457
|
-
// Client-side Liquid validation errors are blocking (genuine syntax errors)
|
|
458
|
-
const hasClientSideLiquidErrors =
|
|
454
|
+
// Client-side Liquid validation errors are blocking (genuine syntax errors)
|
|
455
|
+
const hasClientSideLiquidErrors = (validationState.htmlErrors || []).some((e) => e.source === ISSUE_SOURCES.LIQUID && e.severity === VALIDATION_SEVERITY.ERROR);
|
|
459
456
|
const hasBlockingErrors = (validationState.sanitizationWarnings || []).some((w) => BLOCKING_ERROR_RULE_IDS.includes(w.rule)) || (validationState.securityIssues || []).some((s) => protocolTypes.includes(s?.type)) || hasApiErrors || hasClientSideLiquidErrors;
|
|
460
457
|
|
|
461
458
|
return {
|
|
@@ -76,7 +76,7 @@ const CUSTOM_VALIDATIONS = {
|
|
|
76
76
|
* @param {Function} formatMessage - Message formatter function for internationalization
|
|
77
77
|
* @returns {Object} Validation result with errors and warnings
|
|
78
78
|
*/
|
|
79
|
-
export const validateHTML = (html, variant = 'email', formatMessage = defaultMessageFormatter
|
|
79
|
+
export const validateHTML = (html, variant = 'email', formatMessage = defaultMessageFormatter) => {
|
|
80
80
|
if (!html || typeof html !== 'string') {
|
|
81
81
|
return {
|
|
82
82
|
isValid: true,
|
|
@@ -133,9 +133,7 @@ export const validateHTML = (html, variant = 'email', formatMessage = defaultMes
|
|
|
133
133
|
// Always run custom validations and Liquid validation, even if HTMLHint failed
|
|
134
134
|
// This ensures unsafe protocol detection and other critical validations still run
|
|
135
135
|
runCustomValidations(html, variant, results, formatMessage);
|
|
136
|
-
|
|
137
|
-
runLiquidValidation(html, variant, results, formatMessage);
|
|
138
|
-
}
|
|
136
|
+
runLiquidValidation(html, variant, results, formatMessage);
|
|
139
137
|
|
|
140
138
|
return results;
|
|
141
139
|
};
|
|
@@ -40,11 +40,6 @@ function BeePopupEditor(props) {
|
|
|
40
40
|
const savedCallback = useRef();
|
|
41
41
|
const beeInstanceRef = useRef(null);
|
|
42
42
|
const isInitializedRef = useRef(false);
|
|
43
|
-
const beeJsonRef = useRef(beeJson);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
beeJsonRef.current = beeJson;
|
|
47
|
-
}, [beeJson]);
|
|
48
43
|
|
|
49
44
|
const [visibleTaglist, setVisibleTaglist] = useState(false);
|
|
50
45
|
const [selectedTag, setSelectedTag] = useState({});
|
|
@@ -116,10 +111,8 @@ function BeePopupEditor(props) {
|
|
|
116
111
|
window.BeePlugin.create(tokenData, beeConfig, (instance) => {
|
|
117
112
|
beePluginInstance = instance;
|
|
118
113
|
beeInstanceRef.current = instance;
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
const latestBeeJson = beeJsonRef.current;
|
|
122
|
-
const parseJson = typeof latestBeeJson === 'string' ? JSON.parse(latestBeeJson) : latestBeeJson;
|
|
114
|
+
// Check if beeJson is already an object (happens when layout type changes)
|
|
115
|
+
const parseJson = typeof beeJson === 'string' ? JSON.parse(beeJson) : beeJson;
|
|
123
116
|
beePluginInstance.start(parseJson);
|
|
124
117
|
saveBeeInstance(beePluginInstance, device);
|
|
125
118
|
isInitializedRef.current = true;
|
|
@@ -1078,38 +1078,8 @@ export function SlideBoxContent(props) {
|
|
|
1078
1078
|
)}
|
|
1079
1079
|
|
|
1080
1080
|
{isCreateInApp && (
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewEditorFlowInAppEnabled()) ? (
|
|
1084
|
-
<InApp
|
|
1085
|
-
key="creatives-inapp-create"
|
|
1086
|
-
location={{ pathname: '/inapp/create', query, search: '' }}
|
|
1087
|
-
setIsLoadingContent={setIsLoadingContent}
|
|
1088
|
-
isGetFormData={isGetFormData}
|
|
1089
|
-
getFormData={getFormData}
|
|
1090
|
-
getDefaultTags={type}
|
|
1091
|
-
isFullMode={isFullMode}
|
|
1092
|
-
templateData={templateData}
|
|
1093
|
-
cap={cap}
|
|
1094
|
-
showTemplateName={showTemplateName}
|
|
1095
|
-
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
1096
|
-
onValidationFail={onValidationFail}
|
|
1097
|
-
forwardedTags={forwardedTags}
|
|
1098
|
-
selectedOfferDetails={selectedOfferDetails}
|
|
1099
|
-
onPreviewContentClicked={onPreviewContentClicked}
|
|
1100
|
-
onTestContentClicked={onTestContentClicked}
|
|
1101
|
-
eventContextTags={eventContextTags}
|
|
1102
|
-
onCreateComplete={onCreateComplete}
|
|
1103
|
-
handleClose={handleClose}
|
|
1104
|
-
moduleType={moduleType}
|
|
1105
|
-
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
1106
|
-
handleTestAndPreview={handleTestAndPreview}
|
|
1107
|
-
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
1108
|
-
isTestAndPreviewMode={isTestAndPreviewMode}
|
|
1109
|
-
/>
|
|
1110
|
-
) : (
|
|
1111
|
-
<InAppWrapper
|
|
1112
|
-
key="creatives-inapp-wrapper"
|
|
1081
|
+
<InAppWrapper
|
|
1082
|
+
key="creatives-inapp-wrapper"
|
|
1113
1083
|
date={new Date().getMilliseconds()}
|
|
1114
1084
|
setIsLoadingContent={setIsLoadingContent}
|
|
1115
1085
|
onInAppEditorTypeChange={onInAppEditorTypeChange}
|
|
@@ -1144,12 +1114,10 @@ export function SlideBoxContent(props) {
|
|
|
1144
1114
|
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
1145
1115
|
isTestAndPreviewMode={isTestAndPreviewMode}
|
|
1146
1116
|
/>
|
|
1147
|
-
)
|
|
1148
1117
|
)}
|
|
1149
|
-
|
|
1118
|
+
|
|
1150
1119
|
{isEditInApp && (<InApp
|
|
1151
1120
|
isFullMode={isFullMode}
|
|
1152
|
-
isLoyaltyModule={isLoyaltyModule}
|
|
1153
1121
|
templateData={templateData}
|
|
1154
1122
|
getFormData={getFormData}
|
|
1155
1123
|
getDefaultTags={type}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
3
|
+
|
|
3
4
|
import { SlideBoxContent } from '../SlideBoxContent';
|
|
4
5
|
import mockdata from '../../mockdata';
|
|
5
6
|
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
@@ -41,15 +42,6 @@ jest.mock('../../WebPush', () => ({
|
|
|
41
42
|
),
|
|
42
43
|
}));
|
|
43
44
|
|
|
44
|
-
jest.mock('v2Containers/InApp', () => () => <div data-test="inapp" />);
|
|
45
|
-
jest.mock('v2Containers/InAppWrapper', () => () => <div data-test="inapp-wrapper" />);
|
|
46
|
-
|
|
47
|
-
jest.mock('../../../utils/commonUtils', () => ({
|
|
48
|
-
hasNewEditorFlowInAppEnabled: jest.fn(),
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
import commonUtil from '../../../utils/commonUtils';
|
|
52
|
-
|
|
53
45
|
describe('Test SlideBoxContent container', () => {
|
|
54
46
|
const onCreateComplete = jest.fn();
|
|
55
47
|
let renderedComponent;
|
|
@@ -918,64 +910,4 @@ describe('Test SlideBoxContent container', () => {
|
|
|
918
910
|
expect(renderedComponent).toMatchSnapshot();
|
|
919
911
|
});
|
|
920
912
|
});
|
|
921
|
-
|
|
922
|
-
describe('InApp vs InAppWrapper rendering conditions', () => {
|
|
923
|
-
|
|
924
|
-
beforeEach(() => {
|
|
925
|
-
jest.clearAllMocks();
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
it('renders InAppWrapper when isFullMode=true and new editor disabled', () => {
|
|
929
|
-
commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);
|
|
930
|
-
|
|
931
|
-
renderFunction(
|
|
932
|
-
'INAPP',
|
|
933
|
-
'createTemplate',
|
|
934
|
-
{ mode: 'create' },
|
|
935
|
-
{ isFullMode: true, isLoyaltyModule: false }
|
|
936
|
-
);
|
|
937
|
-
|
|
938
|
-
expect(renderedComponent).toMatchSnapshot();
|
|
939
|
-
});
|
|
940
|
-
|
|
941
|
-
it('renders InApp when isFullMode=false and loyalty module enabled', () => {
|
|
942
|
-
commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);
|
|
943
|
-
|
|
944
|
-
renderFunction(
|
|
945
|
-
'INAPP',
|
|
946
|
-
'createTemplate',
|
|
947
|
-
{ mode: 'create' },
|
|
948
|
-
{ isFullMode: false, isLoyaltyModule: true }
|
|
949
|
-
);
|
|
950
|
-
|
|
951
|
-
expect(renderedComponent).toMatchSnapshot();
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
it('renders InApp when not full mode, not loyalty and new editor disabled', () => {
|
|
955
|
-
commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);
|
|
956
|
-
|
|
957
|
-
renderFunction(
|
|
958
|
-
'INAPP',
|
|
959
|
-
'createTemplate',
|
|
960
|
-
{ mode: 'create' },
|
|
961
|
-
{ isFullMode: false, isLoyaltyModule: false }
|
|
962
|
-
);
|
|
963
|
-
|
|
964
|
-
expect(renderedComponent).toMatchSnapshot();
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
it('renders InAppWrapper when full mode and new editor enabled', () => {
|
|
968
|
-
commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(true);
|
|
969
|
-
|
|
970
|
-
renderFunction(
|
|
971
|
-
'INAPP',
|
|
972
|
-
'createTemplate',
|
|
973
|
-
{ mode: 'create' },
|
|
974
|
-
{ isFullMode: true, isLoyaltyModule: false }
|
|
975
|
-
);
|
|
976
|
-
|
|
977
|
-
expect(renderedComponent).toMatchSnapshot();
|
|
978
|
-
});
|
|
979
|
-
|
|
980
|
-
});
|
|
981
913
|
});
|