@capillarytech/creatives-library 9.0.7 → 9.0.9

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "9.0.7",
4
+ "version": "9.0.9",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -890,6 +890,14 @@
890
890
  .sms-icon{
891
891
  left: 12% !important;
892
892
  }
893
+
894
+ #mobilepush-preview {
895
+ .message-pop {
896
+ .app-header-right {
897
+ margin-left: unset;
898
+ }
899
+ }
900
+ }
893
901
  }
894
902
 
895
903
  #slidebox-container {
@@ -727,7 +727,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
727
727
  ""
728
728
  )}
729
729
  {channel && channel.toUpperCase() === MOBILE_PUSH && (
730
- <CapRow className="shell-v2 align-center" id="mobilepush-preview">
730
+ <CapRow type='flex' align='middle' className="shell-v2 align-center" id="mobilepush-preview">
731
731
  <CapImage
732
732
  className="preview-image"
733
733
  src={
@@ -747,13 +747,13 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
747
747
  }-push-message-Container`}
748
748
  >
749
749
  {this.props.device === "android" ? (
750
- <CapRow className="message-pop align-left">
751
- <CapRow className="app-header">
752
- <CapRow className="app-header-left">
750
+ <CapRow type='flex' align='middle' className="message-pop align-left">
751
+ <CapRow type='flex' fullWidth className="app-header">
752
+ <CapRow type='flex' className="app-header-left">
753
753
  <span className="app-icon">{""}</span>
754
754
  <CapLabel className="title">{content.header}</CapLabel>
755
755
  </CapRow>
756
- <CapRow className="app-header-right">
756
+ <CapRow type='flex' className="app-header-right">
757
757
  <span>2:29 PM</span>
758
758
  <CapIcon type="chevron-down" size="sm" />
759
759
  </CapRow>
@@ -1291,7 +1291,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
1291
1291
  </div>
1292
1292
  <CapHeading
1293
1293
  type="h3"
1294
- style={{ textAlign: "center" }}
1294
+ style={{ textAlign: "center", width: "100%" }}
1295
1295
  className="margin-t-16"
1296
1296
  >
1297
1297
  <FormattedMessage
@@ -2431,7 +2431,7 @@ const splitTemplateVarString = (str) => {
2431
2431
  />
2432
2432
  <CapHeading
2433
2433
  type="h3"
2434
- style={{ textAlign: 'center' }}
2434
+ style={{ textAlign: 'center', width: '100%' }}
2435
2435
  className="margin-t-16"
2436
2436
  >
2437
2437
  {formatMessage(messages.totalCharacters, {
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
- import { mount } from 'enzyme';
3
- import { IntlProvider } from 'react-intl';
4
2
  import { mountWithIntl, shallowWithIntl } from '../../../../helpers/intl-enzym-test-helpers';
5
3
  import MessageSection from './MessageSection';
6
4
  import CapInput from '@capillarytech/cap-ui-library/CapInput';
@@ -232,31 +230,10 @@ describe('MessageSection', () => {
232
230
  });
233
231
 
234
232
  describe('TextArea Ref Handling', () => {
235
- it('should not pass the dropped setInputRef prop to CapInput.TextArea', () => {
233
+ it('should call handleMessageTextAreaRef with setInputRef', () => {
236
234
  const wrapper = mountWithIntl(<MessageSection {...defaultProps} />);
237
235
  const textArea = wrapper.find(CapInput.TextArea);
238
- expect(textArea.prop('setInputRef')).toBeUndefined();
239
- });
240
-
241
- it('should resolve the DOM textarea by id and feed it to handleMessageTextAreaRef on mount', () => {
242
- // attachTo a real DOM node so document.getElementById can find the
243
- // antd-rendered <textarea> (enzyme mount is detached from document otherwise).
244
- const container = document.createElement('div');
245
- document.body.appendChild(container);
246
- const wrapper = mount(
247
- <IntlProvider locale="en">
248
- <MessageSection {...defaultProps} />
249
- </IntlProvider>,
250
- { attachTo: container }
251
- );
252
-
253
- const textarea = document.getElementById('webpush-message-input');
254
- expect(textarea).not.toBeNull();
255
- expect(textarea.tagName).toBe('TEXTAREA');
256
- expect(mockHandleMessageTextAreaRef).toHaveBeenCalledWith(textarea);
257
-
258
- wrapper.unmount();
259
- container.remove();
236
+ expect(textArea.prop('setInputRef')).toBe(mockHandleMessageTextAreaRef);
260
237
  });
261
238
 
262
239
  it('should pass messageTextAreaRef to CapEmojiPicker.Wrapper', () => {
@@ -47,6 +47,7 @@ exports[`MessageSection Rendering should render correctly with default props 1`]
47
47
  id="webpush-message-input"
48
48
  isRequired={true}
49
49
  onChange={[MockFunction]}
50
+ setInputRef={[MockFunction]}
50
51
  size="default"
51
52
  value="Test Message"
52
53
  />
@@ -1,85 +0,0 @@
1
- import React from 'react';
2
- import { configure, mount } from 'enzyme';
3
- import Adapter from '@cfaester/enzyme-adapter-react-18';
4
- import { IntlProvider } from 'react-intl';
5
- import { act } from 'react-dom/test-utils';
6
-
7
- // TagList is a redux-auth-wrapper-connected container that needs full app routing
8
- // state to mount; CallTaskPreview is irrelevant to insertAtCursor. Stub both so we
9
- // can mount the real NewCallTask and exercise its real insertAtCursor method.
10
- jest.mock('../../../v2Containers/TagList', () => {
11
- const Stub = () => null;
12
- return { __esModule: true, default: Stub, TagList: Stub };
13
- });
14
- jest.mock('../../CallTaskPreview', () => {
15
- const Stub = () => null;
16
- return { __esModule: true, default: Stub };
17
- });
18
- // hasStore2DoorFeature() reads app/org config that isn't present in jsdom.
19
- jest.mock('../../../utils/common', () => ({
20
- ...jest.requireActual('../../../utils/common'),
21
- hasStore2DoorFeature: () => false,
22
- }));
23
-
24
- // eslint-disable-next-line import/first
25
- import NewCallTask from '../index';
26
- // eslint-disable-next-line import/first
27
- import mockData from './mockData';
28
-
29
- configure({ adapter: new Adapter() });
30
-
31
- let container;
32
- let wrapper;
33
-
34
- afterEach(() => {
35
- if (wrapper) wrapper.unmount();
36
- if (container) container.remove();
37
- wrapper = undefined;
38
- container = undefined;
39
- });
40
-
41
- // attachTo a real node in document.body so document.getElementById can find the
42
- // antd-rendered <textarea> (enzyme `mount` is detached from `document` otherwise).
43
- const mountNewCallTask = (extraProps = {}) => {
44
- container = document.createElement('div');
45
- document.body.appendChild(container);
46
- wrapper = mount(
47
- <IntlProvider locale="en">
48
- <NewCallTask {...mockData} onCallTaskSubmit={jest.fn()} {...extraProps} />
49
- </IntlProvider>,
50
- { attachTo: container },
51
- );
52
- return wrapper;
53
- };
54
-
55
- // Regression coverage for the antd v3 -> v6 (cap-ui-library v6) migration: the lib
56
- // dropped the `setInputRef` callback, so selecting a personalisation tag used to
57
- // crash with "Cannot read properties of undefined (reading 'focus')". The fix
58
- // resolves the DOM <textarea> via document.getElementById instead.
59
- describe('NewCallTask insertAtCursor (antd v6 setInputRef removal)', () => {
60
- it('forwards the id to a real DOM <textarea>', () => {
61
- mountNewCallTask();
62
- const textarea = document.getElementById('new-call-task-message-body');
63
- expect(textarea).not.toBeNull();
64
- expect(textarea.tagName).toBe('TEXTAREA');
65
- });
66
-
67
- it('inserts a personalisation tag at the caret without throwing', () => {
68
- const wrapper = mountNewCallTask();
69
- const textarea = document.getElementById('new-call-task-message-body');
70
-
71
- // user typed "Hello world" and put the caret right after "Hello "
72
- textarea.value = 'Hello world';
73
- textarea.setSelectionRange(6, 6);
74
-
75
- const instance = wrapper.find('NewCallTask').instance();
76
- expect(() => {
77
- act(() => {
78
- instance.onTagSelect('firstName');
79
- });
80
- }).not.toThrow();
81
-
82
- // tag spliced in at the caret, not appended blindly
83
- expect(instance.state.messageBody).toBe('Hello {{firstName}}world');
84
- });
85
- });