@capillarytech/creatives-library 8.0.143 → 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
CHANGED
|
@@ -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
|
+
});
|
|
@@ -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
|
}
|
package/assets/loading_img.gif
DELETED
|
Binary file
|