@capillarytech/creatives-library 8.0.26 → 8.0.27

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.
Files changed (50) hide show
  1. package/containers/Cap/selectors.js +1 -2
  2. package/containers/Cap/tests/__snapshots__/index.test.js.snap +8 -0
  3. package/containers/Cap/tests/selectors.test.js +28 -0
  4. package/containers/LanguageProvider/tests/index.test.js +8 -30
  5. package/package.json +5 -8
  6. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +5 -2
  7. package/tests/store.test.js +5 -4
  8. package/utils/ApiCaller.js +0 -12
  9. package/utils/test-utils.js +4 -8
  10. package/utils/tests/cdnTransformation.test.js +1 -1
  11. package/v2Components/CapDeviceContent/tests/index.test.js +5 -12
  12. package/v2Components/Ckeditor/tests/index.test.js +3 -15
  13. package/v2Components/FormBuilder/tests/index.test.js +3 -2
  14. package/v2Components/NavigationBar/tests/index.test.js +3 -2
  15. package/v2Components/NewCallTask/tests/index.test.js +3 -2
  16. package/v2Containers/Cap/index.js +0 -5
  17. package/v2Containers/Cap/tests/Cap.test.js +7 -16
  18. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +8 -0
  19. package/v2Containers/Cap/tests/selectors.test.js +26 -27
  20. package/v2Containers/CreativesContainer/index.js +1 -1
  21. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +3 -2
  22. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +9 -9
  23. package/v2Containers/Email/tests/sagas.test.js +27 -23
  24. package/v2Containers/InApp/tests/index.test.js +3 -11
  25. package/v2Containers/InApp/tests/sagas.test.js +10 -13
  26. package/v2Containers/LanguageProvider/tests/index.test.js +11 -19
  27. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +90 -287
  28. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +58 -116
  29. package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +3 -2
  30. package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +3 -2
  31. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +396 -254
  32. package/v2Containers/Line/Container/Wrapper/tests/index.test.js +3 -11
  33. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +215 -395
  34. package/v2Containers/Line/Container/tests/index.test.js +4 -3
  35. package/v2Containers/MobilePush/Edit/index.js +7 -8
  36. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +133186 -146971
  37. package/v2Containers/Rcs/tests/index.test.js +4 -12
  38. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +169 -31
  39. package/v2Containers/SmsTrai/Create/tests/index.test.js +10 -15
  40. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +1457 -817
  41. package/v2Containers/SmsTrai/Edit/tests/index.test.js +3 -14
  42. package/v2Containers/TagList/tests/TagList.test.js +3 -2
  43. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +20 -14
  44. package/v2Containers/TemplatesV2/index.js +55 -80
  45. package/v2Containers/TemplatesV2/tests/index.test.js +4 -3
  46. package/v2Containers/Viber/tests/index.test.js +3 -10
  47. package/v2Containers/Whatsapp/index.js +0 -1
  48. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +32562 -5611
  49. package/v2Containers/Whatsapp/tests/index.test.js +12 -31
  50. package/v2Containers/Zalo/tests/index.test.js +3 -11
@@ -85,7 +85,7 @@ exports[`Test SlideBoxContent container Should render correct component for line
85
85
  }
86
86
  viberBrandName=""
87
87
  />
88
- <withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon)))))
88
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
89
89
  location={
90
90
  Object {
91
91
  "pathname": "/sms/edit",
@@ -283,7 +283,7 @@ exports[`Test SlideBoxContent container Should render correct component for line
283
283
  }
284
284
  viberBrandName=""
285
285
  />
