@capillarytech/creatives-library 7.17.6 → 7.17.7
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
|
@@ -50,6 +50,11 @@ export const VIBER = 'viber';
|
|
|
50
50
|
export const FACEBOOK = 'facebook';
|
|
51
51
|
export const WHATSAPP = 'whatsapp';
|
|
52
52
|
export const RCS = 'rcs';
|
|
53
|
+
export const LINE = 'line';
|
|
54
|
+
export const EMAIL = 'email';
|
|
55
|
+
export const ASSETS = 'assets';
|
|
56
|
+
|
|
57
|
+
export const HIDE_ENGAGEMENT_CHANNELS = 'HIDE_ENGAGEMENT_CHANNELS';
|
|
53
58
|
|
|
54
59
|
export const TRACK_EDIT_SMS = 'editSms';
|
|
55
60
|
export const TRACK_EDIT_EMAIL = 'editEmail';
|
|
@@ -29,9 +29,10 @@ import FTP from '../FTP';
|
|
|
29
29
|
import Gallery from '../Assets/Gallery';
|
|
30
30
|
import withStyles from '../../hoc/withStyles';
|
|
31
31
|
import styles, { CapTabStyle } from './TemplatesV2.style';
|
|
32
|
-
import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS } from '../App/constants';
|
|
32
|
+
import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, HIDE_ENGAGEMENT_CHANNELS } from '../App/constants';
|
|
33
33
|
import AccessForbidden from '../../v2Components/AccessForbidden';
|
|
34
34
|
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
35
|
+
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
35
36
|
|
|
36
37
|
const {CapCustomCardList} = CapCustomCard;
|
|
37
38
|
|
|
@@ -51,6 +52,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
51
52
|
onChannelChange,
|
|
52
53
|
showDisabledFBInfo,
|
|
53
54
|
enableNewChannels = [],
|
|
55
|
+
currentOrgDetails = {},
|
|
56
|
+
cap = {},
|
|
54
57
|
} = props;
|
|
55
58
|
|
|
56
59
|
const defaultPanes = {
|
|
@@ -112,6 +115,15 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
112
115
|
return pane;
|
|
113
116
|
});
|
|
114
117
|
|
|
118
|
+
// This data will be available when it will be accessed in full mode
|
|
119
|
+
const { accessibleFeatures = [] } = currentOrgDetails || {};
|
|
120
|
+
// This data will be available when it will be accessed in library mode
|
|
121
|
+
const { currentOrgDetails: { accessibleFeatures: libModeAccessibleFeatures = [] } = {} } = cap || {};
|
|
122
|
+
const hideEngagementChannel = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS) || libModeAccessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
|
|
123
|
+
// Show only line and email channel content with both channel tabs if the HIDE_ENGAGEMENT_CHANNELS feature is enabled;
|
|
124
|
+
filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [EMAIL, LINE, ASSETS].includes(pane?.key) && pane) : filteredPanes;
|
|
125
|
+
defaultChannel = hideEngagementChannel ? EMAIL : defaultChannel;
|
|
126
|
+
|
|
115
127
|
const channel = ['sms', 'email', 'mobilepush', 'line', 'call_task'];
|
|
116
128
|
if (!isEmpty(channelsToDisable)) {
|
|
117
129
|
channel.some((ch) => {
|
|
@@ -341,15 +353,18 @@ TemplatesV2.propTypes = {
|
|
|
341
353
|
authData: PropTypes.object,
|
|
342
354
|
FTPMode: PropTypes.string,
|
|
343
355
|
messageStrategy: PropTypes.string,
|
|
356
|
+
currentOrgDetails: PropTypes.object,
|
|
344
357
|
};
|
|
345
358
|
|
|
346
359
|
TemplatesV2.defaultProps = {
|
|
347
360
|
isFullMode: true,
|
|
361
|
+
currentOrgDetails: {},
|
|
348
362
|
};
|
|
349
363
|
|
|
350
364
|
const mapStateToProps = createStructuredSelector({
|
|
351
365
|
Templates: makeSelectTemplates(),
|
|
352
366
|
TemplatesList: makeSelectTemplatesResponse(),
|
|
367
|
+
currentOrgDetails: selectCurrentOrgDetails(),
|
|
353
368
|
});
|
|
354
369
|
|
|
355
370
|
function mapDispatchToProps(dispatch) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
5
|
+
import { Provider } from 'react-redux';
|
|
6
|
+
import configureStore from '../../../store';
|
|
7
|
+
import {
|
|
8
|
+
render,
|
|
9
|
+
screen,
|
|
10
|
+
} from '../../../utils/test-utils';
|
|
11
|
+
import { TemplatesV2 } from '../index';
|
|
12
|
+
import { Templates, authData, currentOrgDetails } from './mockData';
|
|
13
|
+
|
|
14
|
+
const ComponentToRender = injectIntl(TemplatesV2);
|
|
15
|
+
const renderComponent = (props) => {
|
|
16
|
+
const store = configureStore({}, null);
|
|
17
|
+
return render(
|
|
18
|
+
<Provider store={store}>
|
|
19
|
+
<ComponentToRender {...props} />
|
|
20
|
+
</Provider>,
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Mock the UserAuthWrapper module
|
|
25
|
+
jest.mock('../../../utils/authWrapper', () => ({
|
|
26
|
+
UserIsAuthenticated: jest.fn((config) => config),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
describe("Test TemplatesV2", () => {
|
|
30
|
+
const templateActions = {
|
|
31
|
+
templateActions: jest.fn(),
|
|
32
|
+
deleteTemplate: jest.fn(),
|
|
33
|
+
getAccountsSettings: jest.fn(),
|
|
34
|
+
getAllTemplates: jest.fn(),
|
|
35
|
+
getCdnTransformationConfig: jest.fn(),
|
|
36
|
+
getDefaultBeeTemplates: jest.fn(),
|
|
37
|
+
getSenderDetails: jest.fn(),
|
|
38
|
+
getTemplateDetails: jest.fn(),
|
|
39
|
+
getUserList: jest.fn(),
|
|
40
|
+
getWeCrmAccounts: jest.fn(),
|
|
41
|
+
handleHtmlUpload: jest.fn(),
|
|
42
|
+
handleZipUpload: jest.fn(),
|
|
43
|
+
resetAccount: jest.fn(),
|
|
44
|
+
resetTemplate: jest.fn(),
|
|
45
|
+
resetTemplateData: jest.fn(),
|
|
46
|
+
resetTemplateStoreData: jest.fn(),
|
|
47
|
+
resetUploadData: jest.fn(),
|
|
48
|
+
setBEETemplate: jest.fn(),
|
|
49
|
+
setChannelAccount: jest.fn(),
|
|
50
|
+
setEdmTemplate: jest.fn(),
|
|
51
|
+
setFacebookAccount: jest.fn(),
|
|
52
|
+
setViberAccount: jest.fn(),
|
|
53
|
+
setWeChatAccount: jest.fn(),
|
|
54
|
+
};
|
|
55
|
+
const props = {
|
|
56
|
+
actions: { defaultAction: jest.fn(), getTemplates: jest.fn() },
|
|
57
|
+
Templates,
|
|
58
|
+
TemplatesList: Templates?.templates,
|
|
59
|
+
authData,
|
|
60
|
+
templateActions,
|
|
61
|
+
isFullMode: true,
|
|
62
|
+
channelsToHide: [],
|
|
63
|
+
channelsToDisable: [],
|
|
64
|
+
onChannelChange: jest.fn(),
|
|
65
|
+
enableNewChannels: [],
|
|
66
|
+
currentOrgDetails,
|
|
67
|
+
location: {
|
|
68
|
+
pathname: "v2",
|
|
69
|
+
basename: "/creatives/ui/",
|
|
70
|
+
query: {},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const { getByText, queryByText } = screen;
|
|
74
|
+
|
|
75
|
+
it("Should show only Email, Line channels and Gallery", () => {
|
|
76
|
+
renderComponent(props);
|
|
77
|
+
expect(getByText('Email')).toBeInTheDocument();
|
|
78
|
+
expect(getByText('Line')).toBeInTheDocument();
|
|
79
|
+
expect(getByText('Gallery')).toBeInTheDocument();
|
|
80
|
+
expect(queryByText('RCS')).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("Should show all other channels", () => {
|
|
84
|
+
const updatedProps = cloneDeep(props);
|
|
85
|
+
updatedProps.currentOrgDetails.accessibleFeatures.pop();
|
|
86
|
+
renderComponent(updatedProps);
|
|
87
|
+
expect(getByText('SMS')).toBeInTheDocument();
|
|
88
|
+
expect(getByText('RCS')).toBeInTheDocument();
|
|
89
|
+
expect(getByText('Email')).toBeInTheDocument();
|
|
90
|
+
expect(getByText('Push notification')).toBeInTheDocument();
|
|
91
|
+
expect(getByText('Line')).toBeInTheDocument();
|
|
92
|
+
expect(getByText('Wechat')).toBeInTheDocument();
|
|
93
|
+
expect(getByText('Viber')).toBeInTheDocument();
|
|
94
|
+
expect(getByText('Facebook')).toBeInTheDocument();
|
|
95
|
+
expect(getByText('WhatsApp')).toBeInTheDocument();
|
|
96
|
+
expect(getByText('Gallery')).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
});
|