@capillarytech/creatives-library 7.17.6-alpha.0 → 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,7 +29,7 @@ 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
35
|
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
@@ -115,13 +115,14 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
115
115
|
return pane;
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
// This data will be available when it will be accessed in full mode
|
|
118
119
|
const { accessibleFeatures = [] } = currentOrgDetails || {};
|
|
120
|
+
// This data will be available when it will be accessed in library mode
|
|
119
121
|
const { currentOrgDetails: { accessibleFeatures: libModeAccessibleFeatures = [] } = {} } = cap || {};
|
|
120
|
-
const hideEngagementChannel = (
|
|
122
|
+
const hideEngagementChannel = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS) || libModeAccessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
|
|
121
123
|
// Show only line and email channel content with both channel tabs if the HIDE_ENGAGEMENT_CHANNELS feature is enabled;
|
|
122
|
-
filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [
|
|
123
|
-
defaultChannel = hideEngagementChannel ?
|
|
124
|
-
// console.log("Test ### filter ", filteredPanes)
|
|
124
|
+
filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [EMAIL, LINE, ASSETS].includes(pane?.key) && pane) : filteredPanes;
|
|
125
|
+
defaultChannel = hideEngagementChannel ? EMAIL : defaultChannel;
|
|
125
126
|
|
|
126
127
|
const channel = ['sms', 'email', 'mobilepush', 'line', 'call_task'];
|
|
127
128
|
if (!isEmpty(channelsToDisable)) {
|
|
@@ -151,7 +152,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
151
152
|
if (queryItems.channel === WHATSAPP) {
|
|
152
153
|
this.channelChange(WHATSAPP);
|
|
153
154
|
}
|
|
154
|
-
if
|
|
155
|
+
if(this.props?.isFullMode){
|
|
155
156
|
this.props.templateActions.getCdnTransformationConfig();
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -306,9 +307,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
306
307
|
if (!accessiblePermissions.includes(CREATIVES_UI_VIEW)) {
|
|
307
308
|
isCreativeAccessible = false;
|
|
308
309
|
}
|
|
309
|
-
|
|
310
|
-
console.log("Test ### panes ", { pane: this.state.panes, activeKey: this.state.selectedChannel});
|
|
311
|
-
|
|
312
310
|
return (
|
|
313
311
|
!isCreativeAccessible ? <AccessForbidden /> : (
|
|
314
312
|
<div className={`${className} creatives-templates-container ${isFullMode ? 'fullmode' : 'library-mode'}`} data-testid="cap-wrapper">
|
|
@@ -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
|
+
});
|