@capillarytech/creatives-library 8.0.114-alpha.2 → 8.0.115
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 +1 -1
- package/v2Components/ErrorInfoNote/ErrorTypeRenderer.js +3 -5
- package/v2Components/ErrorInfoNote/utils.js +12 -0
- package/v2Components/ErrorInfoNote/utils.test.js +34 -1
- package/v2Containers/InApp/index.js +2 -1
- package/v2Containers/Whatsapp/constants.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +57476 -0
- package/v2Containers/Whatsapp/tests/index.test.js +88 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import CapDivider from "@capillarytech/cap-ui-library/CapDivider";
|
|
5
|
-
import { getLiquidProps } from './utils';
|
|
5
|
+
import { getLiquidProps, hasPlatformErrors } from './utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Renders error sections for either generic (non-platform) or platform-specific (Android/iOS) errors.
|
|
@@ -49,10 +49,8 @@ const ErrorTypeRenderer = ({
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Render platform-specific errors (Android/iOS)
|
|
52
|
-
const hasAndroid = (androidErrors
|
|
53
|
-
|
|
54
|
-
const hasIos = (iosErrors?.standard?.errorsToShow?.length || 0) > 0
|
|
55
|
-
|| (iosErrors?.liquid?.errorsToShow?.length || 0) > 0;
|
|
52
|
+
const hasAndroid = hasPlatformErrors(androidErrors);
|
|
53
|
+
const hasIos = hasPlatformErrors(iosErrors);
|
|
56
54
|
|
|
57
55
|
if (!hasAndroid && !hasIos) return null;
|
|
58
56
|
|
|
@@ -36,3 +36,15 @@ export const getLiquidProps = (errors, isAndroid,showTitle,showPlatformLabels) =
|
|
|
36
36
|
liquidError: !!errors?.liquid?.errorsToShow?.length,
|
|
37
37
|
platformLabel: showPlatformLabels ? (isAndroid ? ANDROID : IOS) : null,
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if either standard or liquid errorsToShow arrays have length > 0.
|
|
42
|
+
* @param {Object} errors - The error object for a platform (androidErrors or iosErrors)
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
export const hasPlatformErrors = (errors) => {
|
|
46
|
+
if (!errors) return false;
|
|
47
|
+
const standardLength = errors?.standard?.errorsToShow?.length || 0;
|
|
48
|
+
const liquidLength = errors?.liquid?.errorsToShow?.length || 0;
|
|
49
|
+
return standardLength > 0 || liquidLength > 0;
|
|
50
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { processErrors, getLiquidProps } from './utils';
|
|
1
|
+
import { processErrors, getLiquidProps, hasPlatformErrors } from './utils';
|
|
2
2
|
|
|
3
3
|
const makeMessages = (overrides = {}) => ({
|
|
4
4
|
standardErrorHeader: { id: 'standard', defaultMessage: 'Standard' },
|
|
@@ -154,3 +154,36 @@ describe('getLiquidProps', () => {
|
|
|
154
154
|
expect(result.platformLabel).toBe(ANDROID);
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
describe('hasPlatformErrors', () => {
|
|
159
|
+
it('returns false for null, undefined, or empty object', () => {
|
|
160
|
+
expect(hasPlatformErrors(null)).toBe(false);
|
|
161
|
+
expect(hasPlatformErrors(undefined)).toBe(false);
|
|
162
|
+
expect(hasPlatformErrors({})).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('returns false if both standard.errorsToShow and liquid.errorsToShow are missing or empty', () => {
|
|
166
|
+
expect(hasPlatformErrors({ standard: { errorsToShow: [] }, liquid: { errorsToShow: [] } })).toBe(false);
|
|
167
|
+
expect(hasPlatformErrors({ standard: {}, liquid: {} })).toBe(false);
|
|
168
|
+
expect(hasPlatformErrors({})).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('returns true if standard.errorsToShow has items', () => {
|
|
172
|
+
expect(hasPlatformErrors({ standard: { errorsToShow: [1, 2] }, liquid: { errorsToShow: [] } })).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('returns true if liquid.errorsToShow has items', () => {
|
|
176
|
+
expect(hasPlatformErrors({ standard: { errorsToShow: [] }, liquid: { errorsToShow: [1] } })).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('returns true if both standard and liquid errorsToShow have items', () => {
|
|
180
|
+
expect(hasPlatformErrors({ standard: { errorsToShow: [1] }, liquid: { errorsToShow: [2] } })).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('handles missing standard or liquid keys gracefully', () => {
|
|
184
|
+
expect(hasPlatformErrors({ standard: { errorsToShow: [1] } })).toBe(true);
|
|
185
|
+
expect(hasPlatformErrors({ liquid: { errorsToShow: [2] } })).toBe(true);
|
|
186
|
+
expect(hasPlatformErrors({ standard: {}, liquid: undefined })).toBe(false);
|
|
187
|
+
expect(hasPlatformErrors({ standard: undefined, liquid: {} })).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -81,7 +81,7 @@ export const InApp = (props) => {
|
|
|
81
81
|
currentOrgDetails,
|
|
82
82
|
fetchingLiquidValidation,
|
|
83
83
|
} = props || {};
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
const { formatMessage } = intl;
|
|
86
86
|
const [titleAndroid, setTitleAndroid] = useState("");
|
|
87
87
|
const [titleIos, setTitleIos] = useState("");
|
|
@@ -784,6 +784,7 @@ export const InApp = (props) => {
|
|
|
784
784
|
});
|
|
785
785
|
};
|
|
786
786
|
|
|
787
|
+
const isLiquidFlow = hasLiquidSupportFeature();
|
|
787
788
|
return (
|
|
788
789
|
<CapSpin spinning={spin || fetchingLiquidValidation} tip={fetchingLiquidValidation ? <FormattedMessage {...formBuilderMessages.liquidSpinText} /> : ""}>
|
|
789
790
|
<CapRow className="cap-inapp-creatives">
|
|
@@ -80,7 +80,7 @@ export const mediaTypeOptions = ({host, templateCategory}) => {
|
|
|
80
80
|
tagColor: CAP_GREEN02,
|
|
81
81
|
tagTextColor: CAP_GREEN01,
|
|
82
82
|
},
|
|
83
|
-
...(templateCategory === WHATSAPP_CATEGORIES.marketing
|
|
83
|
+
...(templateCategory === WHATSAPP_CATEGORIES.marketing && host === HOST_GUPSHUP
|
|
84
84
|
? [
|
|
85
85
|
{
|
|
86
86
|
key: 'CAROUSEL',
|