286
- <withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon)))))
286
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
287
287
  location={
288
288
  Object {
289
289
  "pathname": "/sms/edit",
@@ -453,7 +453,7 @@ exports[`Test SlideBoxContent container Should render correct component for line
453
453
  }
454
454
  viberBrandName=""
455
455
  />
456
- <withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon)))))
456
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
457
457
  location={
458
458
  Object {
459
459
  "pathname": "/sms/edit",
@@ -517,7 +517,7 @@ exports[`Test SlideBoxContent container Should render correct component for line
517
517
 
518
518
  exports[`Test SlideBoxContent container Should render correct component for rcs channel create mode 1`] = `
519
519
  <SlideBoxContent__CreativesWrapper>
520
- <withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon)))))
520
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
521
521
  getDefaultTags=""
522
522
  location={
523
523
  Object {
@@ -537,7 +537,7 @@ exports[`Test SlideBoxContent container Should render correct component for rcs
537
537
 
538
538
  exports[`Test SlideBoxContent container Should render correct component for rcs channel edit mode 1`] = `
539
539
  <SlideBoxContent__CreativesWrapper>
540
- <withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon)))))
540
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
541
541
  getDefaultTags=""
542
542
  location={
543
543
  Object {
@@ -637,7 +637,7 @@ exports[`Test SlideBoxContent container Should render correct component for rcs
637
637
 
638
638
  exports[`Test SlideBoxContent container Should render correct component for rcs channel templates mode 1`] = `
639
639
  <SlideBoxContent__CreativesWrapper>
640
- <Connect(UserIsAuthenticated(withSaga(withReducer(Connect(InjectIntl(withStyles__StyledComponent))))))
640
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(withStyles__StyledComponent))))
641
641
  FTPMode="create"
642
642
  channel="rcs"
643
643
  location={
@@ -885,7 +885,7 @@ exports[`Test SlideBoxContent container Should render correct component for vibe
885
885
 
886
886
  exports[`Test SlideBoxContent container Should render correct component for whatsapp channel create mode 1`] = `
887
887
  <SlideBoxContent__CreativesWrapper>
888
- <withSaga(withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon))))))
888
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
889
889
  onCreateComplete={[MockFunction]}
890
890
  />
891
891
  </SlideBoxContent__CreativesWrapper>
@@ -893,7 +893,7 @@ exports[`Test SlideBoxContent container Should render correct component for what
893
893
 
894
894
  exports[`Test SlideBoxContent container Should render correct component for whatsapp channel edit mode 1`] = `
895
895
  <SlideBoxContent__CreativesWrapper>
896
- <withSaga(withReducer(Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon))))))
896
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
897
897
  getDefaultTags=""
898
898
  location={
899
899
  Object {
@@ -1027,7 +1027,7 @@ Click {{3}} to unsubscribe",
1027
1027
 
1028
1028
  exports[`Test SlideBoxContent container Should render correct component for whatsapp channel templates mode 1`] = `
1029
1029
  <SlideBoxContent__CreativesWrapper>
1030
- <Connect(UserIsAuthenticated(withSaga(withReducer(Connect(InjectIntl(withStyles__StyledComponent))))))
1030
+ <Connect(UserIsAuthenticated(Connect(InjectIntl(withStyles__StyledComponent))))
1031
1031
  FTPMode="create"
1032
1032
  channel="whatsapp"
1033
1033
  location={
@@ -1,19 +1,21 @@
1
1
  import { expectSaga } from 'redux-saga-test-plan';
2
- import { takeLatest } from 'redux-saga/effects';
2
+ import { take, takeLatest, takeEvery } from 'redux-saga/effects';
3
3
  import * as matchers from 'redux-saga-test-plan/matchers';
4
+ import { LOCATION_CHANGE } from 'react-router-redux';
4
5
  import { throwError } from 'redux-saga-test-plan/providers';
5
6
  import * as types from '../constants';
6
7
  import * as sagas from '../sagas';
7
- import {transformEmailTemplates} from '../../../utils/cdnTransformation';
8
+ import {transformEmailTemplates} from '../../../utils/cdnTransformation'
8
9
 
9
10
  describe('transformEmailTemplate saga', () => {
11
+
10
12
  it('handle valid response from api', () => {
11
- const callback = () => {};
13
+ const callback = ()=>{};
12
14
  const action = {
13
- type: types.TRANSFORM_EMAIL_TEMPLATE_REQUEST,
14
- callback,
15
- template: {},
16
- };
15
+ type: types.TRANSFORM_EMAIL_TEMPLATE_REQUEST,
16
+ callback,
17
+ template: {}
18
+ };
17
19
  expectSaga(sagas.transformEmailTemplate, action)
18
20
  .provide([
19
21
  [
@@ -34,15 +36,15 @@ describe('transformEmailTemplate saga', () => {
34
36
  [matchers.call.fn(callback)],
35
37
  ])
36
38
  .run();
37
- });
39
+ })
38
40
 
39
41
  it('handles error thrown from api', () => {
40
- const callback = () => {};
42
+ const callback = ()=>{};
41
43
  const action = {
42
- type: types.TRANSFORM_EMAIL_TEMPLATE_REQUEST,
43
- callback,
44
- template: {},
45
- };
44
+ type: types.TRANSFORM_EMAIL_TEMPLATE_REQUEST,
45
+ callback,
46
+ template: {}
47
+ };
46
48
  expectSaga(sagas.transformEmailTemplate, action)
47
49
  .provide([
48
50
  [matchers.call.fn(transformEmailTemplates), throwError()],
@@ -52,13 +54,15 @@ describe('transformEmailTemplate saga', () => {
52
54
  });
53
55
 
54
56
  describe('watchTransformEmailTemplate saga', () => {
55
- let generator = null;
56
- beforeEach(() => {
57
- generator = sagas.watchTransformEmailTemplate();
58
- });
59
- it('handle valid response from api', () => {
60
- const progress1 = generator.next();
61
- const mockTask = takeLatest(types.TRANSFORM_EMAIL_TEMPLATE_REQUEST, sagas.transformEmailTemplate);
62
- expect(progress1.value).toEqual(mockTask);
63
- });
64
- });
57
+ let generator = null;
58
+ beforeEach(() => {
59
+ generator = sagas.watchTransformEmailTemplate();
60
+ });
61
+ it('handle valid response from api', () => {
62
+ const progress1 = generator.next();
63
+ const mockTask = takeLatest(types.TRANSFORM_EMAIL_TEMPLATE_REQUEST, sagas.transformEmailTemplate);
64
+ expect(progress1.value).toEqual(mockTask);
65
+ const progress2 = generator.next();
66
+ expect(progress2.value).toEqual(take(LOCATION_CHANGE));
67
+ });
68
+ });
@@ -3,7 +3,7 @@ import { injectIntl } from 'react-intl';
3
3
  import '@testing-library/jest-dom';
4
4
  import { Provider } from 'react-redux';
5
5
  import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
6
- import history from '../../../utils/history';
6
+ import { createBrowserHistory } from 'history';
7
7
  import { initialReducer } from '../../../initialReducer';
8
8
  import { InApp } from '../index';
9
9
  import { render, screen, fireEvent, within } from '../../../utils/test-utils';
@@ -27,18 +27,10 @@ const mockGlobalActions = {
27
27
  fetchSchemaForEntity: jest.fn(),
28
28
  };
29
29
 
30
- jest.mock('../../../v2Containers/TagList/index.js', () => ({
31
- __esModule: true,
32
- default: (props) => (
33
- <div className="tag-mock" {...props}>
34
- TagList
35
- </div>
36
- ),
37
- }));
38
-
39
30
  let store;
31
+ let browserHistory = createBrowserHistory();
40
32
  beforeAll(() => {
41
- store = configureStore({}, initialReducer, history);
33
+ store = configureStore({}, initialReducer, browserHistory);
42
34
  });
43
35
 
44
36
  const ComponentToRender = injectIntl(InApp);
@@ -1,6 +1,4 @@
1
- import {
2
- call, cancel, put, takeLatest,
3
- } from 'redux-saga/effects';
1
+ import { call, cancel, put, takeLatest } from 'redux-saga/effects';
4
2
  import { createMockTask } from 'redux-saga/utils';
5
3
  import * as sagas from '../sagas';
6
4
  import * as Api from '../../../services/api';
@@ -114,11 +112,11 @@ describe('test for uploadInAppAsset function', () => {
114
112
  );
115
113
 
116
114
  // Pass the mock task to the takeLatest effect
117
- expect(gen.next(mockTask).done).toBe(true);
115
+ expect(gen.next(mockTask).done).toBe(false);
118
116
 
119
117
  // Call the cancel function on the mock task to simulate cancellation
120
118
  expect(mockTask.isRunning()).toBe(true); // the task is running
121
- expect(gen.next().value).toEqual(undefined);
119
+ expect(gen.next().value).toEqual(cancel(mockTask));
122
120
  });
123
121
  });
124
122
 
@@ -214,11 +212,11 @@ describe('test for inAppTemplateCreate function', () => {
214
212
  );
215
213
 
216
214
  // Pass the mock task to the takeLatest effect
217
- expect(gen.next(mockTask).done).toBe(true);
215
+ expect(gen.next(mockTask).done).toBe(false);
218
216
 
219
217
  // Call the cancel function on the mock task to simulate cancellation
220
218
  expect(mockTask.isRunning()).toBe(true); // the task is running
221
- expect(gen.next().value).toEqual(undefined);
219
+ expect(gen.next().value).toEqual(cancel(mockTask));
222
220
  });
223
221
  });
224
222
 
@@ -314,11 +312,11 @@ describe('test for editTemplate function', () => {
314
312
  );
315
313
 
316
314
  // Pass the mock task to the takeLatest effect
317
- expect(gen.next(mockTask).done).toBe(true);
315
+ expect(gen.next(mockTask).done).toBe(false);
318
316
 
319
317
  // Call the cancel function on the mock task to simulate cancellation
320
318
  expect(mockTask.isRunning()).toBe(true); // the task is running
321
- expect(gen.next().value).toEqual(undefined);
319
+ expect(gen.next().value).toEqual(cancel(mockTask));
322
320
  });
