@capillarytech/creatives-library 7.14.9 → 7.14.10

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.
@@ -0,0 +1,3 @@
1
+ <svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M17.0026 0.333496C7.8026 0.333496 0.335938 7.80016 0.335938 17.0002C0.335938 26.2002 7.8026 33.6668 17.0026 33.6668C26.2026 33.6668 33.6693 26.2002 33.6693 17.0002C33.6693 7.80016 26.2026 0.333496 17.0026 0.333496ZM12.8359 21.4502V12.5502C12.8359 11.2335 14.3026 10.4335 15.4026 11.1502L22.3193 15.6002C23.3359 16.2502 23.3359 17.7502 22.3193 18.4002L15.4026 22.8502C14.3026 23.5668 12.8359 22.7668 12.8359 21.4502Z" fill="#091E42"/>
3
+ </svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.14.9",
4
+ "version": "7.14.10",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -20,7 +20,6 @@ function CapDocumentUpload(props) {
20
20
  documentSize,
21
21
  uploadAsset,
22
22
  supportedExtensions,
23
- style,
24
23
  documentSrc,
25
24
  updateDocumentSrc,
26
25
  updateOnReUpload,
@@ -28,7 +27,6 @@ function CapDocumentUpload(props) {
28
27
  className,
29
28
  documentData,
30
29
  channel,
31
- channelSpecificStyle,
32
30
  whatsappDocParams,
33
31
  setWhatsappDocParams,
34
32
  docPreview,
@@ -146,7 +144,6 @@ function CapDocumentUpload(props) {
146
144
  className="dragger-button re-upload"
147
145
  type="flat"
148
146
  onClick={onReUpload}
149
- style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
150
147
  >
151
148
  <FormattedMessage {...messages.docReUpload} />
152
149
  </CapButton>
@@ -154,7 +151,7 @@ function CapDocumentUpload(props) {
154
151
  }, [isDocError, documentSrc]);
155
152
 
156
153
  return (
157
- <div style={style} className="cap-custom-document-upload">
154
+ <div className="cap-custom-document-upload document-div">
158
155
  <WithLabel
159
156
  key={`with-label`}
160
157
  errorMessage={isDocError} ifError={!!isDocError}
@@ -162,7 +159,7 @@ function CapDocumentUpload(props) {
162
159
  <form encType="multipart/form-data" id={`form`} className={className}>
163
160
  <input
164
161
  key={`docFile`}
165
- style={{ display: 'none' }}
162
+ className="input-div"
166
163
  id="fileName"
167
164
  type="file"
168
165
  onChange={(e) => uploadDocuments(e, { files: e.target.files })}
@@ -191,7 +188,6 @@ CapDocumentUpload.propTypes = {
191
188
  documentSize: PropTypes.number,
192
189
  uploadAsset: PropTypes.func,
193
190
  supportedExtensions: PropTypes.any,
194
- style: PropTypes.any,
195
191
  documentSrc: PropTypes.string,
196
192
  updateDocumentSrc: PropTypes.func,
197
193
  intl: intlShape,
@@ -202,7 +198,6 @@ CapDocumentUpload.propTypes = {
202
198
  channel: PropTypes.string,
203
199
  whatsappDocParams: PropTypes.string,
204
200
  setWhatsappDocParams: PropTypes.func,
205
- channelSpecificStyle: PropTypes.bool,
206
201
  docPreview: PropTypes.any,
207
202
  };
208
203
 
@@ -6,6 +6,9 @@ $classPrefix: cap-custom-document-upload;
6
6
  .upload-doc {
7
7
  margin-right: $CAP_SPACE_08;
8
8
  }
9
+ .input-div {
10
+ display: none;
11
+ }
9
12
  .image-info-wrapper {
10
13
  display: flex;
11
14
  justify-content: space-between;
@@ -61,3 +64,6 @@ $classPrefix: cap-custom-document-upload;
61
64
  }
62
65
 
63
66
  }
67
+ .document-div {
68
+ padding-top: '20px';
69
+ }
@@ -33,6 +33,6 @@ export default defineMessages({
33
33
  docErrorDesc: {
34
34
  id: `${scope}.docErrorDesc`,
35
35
  defaultMessage:
36
- 'Please upload the document with allowed file extension, size, dimension and aspect ratio',
36
+ 'Please upload the document with allowed file extension and size',
37
37
  },
38
38
  });
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
2
  import { injectIntl } from 'react-intl';
3
3
  import '@testing-library/jest-dom';
4
+ import userEvent from '@testing-library/user-event';
4
5
  import {
5
6
  render,
6
7
  screen,
7
- fireEvent,
8
- waitFor,
9
8
  } from '../../../utils/test-utils';
10
9
  import CapDocumentUpload from '../index';
11
10
 
@@ -33,7 +32,19 @@ describe("test for document upload", () => {
33
32
  };
34
33
  it("test for cap document upload", () => {
35
34
  renderComponent(props);
36
- expect(true).toBe(true);
35
+ expect(
36
+ screen.getByText(/size upto: 16mb/i)
37
+ ).toBeInTheDocument();
38
+ expect(
39
+ screen.getByText(/format: pdf/i)
40
+ ).toBeInTheDocument();
41
+ expect(
42
+ screen.getByText(/drag and drop document here/i)
43
+ ).toBeInTheDocument();
44
+ const button = screen.getByRole('button', {
45
+ name: /drag and drop document here or select from computer/i,
46
+ });
47
+ userEvent.click(button);
37
48
  });
38
49
  it("test for cap document upload 1", () => {
39
50
  const props1 = {
@@ -10,15 +10,14 @@ import CapDrawer from '@capillarytech/cap-ui-library/CapDrawer';
10
10
  import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
11
11
  import moment from 'moment';
12
12
  import isEmpty from 'lodash/isEmpty';
13
- import messages from './messages';
14
13
  import {
15
14
  CapHeading,
16
15
  CapButton,
17
16
  CapError,
18
17
  CapUploader,
19
18
  CapSpin,
20
- CapNotification,
21
19
  } from '@capillarytech/cap-ui-library';
20
+ import messages from './messages';
22
21
  import {bytes2Size} from '../../utils/common';
23
22
  import { WHATSAPP } from './constants';
24
23
  import './index.scss';
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
2
  import { injectIntl } from 'react-intl';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import '@testing-library/jest-dom';
4
5
  import {
5
6
  render,
6
7
  screen,
7
- fireEvent,
8
- waitFor,
9
8
  } from '../../../utils/test-utils';
10
9
  import CapVideoUpload from '../index';
11
10
 
@@ -20,7 +19,6 @@ describe("test for document upload", () => {
20
19
  videoSize: 16000000,
21
20
  uploadAsset: jest.fn(),
22
21
  supportedExtensions: '',
23
- videoSrc: '',
24
22
  uploadedAssetList: {},
25
23
  updateDocumentSrc: jest.fn(),
26
24
  updateOnReUpload: jest.fn(),
@@ -32,28 +30,61 @@ describe("test for document upload", () => {
32
30
  };
33
31
  it("test for cap document upload", () => {
34
32
  renderComponent(props);
35
- expect(true).toBe(true);
33
+ expect(
34
+ screen.getByText(/file size: up to 16 mb/i)
35
+ ).toBeInTheDocument();
36
+ expect(
37
+ screen.getByText(
38
+ /format: mp4 and 3gpp \(h\.264 video codec and aac audio codec\)/i)
39
+ ).toBeInTheDocument();
40
+ expect(
41
+ screen.getByText(/drag and drop video here/i)
42
+ ).toBeInTheDocument();
43
+ const button = screen.getByRole('button', {
44
+ name: /drag and drop video here or select from computer/i,
45
+ });
46
+ userEvent.click(button);
36
47
  });
37
48
  it("test for cap document upload 1", () => {
38
49
  const props1 = {
39
50
  ...props,
40
- documentData: {
51
+ videoData: {
41
52
  uploadedAssetData0: {
42
- file_size: 134532,
43
- name: 'sample.pdf',
44
- secure_file_path: "https://www.africau.edu/images/default/sample.pdf",
45
- karixFileHandle: 'abcd',
53
+ _id: "63f3126a8f9d2d85450a99d3",
54
+ type: "VIDEO",
55
+ isActive: true,
56
+ name: "sample_960x540_Xs2E4anK.mp4",
57
+ createdBy: "15000449",
58
+ updatedBy: "15000449",
59
+ orgId: 50074,
60
+ metaInfo: {
61
+ file_handle: null,
62
+ name: "sample_960x540_Xs2E4anK.mp4",
63
+ content_type: null,
64
+ file_size: 1320775,
65
+ added_on: 1676874342000,
66
+ last_modified_on: 1676874342000,
67
+ acl: null,
68
+ secure_file_path: "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/69d66812-291f-4658-9da8-c6d30eef.mp4",
69
+ public_url: "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/69d66812-291f-4658-9da8-c6d30eef.mp4",
70
+ video_file_path_preview: "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/video_screenshot_assets__1676874342082.png/1040"
71
+ },
72
+ createdAt: "2023-02-20T06:25:46.637Z",
73
+ updatedAt: "2023-02-20T06:25:46.637Z",
74
+ __v: 0,
46
75
  },
47
76
  },
48
- documentSrc: "https://www.africau.edu/images/default/sample.pdf",
49
- whatsappDocParams: {
50
- whatsappDocName: 'sample.pdf',
51
- whatsappDocSize: 134532,
52
- whatsappDocPages: 2,
53
- whatsappDocImg: 'https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g',
77
+ uploadedAssetList: {
78
+ videoSrc: "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/69d66812-291f-4658-9da8-c6d30eef.mp4",
79
+ videoId: "",
80
+ videoName: "sample_960x540_Xs2E4anK.mp4",
81
+ videoHeight: 540,
82
+ videoWidth: 960,
83
+ previewUrl: "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/video_screenshot_assets__1676874342082.png/1040"
54
84
  },
55
85
  };
56
86
  renderComponent(props1);
57
- expect(true).toBe(true);
87
+ const reUploadBtn = screen.getByRole('button', {name: /re upload/i});
88
+ userEvent.click(reUploadBtn);
58
89
  });
59
90
  });
@@ -457,4 +457,20 @@
457
457
  span {
458
458
  font-size: $FONT_SIZE_VS;
459
459
  }
460
+ }
461
+
462
+ .video-preview {
463
+ position: relative;
464
+ }
465
+ .icon-position {
466
+ width: 50%;
467
+ height: 50%;
468
+ position: absolute;
469
+ left: 0;
470
+ top: 0;
471
+ }
472
+ .video-icon {
473
+ position: absolute;
474
+ right: -17px;
475
+ bottom: -17px;
460
476
  }
@@ -22,6 +22,7 @@ import {
22
22
  import Carousel from '../Carousel';
23
23
  import { VIBER, FACEBOOK } from '../../v2Containers/App/constants';
24
24
  import whatsappMobileAndroid from './assets/images/whatsapp_mobile_android.svg';
25
+ import videoPlay from '../../assets/videoPlay.svg'
25
26
  const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
26
27
  const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
27
28
  const smsMobileIos = require('./assets/images/sms_mobile_ios.svg');
@@ -741,11 +742,16 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
741
742
  />
742
743
  )}
743
744
  {content?.whatsappVideoPreviewImg && (
744
- <CapImage
745
- src={content.whatsappVideoPreviewImg}
746
- className="whatsapp-image"
747
- alt={formatMessage(messages.previewGenerated)}
748
- />
745
+ <div className="video-preview">
746
+ <CapImage
747
+ src={content.whatsappVideoPreviewImg}
748
+ className="whatsapp-image"
749
+ alt={formatMessage(messages.previewGenerated)}
750
+ />
751
+ <div className="icon-position">
752
+ <CapImage className="video-icon" src={videoPlay} />
753
+ </div>
754
+ </div>
749
755
  )}
750
756
  {content?.docPreview && (
751
757
  <div className="whatsapp-image">
@@ -784,7 +784,6 @@ export const Whatsapp = (props) => {
784
784
  );
785
785
  const renderDocumentComponent = () => (
786
786
  <CapDocumentUpload
787
- style={{ paddingTop: '20px' }}
788
787
  allowedExtensionsRegex={ALLOWED_EXTENSIONS_DOCUMENT_REGEX}
789
788
  documentSize={WHATSAPP_DOCUMENT_SIZE}
790
789
  uploadAsset={uploadWhatsappImage}
@@ -4,6 +4,7 @@ import {
4
4
  getWhatsappCategory,
5
5
  getWhatsappCta,
6
6
  bytesConversion,
7
+ getWhatsappDocPreview,
7
8
  } from '../utils';
8
9
  import mockdata from '../../mockdata';
9
10
 
@@ -13,6 +14,8 @@ const {
13
14
  getWhatsappStatusOutput1,
14
15
  getWhatsappCategoryOutput1,
15
16
  getWhatsappCategoryOutput2,
17
+ getWhatsappDocPreviewOutput,
18
+ getWhatsappDocPreviewOutput1,
16
19
  } = mockdata;
17
20
 
18
21
  describe('Test utils', () => {
@@ -21,6 +24,7 @@ describe('Test utils', () => {
21
24
  expect(getWhatsappContent(whatsappPreviewTemplateData2)).toMatchSnapshot();
22
25
  expect(getWhatsappContent({})).toMatchSnapshot();
23
26
  expect(bytesConversion(1024)).toEqual('1.0 KB');
27
+ expect(bytesConversion('abcd')).toEqual('0 bytes');
24
28
  });
25
29
 
26
30
  it('test getWhatsappContent for preview', () => {
@@ -47,4 +51,22 @@ describe('Test utils', () => {
47
51
  getWhatsappCategoryOutput2,
48
52
  );
49
53
  });
54
+
55
+ it('test getWhatsappDocPreview', () => {
56
+ const whatsappDocParams = {
57
+ whatsappDocName: "java_tutorial__QtdfGkr.pdf",
58
+ whatsappDocSize: 1089150,
59
+ whatsappDocPages: 2,
60
+ whatsappDocImg: "https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g",
61
+ };
62
+ expect(getWhatsappDocPreview(whatsappDocParams)).toEqual(
63
+ getWhatsappDocPreviewOutput,
64
+ );
65
+ expect(getWhatsappDocPreview({
66
+ ...whatsappDocParams,
67
+ whatsappDocPages: 1,
68
+ })).toEqual(
69
+ getWhatsappDocPreviewOutput1,
70
+ );
71
+ });
50
72
  });
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FormattedMessage } from 'react-intl';
3
+ import { CapImage, CapLabel } from '@capillarytech/cap-ui-library';
4
+ import pdfIcon from '../assets/pdfIcon.svg';
3
5
 
4
6
  export default {
5
7
  whatsappTemplates: {
@@ -957,6 +959,50 @@ export default {
957
959
  type: 'WHATSAPP',
958
960
  channel: 'WHATSAPP',
959
961
  },
962
+ getWhatsappDocPreviewOutput:
963
+ (
964
+ <>
965
+ <div className="pdf-img-box">
966
+ <CapImage src={"https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g"} alt="upload-document-src" className="pdf-preview-img" />
967
+ </div>
968
+ <div className="pdf-label">
969
+ <CapImage src={pdfIcon} />
970
+ <div className="pdf-info">
971
+ <div className="pdf-name-div">
972
+ <CapLabel type="label9" className="pdf-name">java_tutorial</CapLabel>
973
+ <CapLabel type="label9">{".pdf"}</CapLabel>
974
+ </div>
975
+ <CapLabel className="pdf-info-sec">
976
+ {
977
+ `2 pages · 1.0 MB · PDF`
978
+ }
979
+ </CapLabel>
980
+ </div>
981
+ </div>
982
+ </>
983
+ ),
984
+ getWhatsappDocPreviewOutput1:
985
+ (
986
+ <>
987
+ <div className="pdf-img-box">
988
+ <CapImage src={"https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g"} alt="upload-document-src" className="pdf-preview-img" />
989
+ </div>
990
+ <div className="pdf-label">
991
+ <CapImage src={pdfIcon} />
992
+ <div className="pdf-info">
993
+ <div className="pdf-name-div">
994
+ <CapLabel type="label9" className="pdf-name">java_tutorial</CapLabel>
995
+ <CapLabel type="label9">{".pdf"}</CapLabel>
996
+ </div>
997
+ <CapLabel className="pdf-info-sec">
998
+ {
999
+ `1 page · 1.0 MB · PDF`
1000
+ }
1001
+ </CapLabel>
1002
+ </div>
1003
+ </div>
1004
+ </>
1005
+ ),
960
1006
  rcsEditTemplateData: {
961
1007
  mode: 'edit',
962
1008
  _id: '620e213d39bd394c58aeaaca',