@capillarytech/creatives-library 7.17.89 → 7.17.91-alpha.0
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/containers/App/constants.js +1 -0
- package/initialState.js +1 -0
- package/package.json +1 -1
- package/services/api.js +5 -0
- package/services/tests/api.test.js +6 -0
- package/utils/common.js +5 -0
- package/v2Components/CapTagList/index.js +45 -5
- package/v2Components/CapTagList/messages.js +8 -0
- package/v2Components/CapTagList/style.scss +21 -0
- package/v2Components/FormBuilder/index.js +19 -1
- package/v2Components/FormBuilder/messages.js +4 -0
- package/v2Containers/Cap/actions.js +4 -0
- package/v2Containers/Cap/constants.js +14 -0
- package/v2Containers/Cap/index.js +51 -3
- package/v2Containers/Cap/reducer.js +18 -3
- package/v2Containers/Cap/sagas.js +48 -2
- package/v2Containers/Cap/selectors.js +14 -0
- package/v2Containers/Cap/tests/Cap.test.js +161 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/Cap/tests/actions.test.js +11 -0
- package/v2Containers/Cap/tests/reducer.test.js +59 -0
- package/v2Containers/Cap/tests/saga.test.js +170 -2
- package/v2Containers/Cap/tests/selectors.test.js +42 -18
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +3 -0
- package/v2Containers/CreativesContainer/index.js +1 -0
- package/v2Containers/CreativesContainer/index.scss +9 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +5 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +31 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/TagList/index.js +8 -1
- package/v2Containers/Whatsapp/index.js +1 -0
- package/v2Containers/Whatsapp/selectors.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/mockdata.js +602 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// This test in written using React Testing library. Written during setting up this library to make sure tests are working.
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
import { screen } from '@testing-library/react';
|
|
6
|
+
import { Provider } from 'react-redux';
|
|
7
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
8
|
+
import configureStore from '../../../store';
|
|
9
|
+
import { render } from '../../../utils/test-utils';
|
|
10
|
+
import { Cap } from '../index';
|
|
11
|
+
import mockData from '../../mockdata';
|
|
12
|
+
const {
|
|
13
|
+
demoVideoAndLinkJSONData,
|
|
14
|
+
history,
|
|
15
|
+
location,
|
|
16
|
+
match,
|
|
17
|
+
Global,
|
|
18
|
+
} = mockData;
|
|
19
|
+
|
|
20
|
+
const ComponentToRender = injectIntl(Cap);
|
|
21
|
+
|
|
22
|
+
const renderComponent = (props) => {
|
|
23
|
+
const store = configureStore({}, null);
|
|
24
|
+
render(
|
|
25
|
+
<Provider store={store}>
|
|
26
|
+
<ComponentToRender {...props} />
|
|
27
|
+
</Provider>,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
jest.setTimeout(15000);
|
|
32
|
+
jest.mock('@capillarytech/cap-ui-utils', () => ({
|
|
33
|
+
...jest.requireActual('@capillarytech/cap-ui-utils'),
|
|
34
|
+
GA: {
|
|
35
|
+
initialize: jest.fn(),
|
|
36
|
+
timeTracker: {
|
|
37
|
+
stopTimer: jest.fn(),
|
|
38
|
+
startTimer: jest.fn(),
|
|
39
|
+
},
|
|
40
|
+
setCustomDimension: jest.fn(),
|
|
41
|
+
getCallerName: jest.fn(),
|
|
42
|
+
},
|
|
43
|
+
Auth: {
|
|
44
|
+
hasAccess: () => jest.fn(() => true),
|
|
45
|
+
hasFeatureAccess: () => jest.fn(() => true),
|
|
46
|
+
authHoc: jest.fn(),
|
|
47
|
+
initialize: jest.fn(),
|
|
48
|
+
},
|
|
49
|
+
multipleOrgSwitch: {
|
|
50
|
+
logNewTab: jest.fn(),
|
|
51
|
+
utilsGetOrgNameFromId: () => 'org2',
|
|
52
|
+
tabBeforeUnloadEventHandler: jest.fn(),
|
|
53
|
+
utilsHandleStorageChange: () => jest.fn(() => true),
|
|
54
|
+
isMultipleTabsOpen: () => jest.fn(() => true),
|
|
55
|
+
},
|
|
56
|
+
utilsSessionStorageApi: {
|
|
57
|
+
loadSessionItem: () => true,
|
|
58
|
+
saveSessionItem: jest.fn(),
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
// jest.mock('../../../components/NavigationBar');
|
|
63
|
+
|
|
64
|
+
jest.mock('@capillarytech/cap-ui-library/CapSupportVideosWrapper', () => {
|
|
65
|
+
const ChildComponent = (props) => {
|
|
66
|
+
const { targetElements } = props;
|
|
67
|
+
const DEMO_LABEL =
|
|
68
|
+
targetElements[Object.keys(targetElements)[1]]?.support_video?.target_url
|
|
69
|
+
?.default?.label;
|
|
70
|
+
return <h4>{DEMO_LABEL}</h4>;
|
|
71
|
+
};
|
|
72
|
+
return ChildComponent;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('Cap', () => {
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
jest.clearAllMocks();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const actions = {
|
|
81
|
+
authenticate: jest.fn(),
|
|
82
|
+
addMessageToQueue: jest.fn(),
|
|
83
|
+
changeOrg: jest.fn(),
|
|
84
|
+
changeOu: jest.fn(),
|
|
85
|
+
changeOuFailure: jest.fn(),
|
|
86
|
+
changeOuSuccess: jest.fn(),
|
|
87
|
+
fetchMenuSearchResults: jest.fn(),
|
|
88
|
+
clearTopbarMenuData: jest.fn(),
|
|
89
|
+
getAllUsers: jest.fn(),
|
|
90
|
+
getStartOfWeekForOrg: jest.fn(),
|
|
91
|
+
getTopbarMenuData: jest.fn(),
|
|
92
|
+
getUserData: jest.fn(),
|
|
93
|
+
loginSuccess: jest.fn(),
|
|
94
|
+
logout: jest.fn(),
|
|
95
|
+
removeMessageFromQueue: jest.fn(),
|
|
96
|
+
setActiveReportStatus: jest.fn(),
|
|
97
|
+
getSupportedLocales: jest.fn(),
|
|
98
|
+
getSupportVideosConfig: jest.fn(),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Assign the mock window object to the global object
|
|
102
|
+
const originalLocation = window.location;
|
|
103
|
+
delete window.location;
|
|
104
|
+
window.location = { ...originalLocation, pathname: '/creatives/ui/v2' };
|
|
105
|
+
|
|
106
|
+
const props = {
|
|
107
|
+
demoVideoAndLinkJSONData,
|
|
108
|
+
history,
|
|
109
|
+
location: { ...location, query: { type: '' }},
|
|
110
|
+
match,
|
|
111
|
+
Global,
|
|
112
|
+
actions,
|
|
113
|
+
appActions: {
|
|
114
|
+
getSidebar: jest.fn(),
|
|
115
|
+
},
|
|
116
|
+
loader: { localeLoading: false },
|
|
117
|
+
intl: { formatMessage: jest.fn() },
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const mockReplaceDynamicAndCompare = () => {
|
|
121
|
+
// Mocking replaceDynamicAndCompare function to get the currentPathJSON
|
|
122
|
+
jest.mock(
|
|
123
|
+
'@capillarytech/cap-ui-library/CapSupportVideosWrapper/utils',
|
|
124
|
+
() => ({
|
|
125
|
+
replaceDynamicAndCompare: jest.fn((pathname, route) => {
|
|
126
|
+
if (pathname === '/creatives/ui/v2') {
|
|
127
|
+
return {
|
|
128
|
+
target_elements: { element1: 'video1', element2: 'video2' },
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}),
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const { findByText, queryByText } = screen;
|
|
138
|
+
|
|
139
|
+
it('Should show Demo text for video support', async () => {
|
|
140
|
+
mockReplaceDynamicAndCompare();
|
|
141
|
+
renderComponent(props);
|
|
142
|
+
expect(await findByText(/Demo/i)).toBeInTheDocument();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('Should show Demo text for video support with orgLocale if userLocal is not present', async () => {
|
|
146
|
+
mockReplaceDynamicAndCompare();
|
|
147
|
+
const updatedProps = cloneDeep(props);
|
|
148
|
+
delete updatedProps.Global.user.lang;
|
|
149
|
+
renderComponent(updatedProps);
|
|
150
|
+
expect(await findByText(/Demo/i)).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('Should not show Demo text for video support if targetELements not found', async () => {
|
|
154
|
+
mockReplaceDynamicAndCompare();
|
|
155
|
+
const updatedProps = cloneDeep(props);
|
|
156
|
+
delete updatedProps.demoVideoAndLinkJSONData.demoVideoAndLinkJSON
|
|
157
|
+
.json_config?.[0]?.target_elements;
|
|
158
|
+
renderComponent(updatedProps);
|
|
159
|
+
expect(queryByText(/Demo/i)).toBeNull();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -41,6 +41,7 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
41
41
|
"clearMetaEntities": [Function],
|
|
42
42
|
"clearTopbarMenuData": [Function],
|
|
43
43
|
"fetchSchemaForEntity": [Function],
|
|
44
|
+
"getSupportVideosConfig": [Function],
|
|
44
45
|
"getTopbarMenuData": [Function],
|
|
45
46
|
"getUserData": [Function],
|
|
46
47
|
"logout": [Function],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as types from '../constants';
|
|
2
|
+
import * as actions from '../actions';
|
|
3
|
+
|
|
4
|
+
describe('Test CAP actions', () => {
|
|
5
|
+
it('has a type of GET_SUPPORT_VIDEOS_CONFIG_REQUEST action', () => {
|
|
6
|
+
const expected = {
|
|
7
|
+
type: types.GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
|
|
8
|
+
};
|
|
9
|
+
expect(actions.getSupportVideosConfig()).toEqual(expected);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import {
|
|
3
|
+
GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
|
|
4
|
+
GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
|
|
5
|
+
GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
|
|
6
|
+
REQUEST,
|
|
7
|
+
SUCCESS,
|
|
8
|
+
FAILURE,
|
|
9
|
+
} from '../constants';
|
|
10
|
+
import reducer from '../reducer';
|
|
11
|
+
import initialState from '../../../initialState';
|
|
12
|
+
|
|
13
|
+
const mockedInitialState = fromJS(initialState.cap);
|
|
14
|
+
|
|
15
|
+
describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
|
|
16
|
+
it('should handle GET_SUPPORT_VIDEOS_CONFIG_REQUEST', () => {
|
|
17
|
+
const action = {
|
|
18
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
|
|
19
|
+
};
|
|
20
|
+
expect(reducer(mockedInitialState, action).toJS()).toEqual({
|
|
21
|
+
...mockedInitialState.toJS(),
|
|
22
|
+
demoVideoAndLinkJSON: {},
|
|
23
|
+
demoVideoAndLinkJSONStatus: REQUEST,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('it handles the GET_SUPPORT_VIDEOS_CONFIG_SUCCESS action', () => {
|
|
28
|
+
const result = {
|
|
29
|
+
is_active: true,
|
|
30
|
+
_id: "12345",
|
|
31
|
+
json_config: [
|
|
32
|
+
{ data: 'Test data' },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
const action = {
|
|
36
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
|
|
37
|
+
result,
|
|
38
|
+
GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
|
|
39
|
+
};
|
|
40
|
+
expect(reducer(mockedInitialState, action).toJS()).toEqual({
|
|
41
|
+
...mockedInitialState.toJS(),
|
|
42
|
+
demoVideoAndLinkJSON: result,
|
|
43
|
+
demoVideoAndLinkJSONStatus: SUCCESS,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should handle GET_SUPPORT_VIDEOS_CONFIG_FAILURE', () => {
|
|
48
|
+
const error = 'Error';
|
|
49
|
+
const action = {
|
|
50
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
|
|
51
|
+
error,
|
|
52
|
+
};
|
|
53
|
+
expect(reducer(mockedInitialState, action).toJS()).toEqual({
|
|
54
|
+
...mockedInitialState.toJS(),
|
|
55
|
+
demoVideoAndLinkJSONError: error,
|
|
56
|
+
demoVideoAndLinkJSONStatus: FAILURE,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { take, fork, cancel, takeLatest } from 'redux-saga/effects';
|
|
2
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
3
|
+
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
|
+
import { authorize, loginFlow, fetchSchemaForEntity, getSupportVideosConfig, watchForGetVideosConfig } from '../sagas';
|
|
5
|
+
import { throwError } from 'redux-saga-test-plan/providers';
|
|
6
|
+
import * as api from '../../../services/api';
|
|
3
7
|
import {
|
|
4
8
|
LOGIN_REQUEST,
|
|
5
9
|
LOGIN_FAILURE,
|
|
6
10
|
LOGOUT_REQUEST_V2,
|
|
11
|
+
GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
12
|
+
GET_SCHEMA_FOR_ENTITY_FAILURE,
|
|
13
|
+
GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
|
|
14
|
+
GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
|
|
15
|
+
GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
|
|
7
16
|
} from '../constants';
|
|
17
|
+
import { callback, error, error2, videoConfigData } from '../../mockdata';
|
|
18
|
+
|
|
8
19
|
describe('loginFlow', () => {
|
|
9
20
|
it('should handle the login flow', () => {
|
|
10
21
|
const generator = loginFlow();
|
|
@@ -28,4 +39,161 @@ describe('loginFlow', () => {
|
|
|
28
39
|
}
|
|
29
40
|
catch{}
|
|
30
41
|
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("fetchSchemaForEntity", () => {
|
|
45
|
+
it("handle success response from fetchSchemaForEntity", () => {
|
|
46
|
+
expectSaga(fetchSchemaForEntity, {
|
|
47
|
+
queryParams: {
|
|
48
|
+
type: 'tags'
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
.provide([
|
|
52
|
+
[
|
|
53
|
+
matchers.call.fn(api.fetchSchemaForEntity),
|
|
54
|
+
{
|
|
55
|
+
success: true,
|
|
56
|
+
response: {},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
])
|
|
60
|
+
.put({
|
|
61
|
+
type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
62
|
+
data: {},
|
|
63
|
+
statusCode: '',
|
|
64
|
+
entityType: 'tags'
|
|
65
|
+
})
|
|
66
|
+
.run();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("handle success response from fetchSchemaForEntity when metaEntities available", () => {
|
|
70
|
+
expectSaga(fetchSchemaForEntity, {
|
|
71
|
+
queryParams: {
|
|
72
|
+
type: 'tags'
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
.provide([
|
|
76
|
+
[
|
|
77
|
+
matchers.call.fn(api.fetchSchemaForEntity),
|
|
78
|
+
{
|
|
79
|
+
response: {
|
|
80
|
+
metaEntities: []
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
])
|
|
85
|
+
.put({
|
|
86
|
+
type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
87
|
+
data: {
|
|
88
|
+
metaEntities: []
|
|
89
|
+
},
|
|
90
|
+
statusCode: '',
|
|
91
|
+
entityType: 'tags'
|
|
92
|
+
})
|
|
93
|
+
.run();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("handle when response and query params are empty from fetchSchemaForEntity when metaEntities available", () => {
|
|
97
|
+
expectSaga(fetchSchemaForEntity, {})
|
|
98
|
+
.provide([
|
|
99
|
+
[
|
|
100
|
+
matchers.call.fn(api.fetchSchemaForEntity),
|
|
101
|
+
{
|
|
102
|
+
success: true
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
])
|
|
106
|
+
.put({
|
|
107
|
+
type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
108
|
+
data: {},
|
|
109
|
+
statusCode: '',
|
|
110
|
+
entityType: ''
|
|
111
|
+
})
|
|
112
|
+
.run();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("handle error response from fetchSchemaForEntity", () => {
|
|
116
|
+
expectSaga(fetchSchemaForEntity, {
|
|
117
|
+
queryParams: {
|
|
118
|
+
type: 'tags'
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
.provide([
|
|
122
|
+
[
|
|
123
|
+
matchers.call.fn(api.fetchSchemaForEntity),
|
|
124
|
+
{
|
|
125
|
+
success: false,
|
|
126
|
+
response: {},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
])
|
|
130
|
+
.put({
|
|
131
|
+
type: GET_SCHEMA_FOR_ENTITY_FAILURE,
|
|
132
|
+
error: 'Error in fetching tags'
|
|
133
|
+
})
|
|
134
|
+
.run();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('getSupportVideoConfig saga', () => {
|
|
139
|
+
it('handle valid response from api', () => {
|
|
140
|
+
expectSaga(getSupportVideosConfig, {
|
|
141
|
+
callback,
|
|
142
|
+
})
|
|
143
|
+
.provide([
|
|
144
|
+
[
|
|
145
|
+
matchers.call.fn(api.getSupportVideosConfig),
|
|
146
|
+
{
|
|
147
|
+
success: true,
|
|
148
|
+
status: 200,
|
|
149
|
+
data: videoConfigData,
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
])
|
|
153
|
+
.put({
|
|
154
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
|
|
155
|
+
result: videoConfigData,
|
|
156
|
+
})
|
|
157
|
+
.run();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('handle error thrown from api', () => {
|
|
161
|
+
expectSaga(getSupportVideosConfig, {
|
|
162
|
+
data: videoConfigData,
|
|
163
|
+
})
|
|
164
|
+
.provide([
|
|
165
|
+
[matchers.call.fn(api.getSupportVideosConfig), error2],
|
|
166
|
+
])
|
|
167
|
+
.put({
|
|
168
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
|
|
169
|
+
error: error2,
|
|
170
|
+
})
|
|
171
|
+
.run();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('handles error from catch block', () => {
|
|
175
|
+
expectSaga(getSupportVideosConfig, {
|
|
176
|
+
data: videoConfigData,
|
|
177
|
+
})
|
|
178
|
+
.provide([
|
|
179
|
+
[matchers.call.fn(api.getSupportVideosConfig), throwError(error)],
|
|
180
|
+
])
|
|
181
|
+
.put({
|
|
182
|
+
type: GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
|
|
183
|
+
error,
|
|
184
|
+
})
|
|
185
|
+
.run();
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('watchForGetVideosConfig saga', () => {
|
|
190
|
+
let generator = null;
|
|
191
|
+
beforeEach(() => {
|
|
192
|
+
generator = watchForGetVideosConfig();
|
|
193
|
+
});
|
|
194
|
+
it('handle valid response from api', () => {
|
|
195
|
+
expect(generator.next().value).toEqual(
|
|
196
|
+
takeLatest(GET_SUPPORT_VIDEOS_CONFIG_REQUEST, getSupportVideosConfig),
|
|
197
|
+
);
|
|
198
|
+
});
|
|
31
199
|
});
|
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
import { fromJS } from 'immutable';
|
|
2
2
|
|
|
3
|
-
import { makeSelectLocationState } from 'v2Containers/Cap/selectors';
|
|
3
|
+
import { makeSelectLocationState, makeSelectDemoVideoAndLink } from 'v2Containers/Cap/selectors';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
expect(makeSelectLocationState()(mockedState)).toEqual(route.toJS());
|
|
5
|
+
describe('CapSelectors', () => {
|
|
6
|
+
const mockState = fromJS({
|
|
7
|
+
cap: {
|
|
8
|
+
demoVideoAndLinkJSON: 'Test data',
|
|
9
|
+
demoVideoAndLinkJSONError: null,
|
|
10
|
+
demoVideoAndLinkJSONStatus: 'SUCCESS',
|
|
11
|
+
},
|
|
14
12
|
});
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
describe('makeSelectLocationState', () => {
|
|
15
|
+
it('should select the route as a plain JS object', () => {
|
|
16
|
+
const route = fromJS({
|
|
17
|
+
locationBeforeTransitions: null,
|
|
18
|
+
});
|
|
19
|
+
const mockedState = fromJS({
|
|
20
|
+
route,
|
|
21
|
+
});
|
|
22
|
+
expect(makeSelectLocationState()(mockedState)).toEqual(route.toJS());
|
|
19
23
|
});
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
|
|
25
|
+
it('should return cached js routeState for same concurrent calls', () => {
|
|
26
|
+
const route = fromJS({
|
|
27
|
+
locationBeforeTransitions: null,
|
|
28
|
+
});
|
|
29
|
+
const mockedState = fromJS({
|
|
30
|
+
route,
|
|
31
|
+
});
|
|
32
|
+
const selectLocationState = makeSelectLocationState();
|
|
33
|
+
|
|
34
|
+
const firstRouteStateJS = selectLocationState(mockedState);
|
|
35
|
+
expect(selectLocationState(mockedState)).toBe(firstRouteStateJS);
|
|
22
36
|
});
|
|
23
|
-
|
|
37
|
+
});
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
describe('makeSelectDemoVideoAndLink selector', () => {
|
|
40
|
+
it('should return the correct substate', () => {
|
|
41
|
+
const selected = makeSelectDemoVideoAndLink().resultFunc(
|
|
42
|
+
mockState.get('cap'),
|
|
43
|
+
);
|
|
44
|
+
expect(selected).toEqual({
|
|
45
|
+
demoVideoAndLinkJSON: 'Test data',
|
|
46
|
+
demoVideoAndLinkJSONError: null,
|
|
47
|
+
demoVideoAndLinkJSONStatus: 'SUCCESS',
|
|
48
|
+
});
|
|
49
|
+
});
|
|
27
50
|
});
|
|
28
51
|
});
|
|
52
|
+
|
|
@@ -88,6 +88,7 @@ export function SlideBoxHeader(props) {
|
|
|
88
88
|
{showTemplateNameHeader && templateNameRenderProp()}
|
|
89
89
|
{slidBoxContent === 'preview' && (
|
|
90
90
|
<CapHeader
|
|
91
|
+
className="support-video-elements"
|
|
91
92
|
title={<CapHeading className='slidebox-header-template-name' type="h1">{templateData.name}</CapHeading>}
|
|
92
93
|
description={<CapLabel type="label3">
|
|
93
94
|
<FormattedMessage {...messages.lastUpdated} values={{date: moment(templateData.updatedAt).format('DD MMM YYYY'), user: templateData.updatedByName}}/>
|
|
@@ -101,6 +102,7 @@ export function SlideBoxHeader(props) {
|
|
|
101
102
|
)}
|
|
102
103
|
{!showTemplateNameHeader && slidBoxContent === 'editTemplate' && (
|
|
103
104
|
<CapHeader
|
|
105
|
+
className="support-video-elements"
|
|
104
106
|
title={<FormattedMessage {...headerMessage} values={{ channel: getChannelLabel(channel) }} />}
|
|
105
107
|
description={
|
|
106
108
|
<>
|
|
@@ -131,6 +133,7 @@ export function SlideBoxHeader(props) {
|
|
|
131
133
|
)}
|
|
132
134
|
{!showTemplateNameHeader && slidBoxContent === 'createTemplate' && ( templateStep === 'modeSelection' || (templateStep === "createTemplateContent" && weChatTemplateType !== MAP_TEMPLATE) ) && (
|
|
133
135
|
<CapHeader
|
|
136
|
+
className="support-video-elements"
|
|
134
137
|
title={<FormattedMessage {...(showCreateTraiSMSHeader ? messages.UploadSMStemplates : messages.createMessageContent)} values={{channel: getChannelLabel(channel)}}/>}
|
|
135
138
|
prefix={!isFullMode && showPrefix &&
|
|
136
139
|
<PrefixWrapper>
|
|
@@ -1059,6 +1059,7 @@ export class Creatives extends React.Component {
|
|
|
1059
1059
|
<CapHeader
|
|
1060
1060
|
inline
|
|
1061
1061
|
title={name}
|
|
1062
|
+
className="support-video-elements"
|
|
1062
1063
|
description={<CapLink
|
|
1063
1064
|
title={<FormattedMessage {...messages.creativesTemplatesEditName}/>}
|
|
1064
1065
|
onClick={() => { this.setState({isEditName: true}, () => { this.showTemplateName({formData, onFormDataChange}); }); }}/>
|
|
@@ -60,4 +60,13 @@ $classPrefix: add-creatives-section;
|
|
|
60
60
|
}
|
|
61
61
|
.zalo-template-name-spacing {
|
|
62
62
|
margin-right: 8px;
|
|
63
|
+
}
|
|
64
|
+
.support-video-elements {
|
|
65
|
+
.cap-header-v2-title{
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
};
|
|
69
|
+
i {
|
|
70
|
+
height: $ICON_SIZE_M;
|
|
71
|
+
}
|
|
63
72
|
}
|
|
@@ -11,6 +11,7 @@ exports[`Test SlideBoxHeader container Should render correct component for rcs c
|
|
|
11
11
|
key="creatives-container-slidebox-header-content"
|
|
12
12
|
>
|
|
13
13
|
<CapHeader
|
|
14
|
+
className="support-video-elements"
|
|
14
15
|
description={
|
|
15
16
|
<React.Fragment>
|
|
16
17
|
|
|
@@ -45,6 +46,7 @@ exports[`Test SlideBoxHeader container Should render correct component for rcs c
|
|
|
45
46
|
key="creatives-container-slidebox-header-content"
|
|
46
47
|
>
|
|
47
48
|
<CapHeader
|
|
49
|
+
className="support-video-elements"
|
|
48
50
|
description={
|
|
49
51
|
<CapLabel
|
|
50
52
|
type="label3"
|
|
@@ -139,6 +141,7 @@ exports[`Test SlideBoxHeader container Should render correct component for whats
|
|
|
139
141
|
key="creatives-container-slidebox-header-content"
|
|
140
142
|
>
|
|
141
143
|
<CapHeader
|
|
144
|
+
className="support-video-elements"
|
|
142
145
|
description={
|
|
143
146
|
<React.Fragment>
|
|
144
147
|
<React.Fragment>
|
|
@@ -248,6 +251,7 @@ exports[`Test SlideBoxHeader container Should render correct component for whats
|
|
|
248
251
|
key="creatives-container-slidebox-header-content"
|
|
249
252
|
>
|
|
250
253
|
<CapHeader
|
|
254
|
+
className="support-video-elements"
|
|
251
255
|
description={
|
|
252
256
|
<CapLabel
|
|
253
257
|
type="label3"
|
|
@@ -317,6 +321,7 @@ exports[`Test SlideBoxHeader container Should render correct component for zalo
|
|
|
317
321
|
key="creatives-container-slidebox-header-content"
|
|
318
322
|
>
|
|
319
323
|
<CapHeader
|
|
324
|
+
className="support-video-elements"
|
|
320
325
|
description={
|
|
321
326
|
<React.Fragment>
|
|
322
327
|
<React.Fragment>
|
|
@@ -23085,6 +23085,7 @@ new message content.",
|
|
|
23085
23085
|
"app": Object {},
|
|
23086
23086
|
"cap": Object {
|
|
23087
23087
|
"fetchingSchema": true,
|
|
23088
|
+
"fetchingSchemaError": "",
|
|
23088
23089
|
"messages": Array [],
|
|
23089
23090
|
"metaEntities": Object {
|
|
23090
23091
|
"layouts": Array [],
|