323
321
  });
324
322
 
@@ -372,7 +370,6 @@ describe('test for getTemplateDetails', () => {
372
370
  it('should call getTemplateDetails when GET_INAPP_TEMPLATE_DETAILS_REQUEST action is dispatched', () => {
373
371
  const watcher = sagas.watchGetTemplateDetails();
374
372
  const gen = watcher.next().value;
375
-
376
373
  expect(gen).toEqual(takeLatest(types.GET_INAPP_TEMPLATE_DETAILS_REQUEST, sagas.getTemplateDetails));
377
374
  });
378
375
  it('should cancel the watcher watchGetTemplateDetails', () => {
@@ -383,12 +380,12 @@ describe('test for getTemplateDetails', () => {
383
380
  expect(gen.next().value).toEqual(
384
381
  takeLatest(types.GET_INAPP_TEMPLATE_DETAILS_REQUEST, sagas.getTemplateDetails),
385
382
  );
386
- console.log('gen.next().value', gen.next());
383
+
387
384
  // Pass the mock task to the takeLatest effect
388
- expect(gen.next(mockTask).done).toBe(true);
385
+ expect(gen.next(mockTask).done).toBe(false);
389
386
 
390
387
  // Call the cancel function on the mock task to simulate cancellation
391
388
  expect(mockTask.isRunning()).toBe(true); // the task is running
392
- expect(gen.next().value).toEqual(undefined);
389
+ expect(gen.next().value).toEqual(cancel(mockTask));
393
390
  });
394
391
  });
@@ -2,9 +2,11 @@ import React from 'react';
2
2
  import { shallow, mount } from 'enzyme';
3
3
  import { FormattedMessage, defineMessages } from 'react-intl';
4
4
  import { Provider } from 'react-redux';
5
+ import { browserHistory } from 'react-router';
6
+ import enUS from 'antd/es/locale-provider/en_US';
5
7
  import ConnectedLanguageProvider, { LanguageProvider } from '../index';
6
8
  import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
7
- import history from '../../../utils/history';
9
+ import { createBrowserHistory } from 'history';
8
10
  import { initialReducer } from '../../../initialReducer';
9
11
 
10
12
  import { translationMessages } from '../../../i18n';
@@ -23,24 +25,13 @@ jest.mock('antd/es/locale-provider/ja_JP', () => 'jaJP');
23
25
 
24
26
  describe('<LanguageProvider />', () => {
25
27
  it('should render its children', () => {
26
- const mockActions = {
27
- getLocizMessage: jest.fn(),
28
- };
29
-
30
- const language = {
31
- locale : 'en',
32
- }
33
-
34
- const props = {
35
- messages : messages,
36
- language: language,
37
- actions: mockActions,
38
- };
39
-
40
- const children = <h1>Test</h1>
41
-
28
+ const children = (<h1>Test</h1>);
42
29
  const renderedComponent = shallow(
43
- <LanguageProvider {...props}>
30
+ <LanguageProvider
31
+ messages={messages}
32
+ language={{
33
+ locale: 'en',
34
+ }}>
44
35
  {children}
45
36
  </LanguageProvider>
46
37
  );
@@ -50,9 +41,10 @@ describe('<LanguageProvider />', () => {
50
41
 
51
42
  describe('<ConnectedLanguageProvider />', () => {
52
43
  let store;
44
+ let browserHistory = createBrowserHistory();
53
45
 
54
46
  beforeAll(() => {
55
- store = configureStore({}, initialReducer, history);
47
+ store = configureStore({}, initialReducer, browserHistory);
56
48
  });
57
49
 
58
50
  it('should render the default language messages', () => {