@capillarytech/creatives-library 7.17.134 → 7.17.136-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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.134",
4
+ "version": "7.17.136-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -527,7 +527,11 @@ export const getS3UrlFileSizes = (data) => {
527
527
 
528
528
  export const getTemplateInfoById = ({id, username, oa_id, token}) => {
529
529
  const url = `${API_ENDPOINT}/templates/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
530
- return request(url, getAPICallObject('GET'));
530
+ const compressedTemplatesData = request(url, getAPICallObject('GET'));
531
+ return compressedTemplatesData.then(async (data) => {
532
+ const { response = '' } = data || {};
533
+ return { ...data, response: await decompressJsonObject(response)};
534
+ });
531
535
  };
532
536
 
533
537
  export const getMetaTags = ({previewUrl}) => {
@@ -544,3 +548,5 @@ export const getNavigationConfigApi = async () => {
544
548
  const url = `${ARYA_ENDPOINT}/navigations`;
545
549
  return await request(url, getAPICallObject('GET'));
546
550
  };
551
+
552
+ export {request, getAPICallObject};
@@ -8,6 +8,7 @@ import {
8
8
  getNavigationConfigApi,
9
9
  getAllTemplates,
10
10
  getTemplateDetails,
11
+ getTemplateInfoById,
11
12
  } from '../api';
12
13
  import { mockData } from './mockData';
13
14
  const sampleFile = require('../../assets/line.png');
@@ -225,3 +226,68 @@ describe('getTemplateDetails -- Test with valid responses', () => {
225
226
  });
226
227
  });
227
228
  });
229
+
230
+ describe('getTemplateInfoById -- Test with valid responses', () => {
231
+ beforeEach(() => {
232
+ global.fetch = jest.fn(); // Mocking global fetch function
233
+ });
234
+
235
+ afterEach(() => {
236
+ jest.restoreAllMocks(); // Restore all mocks after each test
237
+ });
238
+ it('Should return correct response', async () => {
239
+ global.fetch.mockReturnValue(Promise.resolve({
240
+ status: 200,
241
+ json: () => Promise.resolve({
242
+ status: 200,
243
+ response: {
244
+ _id: '123',
245
+ },
246
+ }),
247
+ }));
248
+ mockDecompressJsonObject.mockReturnValue(Promise.resolve({
249
+ _id: '123',
250
+ }));
251
+ expect(await getTemplateInfoById({id: '123', username: 'capillary_zns', 'oa_id': 'jfhagsdhj', token: 'tuyagjahs'})).toEqual({
252
+ response: {
253
+ _id: '123',
254
+ },
255
+ status: 200,
256
+ });
257
+ });
258
+
259
+ it('Should not return correct response', async () => {
260
+ global.fetch.mockReturnValue(Promise.resolve({
261
+ status: 200,
262
+ json: () => Promise.resolve({
263
+ status: 200,
264
+ data: {
265
+ _id: '123',
266
+ },
267
+ }),
268
+ }));
269
+ mockDecompressJsonObject.mockReturnValue(Promise.resolve({
270
+ _id: '123',
271
+ }));
272
+ expect(await getTemplateInfoById({id: '123', username: 'capillary_zns', 'oa_id': 'jfhagsdhj', token: 'tuyagjahs'})).toEqual({
273
+ data: {
274
+ _id: '123',
275
+ },
276
+ response: {
277
+ _id: '123',
278
+ },
279
+ status: 200,
280
+ });
281
+ });
282
+
283
+ it('Should not return correct response when data is undefined', async () => {
284
+ global.fetch.mockReturnValue(Promise.resolve({
285
+ status: 200,
286
+ json: () => Promise.resolve(),
287
+ }));
288
+ mockDecompressJsonObject.mockReturnValue(Promise.resolve());
289
+ expect(await getTemplateInfoById({id: '123', username: 'capillary_zns', 'oa_id': 'jfhagsdhj', token: 'tuyagjahs'})).toEqual({
290
+ response: undefined,
291
+ });
292
+ });
293
+ });
@@ -14,10 +14,9 @@ import { LOYALTY } from '../../v2Containers/App/constants';
14
14
  import {
15
15
  HELP_URL,
16
16
  LOYALTY_HELP_URL,
17
- ENABLE_AI_SUGGESTIONS,
18
17
  ENABLE_NEW_LEFT_NAVIGATION,
19
18
  DEFAULT_MODULE,
20
- AI_DOCUMENTATION_BOT_ENABLED
19
+ AI_DOCUMENTATION_BOT_DISABLED,
21
20
  } from '../../v2Containers/Cap/constants';
22
21
  import CapNavigation from '@capillarytech/cap-ui-library/CapNavigation';
23
22
  import configPath from '../../config/path';
@@ -149,7 +148,9 @@ export class NavigationBar extends React.Component {
149
148
  handleLeftNavBarExpanded,
150
149
  leftNavbarExpandedProp,
151
150
  } = this.props;
152
- const showDocumentationBot = userData?.currentOrgDetails?.accessibleFeatures?.includes(ENABLE_AI_SUGGESTIONS) || userData?.currentOrgDetails?.accessibleFeatures?.includes(AI_DOCUMENTATION_BOT_ENABLED);
151
+ const showDocumentationBot = !userData?.currentOrgDetails?.accessibleFeatures?.includes(
152
+ AI_DOCUMENTATION_BOT_DISABLED,
153
+ );
153
154
  const dropdownMenuProps = this.getDropdownMenu();
154
155
  const {
155
156
  currentOrgDetails: {
@@ -185,6 +186,8 @@ export class NavigationBar extends React.Component {
185
186
  showDocumentationBot={showDocumentationBot}
186
187
  setLeftNavbarExpandedProp={handleLeftNavBarExpanded}
187
188
  headerOverideCss={headerOverideCss}
189
+ request={Api.request}
190
+ getAPICallObject={Api.getAPICallObject}
188
191
  >
189
192
  <div data-testid="cap-wrapper">
190
193
  <CapWrapper isEmbedded={type === EMBEDDED}>
@@ -7,19 +7,25 @@ import { render, screen } from '../../../utils/test-utils';
7
7
 
8
8
  import { NavigationBar } from '../index';
9
9
  import * as mockdata from './mockData';
10
+ import { Provider } from 'react-redux';
11
+ import configureStore from '../../../store';
12
+ import { browserHistory } from 'react-router';
13
+ const { userData } = mockdata;
10
14
 
11
- const { userData} = mockdata;
12
-
15
+ let store;
16
+ beforeAll(() => {
17
+ store = configureStore({}, browserHistory);
18
+ });
13
19
  const ComponentToRender = injectIntl(NavigationBar);
14
-
15
20
  const renderComponent = (props) => {
16
21
  render(
17
- <Router>
18
- <ComponentToRender {...props} />
19
- </Router>,
22
+ <Provider store={store}>
23
+ <Router>
24
+ <ComponentToRender {...props} />
25
+ </Router>
26
+ </Provider>
20
27
  );
21
28
  };
22
-
23
29
  describe('NavigationBar', () => {
24
30
  const props = {
25
31
  topbarMenuData: [{}],
@@ -49,7 +55,7 @@ describe('NavigationBar', () => {
49
55
  expect(ariaBotIcon).toBeNull();
50
56
  });
51
57
  it('Should contains top vertical', () => {
52
- const updatedProps = {...props} ;
58
+ const updatedProps = { ...props };
53
59
  delete updatedProps.userData.currentOrgDetails.accessibleFeatures;
54
60
  renderComponent(updatedProps);
55
61
  const topVaerticalBar = document.querySelector('.cap-top-bar-vertical');
@@ -43,6 +43,7 @@ export const AI_CONTENT_BOT_DISABLED = 'AI_CONTENT_BOT_DISABLED';
43
43
  export const AI_DOCUMENTATION_BOT_ENABLED = 'AI_DOCUMENTATION_BOT_ENABLED';
44
44
  export const ERROR_IN_FETCHING_TAGS = 'Error in fetching tags';
45
45
  export const ENABLE_NEW_LEFT_NAVIGATION = 'ENABLE_NEW_LEFT_NAVIGATION';
46
+ export const AI_DOCUMENTATION_BOT_DISABLED = 'AI_DOCUMENTATION_BOT_DISABLED';
46
47
 
47
48
  export const GET_SUPPORT_VIDEOS_CONFIG_REQUEST =
48
49
  'cap/GET_SUPPORT_VIDEOS_CONFIG_REQUEST';