@capillarytech/creatives-library 7.17.90 → 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.
@@ -1,15 +1,20 @@
1
- import { take, fork, cancel } 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 } from '../sagas';
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';
5
7
  import {
6
8
  LOGIN_REQUEST,
7
9
  LOGIN_FAILURE,
8
10
  LOGOUT_REQUEST_V2,
9
11
  GET_SCHEMA_FOR_ENTITY_SUCCESS,
10
- GET_SCHEMA_FOR_ENTITY_FAILURE
12
+ GET_SCHEMA_FOR_ENTITY_FAILURE,
13
+ GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
14
+ GET_SUPPORT_VIDEOS_CONFIG_SUCCESS,
15
+ GET_SUPPORT_VIDEOS_CONFIG_FAILURE,
11
16
  } from '../constants';
12
- import { fetchSchemaForEntity as fetchSchemaForEntityApi } from "../../../services/api";
17
+ import { callback, error, error2, videoConfigData } from '../../mockdata';
13
18
 
14
19
  describe('loginFlow', () => {
15
20
  it('should handle the login flow', () => {
@@ -45,7 +50,7 @@ describe("fetchSchemaForEntity", () => {
45
50
  })
46
51
  .provide([
47
52
  [
48
- matchers.call.fn(fetchSchemaForEntityApi),
53
+ matchers.call.fn(api.fetchSchemaForEntity),
49
54
  {
50
55
  success: true,
51
56
  response: {},
@@ -69,7 +74,7 @@ describe("fetchSchemaForEntity", () => {
69
74
  })
70
75
  .provide([
71
76
  [
72
- matchers.call.fn(fetchSchemaForEntityApi),
77
+ matchers.call.fn(api.fetchSchemaForEntity),
73
78
  {
74
79
  response: {
75
80
  metaEntities: []
@@ -92,7 +97,7 @@ describe("fetchSchemaForEntity", () => {
92
97
  expectSaga(fetchSchemaForEntity, {})
93
98
  .provide([
94
99
  [
95
- matchers.call.fn(fetchSchemaForEntityApi),
100
+ matchers.call.fn(api.fetchSchemaForEntity),
96
101
  {
97
102
  success: true
98
103
  },
@@ -115,7 +120,7 @@ describe("fetchSchemaForEntity", () => {
115
120
  })
116
121
  .provide([
117
122
  [
118
- matchers.call.fn(fetchSchemaForEntityApi),
123
+ matchers.call.fn(api.fetchSchemaForEntity),
119
124
  {
120
125
  success: false,
121
126
  response: {},
@@ -128,4 +133,67 @@ describe("fetchSchemaForEntity", () => {
128
133
  })
129
134
  .run();
130
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
+ });
131
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('makeSelectLocationState', () => {
6
- it('should select the route as a plain JS object', () => {
7
- const route = fromJS({
8
- locationBeforeTransitions: null,
9
- });
10
- const mockedState = fromJS({
11
- route,
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
- it('should return cached js routeState for same concurrent calls', () => {
17
- const route = fromJS({
18
- locationBeforeTransitions: null,
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
- const mockedState = fromJS({
21
- route,
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
- const selectLocationState = makeSelectLocationState();
37
+ });
24
38
 
25
- const firstRouteStateJS = selectLocationState(mockedState);
26
- expect(selectLocationState(mockedState)).toBe(firstRouteStateJS);
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>