@capillarytech/creatives-library 8.0.142 → 8.0.144
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/TemplatePreview/index.js +1 -1
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +1 -1
- package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +1 -1
- package/v2Components/TestAndPreviewSlidebox/tests/PreviewSection.test.js +99 -0
- package/v2Containers/BeePopupEditor/index.js +2 -2
- package/v2Containers/CreativesContainer/index.js +52 -8
- package/v2Containers/Email/index.js +1 -1
- package/v2Containers/InApp/constants.js +3 -0
- package/v2Containers/InappWrapper/_inappWrapper.scss +4 -4
- package/v2Containers/InappWrapper/index.js +4 -3
package/package.json
CHANGED
|
@@ -1336,7 +1336,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
1336
1336
|
/>
|
|
1337
1337
|
<iframe
|
|
1338
1338
|
srcDoc={inAppPreviewContent?.value}
|
|
1339
|
-
title=
|
|
1339
|
+
title={formatMessage(messages.inappPreview)}
|
|
1340
1340
|
style={{
|
|
1341
1341
|
position: 'absolute',
|
|
1342
1342
|
top: '3rem',
|
|
@@ -94,4 +94,8 @@ export default defineMessages({
|
|
|
94
94
|
id: 'creatives.componentsV2.TemplatePreview.videoNotSupported',
|
|
95
95
|
defaultMessage: 'Your browser does not support the video tag.',
|
|
96
96
|
},
|
|
97
|
+
inappPreview: {
|
|
98
|
+
id: 'creatives.componentsV2.TemplatePreview.inappPreview',
|
|
99
|
+
defaultMessage: 'Inapp Preview',
|
|
100
|
+
},
|
|
97
101
|
});
|
|
@@ -15,7 +15,7 @@ const PreviewSection = ({
|
|
|
15
15
|
formatMessage,
|
|
16
16
|
PreviewChrome,
|
|
17
17
|
}) => (
|
|
18
|
-
<CapRow className="preview-section panel-section">
|
|
18
|
+
<CapRow className="preview-section-test panel-section">
|
|
19
19
|
<PreviewChrome
|
|
20
20
|
device={previewDevice}
|
|
21
21
|
onDeviceChange={setPreviewDevice}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
import PreviewSection from '../PreviewSection';
|
|
7
|
+
|
|
8
|
+
// Mock messages for testing
|
|
9
|
+
const mockMessages = {
|
|
10
|
+
'app.v2Components.TestAndPreviewSlidebox.updatingPreview': 'Updating preview with the latest changes',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Test wrapper with IntlProvider
|
|
14
|
+
const TestWrapper = ({ children, locale = 'en' }) => (
|
|
15
|
+
<IntlProvider locale={locale} messages={mockMessages}>
|
|
16
|
+
{children}
|
|
17
|
+
</IntlProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
TestWrapper.propTypes = {
|
|
21
|
+
children: PropTypes.node.isRequired,
|
|
22
|
+
locale: PropTypes.string,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
TestWrapper.defaultProps = {
|
|
26
|
+
locale: 'en',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Mock PreviewChrome component
|
|
30
|
+
const MockPreviewChrome = ({
|
|
31
|
+
children,
|
|
32
|
+
device,
|
|
33
|
+
subject,
|
|
34
|
+
}) => (
|
|
35
|
+
<div data-testid="preview-chrome" data-device={device} data-subject={subject}>
|
|
36
|
+
{children}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
MockPreviewChrome.propTypes = {
|
|
41
|
+
children: PropTypes.node,
|
|
42
|
+
device: PropTypes.string,
|
|
43
|
+
subject: PropTypes.string,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
MockPreviewChrome.defaultProps = {
|
|
47
|
+
children: null,
|
|
48
|
+
device: 'desktop',
|
|
49
|
+
subject: '',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Default props for testing
|
|
53
|
+
const defaultProps = {
|
|
54
|
+
previewDevice: 'desktop',
|
|
55
|
+
setPreviewDevice: jest.fn(),
|
|
56
|
+
selectedCustomer: { id: 'customer-1', name: 'John Doe' },
|
|
57
|
+
formData: { 'template-subject': 'Test Email Subject' },
|
|
58
|
+
isUpdatingPreview: false,
|
|
59
|
+
previewDataHtml: null,
|
|
60
|
+
content: '<p>Default email content</p>',
|
|
61
|
+
formatMessage: jest.fn((msg) => msg.defaultMessage || 'Updating preview with the latest changes'),
|
|
62
|
+
PreviewChrome: MockPreviewChrome,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
describe('PreviewSection Component', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
jest.clearAllMocks();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should render the component with basic structure', () => {
|
|
71
|
+
render(
|
|
72
|
+
<TestWrapper>
|
|
73
|
+
<PreviewSection {...defaultProps} />
|
|
74
|
+
</TestWrapper>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Check if the main container is rendered
|
|
78
|
+
expect(screen.getByTestId('preview-chrome')).toBeInTheDocument();
|
|
79
|
+
|
|
80
|
+
// Check if PreviewChrome receives the correct props
|
|
81
|
+
const previewChrome = screen.getByTestId('preview-chrome');
|
|
82
|
+
expect(previewChrome).toHaveAttribute('data-device', 'desktop');
|
|
83
|
+
expect(previewChrome).toHaveAttribute('data-subject', 'Test Email Subject');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should show loading spinner when updating preview', () => {
|
|
87
|
+
render(
|
|
88
|
+
<TestWrapper>
|
|
89
|
+
<PreviewSection {...defaultProps} isUpdatingPreview />
|
|
90
|
+
</TestWrapper>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Check if loading container is displayed
|
|
94
|
+
expect(document.querySelector('.loading-container')).toBeInTheDocument();
|
|
95
|
+
|
|
96
|
+
// Check if CapSpin component is rendered (ant-spin class)
|
|
97
|
+
expect(document.querySelector('.ant-spin')).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -101,7 +101,7 @@ function BeePopupEditor(props) {
|
|
|
101
101
|
}, [templateLayoutType]);
|
|
102
102
|
|
|
103
103
|
useEffect(() => {
|
|
104
|
-
savedCallback.current = Object
|
|
104
|
+
savedCallback.current = Object?.keys(selectedTag)?.length > 0 && selectedTag;
|
|
105
105
|
}, [selectedTag]);
|
|
106
106
|
|
|
107
107
|
const onTagSelect = (result) => {
|
|
@@ -120,7 +120,7 @@ function BeePopupEditor(props) {
|
|
|
120
120
|
|
|
121
121
|
return (
|
|
122
122
|
<>
|
|
123
|
-
<div id="bee-plugin-container" style={{ height: "
|
|
123
|
+
<div id="bee-plugin-container" style={{ height: "46.5rem" }}></div>
|
|
124
124
|
<TagList
|
|
125
125
|
moduleFilterEnabled={moduleFilterEnabled}
|
|
126
126
|
label={label}
|
|
@@ -398,8 +398,22 @@ export class Creatives extends React.Component {
|
|
|
398
398
|
versions: {
|
|
399
399
|
base: {
|
|
400
400
|
content: {
|
|
401
|
-
ANDROID: templateData?.androidContent
|
|
402
|
-
|
|
401
|
+
ANDROID: templateData?.androidContent?.type === 'HTML' ? {
|
|
402
|
+
type: templateData?.androidContent?.type,
|
|
403
|
+
bodyType: templateData?.androidContent?.bodyType,
|
|
404
|
+
deviceType: constants.ANDROID,
|
|
405
|
+
beeHtml: { value: templateData?.androidContent?.message },
|
|
406
|
+
beeJson: templateData?.androidContent?.expandableDetails?.message,
|
|
407
|
+
isBEEeditor: true,
|
|
408
|
+
} : templateData?.androidContent,
|
|
409
|
+
IOS: templateData?.iosContent?.type === 'HTML' ? {
|
|
410
|
+
type: templateData?.iosContent?.type,
|
|
411
|
+
bodyType: templateData?.iosContent?.bodyType,
|
|
412
|
+
deviceType: constants.IOS,
|
|
413
|
+
beeHtml: { value: templateData?.iosContent?.message },
|
|
414
|
+
beeJson: templateData?.iosContent?.expandableDetails?.message,
|
|
415
|
+
isBEEeditor: true,
|
|
416
|
+
} : templateData?.iosContent,
|
|
403
417
|
},
|
|
404
418
|
},
|
|
405
419
|
},
|
|
@@ -801,9 +815,24 @@ export class Creatives extends React.Component {
|
|
|
801
815
|
if (channel === constants.MOBILE_PUSH && androidContent?.expandableDetails?.carouselData?.length) {
|
|
802
816
|
androidContent.expandableDetails = this.getMobilePushCarouselData({...androidContent?.expandableDetails});
|
|
803
817
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
818
|
+
if (androidContent?.isBEEeditor && androidContent?.beeHtml?.value) {
|
|
819
|
+
templateData.androidContent = {};
|
|
820
|
+
templateData.androidContent.type = 'TEXT';
|
|
821
|
+
// replace the TEXT in above line when backend supports HTML
|
|
822
|
+
templateData.androidContent.message = androidContent?.beeHtml?.value || '';
|
|
823
|
+
templateData.androidContent.title = 'bee free template';
|
|
824
|
+
templateData.androidContent.bodyType = androidContent?.bodyType;
|
|
825
|
+
templateData.androidContent.deviceType = constants.ANDROID;
|
|
826
|
+
templateData.androidContent.expandableDetails = {
|
|
827
|
+
style: 'BIG_TEXT',
|
|
828
|
+
// replace the BIG_TEXT in above line when backend supports HTML
|
|
829
|
+
message: androidContent?.beeJson || '',
|
|
830
|
+
};
|
|
831
|
+
} else if (!androidContent?.isBEEeditor) {
|
|
832
|
+
templateData.androidContent = androidContent;
|
|
833
|
+
templateData.androidContent.type = androidContent?.type || get(channelTemplate, 'definition.mode', '')?.toUpperCase() || constants.TEXT;
|
|
834
|
+
templateData.androidContent.deviceType = constants.ANDROID;
|
|
835
|
+
}
|
|
807
836
|
}
|
|
808
837
|
const iosContent = channel === constants.INAPP ? get(channelTemplate, 'versions.base.content.IOS') : get(channelTemplate, 'versions.base.IOS');
|
|
809
838
|
if (!isEmpty(iosContent)) {
|
|
@@ -823,9 +852,24 @@ export class Creatives extends React.Component {
|
|
|
823
852
|
if (channel === constants.MOBILE_PUSH && iosContent?.expandableDetails?.carouselData?.length) {
|
|
824
853
|
iosContent.expandableDetails = this.getMobilePushCarouselData({...iosContent?.expandableDetails});
|
|
825
854
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
855
|
+
if (iosContent?.isBEEeditor && iosContent?.beeHtml?.value) {
|
|
856
|
+
templateData.iosContent = {};
|
|
857
|
+
templateData.iosContent.type = 'TEXT';
|
|
858
|
+
// replace the TEXT in above line when backend supports HTML
|
|
859
|
+
templateData.iosContent.message = iosContent?.beeHtml?.value || '';
|
|
860
|
+
templateData.iosContent.title = 'bee free template';
|
|
861
|
+
templateData.iosContent.bodyType = iosContent?.bodyType;
|
|
862
|
+
templateData.iosContent.deviceType = constants.IOS;
|
|
863
|
+
templateData.iosContent.expandableDetails = {
|
|
864
|
+
style: 'BIG_TEXT',
|
|
865
|
+
// replace the BIG_TEXT in above line when backend supports HTML
|
|
866
|
+
message: iosContent?.beeJson || '',
|
|
867
|
+
};
|
|
868
|
+
} else if (!iosContent?.isBEEeditor) {
|
|
869
|
+
templateData.iosContent = iosContent;
|
|
870
|
+
templateData.iosContent.type = iosContent?.type || get(channelTemplate, 'definition.mode', '')?.toUpperCase() || 'TEXT';
|
|
871
|
+
templateData.iosContent.deviceType = constants.IOS;
|
|
872
|
+
}
|
|
829
873
|
}
|
|
830
874
|
templateData.messageSubject = channelTemplate?.name ? channelTemplate?.name : "messageSubject";
|
|
831
875
|
}
|
|
@@ -2709,7 +2709,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2709
2709
|
return (
|
|
2710
2710
|
<div className="email-container">
|
|
2711
2711
|
<CapSpin spinning={isLoading}>
|
|
2712
|
-
{ showTestAndPreview &&
|
|
2712
|
+
{ !showTestAndPreviewSlidebox && showTestAndPreview &&
|
|
2713
2713
|
<div className="test-and-preview-container">
|
|
2714
2714
|
{this.showTestAndPreviewIcons('PREVIEW')}
|
|
2715
2715
|
{this.showTestAndPreviewIcons('TEST')}
|
|
@@ -164,3 +164,6 @@ export const INAPP_LAYOUT_DETAILS = {
|
|
|
164
164
|
|
|
165
165
|
export const DEVICE_SUPPORTED = '1';
|
|
166
166
|
export const AI_CONTENT_BOT_DISABLED = "AI_CONTENT_BOT_DISABLED";
|
|
167
|
+
export const MODE_SELECTION = "modeSelection";
|
|
168
|
+
export const BASIC_EDITOR = "basicEditor";
|
|
169
|
+
export const BEE_EDITOR = "beeEditor";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
.ant-radio-group.cap-radioCard-v2 {
|
|
4
4
|
.ant-radio-button-wrapper{
|
|
5
|
-
width:
|
|
6
|
-
height:
|
|
5
|
+
width: 20.28rem;
|
|
6
|
+
height: 18.43rem;
|
|
7
7
|
}
|
|
8
8
|
.ant-card-body {
|
|
9
9
|
padding: 1rem;
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
.template-name-inapp {
|
|
14
|
-
width:
|
|
14
|
+
width: 41.4rem;
|
|
15
15
|
margin-bottom: 1.5rem;
|
|
16
16
|
.ant-input {
|
|
17
|
-
height:
|
|
17
|
+
height: 2.86rem;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -16,6 +16,7 @@ import InApp from "../InApp/index";
|
|
|
16
16
|
import InappAdvanced from "../InappAdvanced/index";
|
|
17
17
|
import messages from "./messages";
|
|
18
18
|
import "./_inappWrapper.scss";
|
|
19
|
+
import { BASIC_EDITOR, BEE_EDITOR, MODE_SELECTION } from "../InApp/constants";
|
|
19
20
|
|
|
20
21
|
const CapRadioCardWithLabel = ComponentWithLabelHOC(CapRadioCard);
|
|
21
22
|
const CardContainer = styled.div`
|
|
@@ -83,7 +84,7 @@ export function InappWrapper(props) {
|
|
|
83
84
|
|
|
84
85
|
return (
|
|
85
86
|
<div className="inapp-wrapper">
|
|
86
|
-
{step ===
|
|
87
|
+
{step === MODE_SELECTION ? (
|
|
87
88
|
<div>
|
|
88
89
|
{isFullMode && (
|
|
89
90
|
<CapInput
|
|
@@ -109,7 +110,7 @@ export function InappWrapper(props) {
|
|
|
109
110
|
</div>
|
|
110
111
|
) : (
|
|
111
112
|
<div>
|
|
112
|
-
{inAppCreateMode ===
|
|
113
|
+
{inAppCreateMode === BASIC_EDITOR && (
|
|
113
114
|
<InApp
|
|
114
115
|
getFormData={getFormData}
|
|
115
116
|
setIsLoadingContent={setIsLoadingContent}
|
|
@@ -134,7 +135,7 @@ export function InappWrapper(props) {
|
|
|
134
135
|
onCreateComplete={onCreateComplete}
|
|
135
136
|
/>
|
|
136
137
|
)}
|
|
137
|
-
{inAppCreateMode ===
|
|
138
|
+
{inAppCreateMode === BEE_EDITOR && (
|
|
138
139
|
<InappAdvanced
|
|
139
140
|
getFormData={getFormData}
|
|
140
141
|
setIsLoadingContent={setIsLoadingContent}
|