@capillarytech/creatives-library 8.0.165 → 8.0.166

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": "8.0.165",
4
+ "version": "8.0.166",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -6,13 +6,15 @@ export default [
6
6
  {
7
7
  key: 'navigation',
8
8
  saga: function* navigationConfigSaga() {
9
- yield all(CapCollapsibleLeftNavigationSagas.map(saga => saga.call()));
9
+ yield all(CapCollapsibleLeftNavigationSagas.map((saga) => saga.call()));
10
10
  },
11
11
  },
12
12
  {
13
13
  key: 'analyticsBotSaga',
14
14
  saga: function* analyticsBotSagaFn() {
15
- yield all(analyticsBotSaga.map(saga => saga.call()));
15
+ if (analyticsBotSaga && Array.isArray(analyticsBotSaga)) {
16
+ yield all(analyticsBotSaga.map((saga) => saga.call()));
17
+ }
16
18
  },
17
19
  },
18
20
  ];
@@ -1,34 +1,78 @@
1
1
  import { expectSaga } from "redux-saga-test-plan";
2
- import rootSagas from "../saga";
3
2
  import * as matchers from "redux-saga-test-plan/matchers";
4
3
  import CapCollapsibleLeftNavigationSagas from '@capillarytech/cap-ui-library/CapCollapsibleLeftNavigation/saga';
5
- import { analyticsBotSaga } from "@capillarytech/cap-ui-library/CapAskAira";
4
+
5
+ import rootSagas from "../saga";
6
+
7
+ // Mock the analyticsBotSaga module
8
+ jest.mock('@capillarytech/cap-ui-library/CapAskAira', () => ({
9
+ analyticsBotSaga: [
10
+ {
11
+ * call() { yield true; },
12
+ },
13
+ {
14
+ * call() { yield true; },
15
+ },
16
+ ],
17
+ }));
6
18
 
7
19
  describe("analyticsBotSagaFn", () => {
8
- test.concurrent("should call all analytics bot sagas", () => {
9
- const { saga: analyticsBotSagaFn } = rootSagas.find(
10
- s => s.key === "analyticsBotSaga"
11
- );
20
+ const { saga: analyticsBotSagaFn } = rootSagas.find(
21
+ (s) => s.key === "analyticsBotSaga"
22
+ );
23
+
24
+ test.concurrent("should handle when analyticsBotSaga is valid array", () => {
25
+ // Mock module with valid array
26
+ jest.mock('@capillarytech/cap-ui-library/CapAskAira', () => ({
27
+ analyticsBotSaga: [
28
+ {
29
+ * call() { yield true; },
30
+ },
31
+ {
32
+ * call() { yield true; },
33
+ },
34
+ ],
35
+ }));
36
+
12
37
  return expectSaga(analyticsBotSagaFn)
13
38
  .provide([
14
- [matchers.call.fn(analyticsBotSaga[0]), undefined],
15
- [matchers.call.fn(analyticsBotSaga[1]), undefined]
39
+ [matchers.call.fn(() => {}), undefined],
16
40
  ])
17
41
  .run();
18
42
  });
43
+
44
+ test.concurrent("should handle when analyticsBotSaga is undefined", () => {
45
+ // Mock module with undefined analyticsBotSaga
46
+ jest.mock('@capillarytech/cap-ui-library/CapAskAira', () => ({
47
+ analyticsBotSaga: undefined,
48
+ }));
49
+
50
+ return expectSaga(analyticsBotSagaFn)
51
+ .run();
52
+ });
53
+
54
+ test.concurrent("should handle when analyticsBotSaga is not an array", () => {
55
+ // Mock module with non-array analyticsBotSaga
56
+ jest.mock('@capillarytech/cap-ui-library/CapAskAira', () => ({
57
+ analyticsBotSaga: {},
58
+ }));
59
+
60
+ return expectSaga(analyticsBotSagaFn)
61
+ .run();
62
+ });
19
63
  });
20
64
 
21
65
  describe("navigationConfigSaga", () => {
22
- it.concurrent("should call all analytics bot sagas", () => {
23
- const { saga: navigationConfigSaga } = rootSagas.find(
24
- s => s.key === "navigation"
25
- );
26
-
27
- return expectSaga(navigationConfigSaga)
28
- .provide([
29
- [matchers.call.fn(CapCollapsibleLeftNavigationSagas[0]), undefined],
30
- [matchers.call.fn(CapCollapsibleLeftNavigationSagas[1]), undefined]
31
- ])
32
- .run();
33
- });
66
+ it.concurrent("should call all analytics bot sagas", () => {
67
+ const { saga: navigationConfigSaga } = rootSagas.find(
68
+ (s) => s.key === "navigation"
69
+ );
70
+
71
+ return expectSaga(navigationConfigSaga)
72
+ .provide([
73
+ [matchers.call.fn(CapCollapsibleLeftNavigationSagas[0]), undefined],
74
+ [matchers.call.fn(CapCollapsibleLeftNavigationSagas[1]), undefined],
75
+ ])
76
+ .run();
34
77
  });
78
+ });
@@ -2696,19 +2696,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2696
2696
  const previewSubject = formData['template-subject'];
2697
2697
  const testOrPreviewProps = {channel: EMAIL, content: previewContent, subject: previewSubject};
2698
2698
 
2699
- // Call our handler instead of the props methods to set the flag
2700
- const handleClick = () => {
2701
- if (action === 'TEST') {
2702
- // For test action, open our Test & Preview slidebox
2703
- this.handleTestAndPreview();
2704
- } else {
2705
- // For preview action, call the original method
2706
- const { onPreviewContentClicked } = this.props;
2707
- if (onPreviewContentClicked) {
2708
- onPreviewContentClicked(testOrPreviewProps);
2709
- }
2710
- }
2711
- };
2699
+ const { onPreviewContentClicked, onTestContentClicked } = this.props;
2712
2700
 
2713
2701
  return (
2714
2702
  <CapButton
@@ -2718,7 +2706,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2718
2706
  padding: '0 6px',
2719
2707
  }}
2720
2708
  type="flat"
2721
- onClick={handleClick}
2709
+ onClick={() => action === 'PREVIEW' ? onPreviewContentClicked(testOrPreviewProps) : onTestContentClicked(testOrPreviewProps)}
2722
2710
  >
2723
2711
  <CapIcon type={action === 'PREVIEW' ? "eye" : "lab"}/>
2724
2712
  {action === 'PREVIEW' ? <FormattedMessage {...messages.preview} /> : <FormattedMessage {...messages.testMessage} />}
@@ -2773,7 +2761,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2773
2761
  tags = this.props.supportedTags;
2774
2762
  }
2775
2763
  const { showImageSelectionBox = false } = this.state;
2776
- const showTestAndPreview = !showImageSelectionBox && getDefaultTags === 'outbound';
2764
+ const showTestAndPreview = !showImageSelectionBox && getDefaultTags === 'outbound' && !this.props.showTestAndPreviewSlidebox;
2777
2765
  return (
2778
2766
  <div className="email-container">
2779
2767
  <CapSpin spinning={isLoading}>