@capillarytech/creatives-library 8.0.34-alpha.1 → 8.0.35

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 (64) hide show
  1. package/containers/App/test/saga.test.js +11 -0
  2. package/containers/Assets/Gallery/sagas.js +2 -1
  3. package/containers/Assets/Gallery/tests/saga.test.js +161 -0
  4. package/containers/Cap/tests/saga.test.js +8 -1
  5. package/containers/Dashboard/test/saga.test.js +9 -0
  6. package/containers/Ebill/test/saga.test.js +11 -0
  7. package/containers/Email/sagas.js +1 -1
  8. package/containers/Email/test/saga.test.js +278 -0
  9. package/containers/Line/Create/tests/saga.test.js +209 -0
  10. package/containers/Line/Edit/sagas.js +4 -4
  11. package/containers/Line/Edit/test/saga.test.js +164 -0
  12. package/containers/MobilePush/Create/test/saga.test.js +19 -0
  13. package/containers/MobilePush/Edit/tests/saga.test.js +255 -0
  14. package/containers/Sms/Create/test/saga.test.js +12 -0
  15. package/containers/Sms/Edit/test/saga.test.js +13 -0
  16. package/containers/Templates/test/saga.test.js +244 -0
  17. package/containers/WeChat/MapTemplates/test/saga.test.js +159 -0
  18. package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +13 -0
  19. package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +12 -0
  20. package/hoc/test/WithReactRouterV3Compatibility.test.js +135 -0
  21. package/hoc/withReactRouterV3Compatibility.js +4 -4
  22. package/package.json +2 -2
  23. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +4 -2
  24. package/tests/integration/TemplateCreation/api-response.js +10 -1
  25. package/tests/integration/TemplateCreation/msw-handler.js +3 -0
  26. package/utils/authWrapper.js +0 -6
  27. package/utils/tests/authWrapper.test.js +142 -0
  28. package/utils/tests/checkStore.test.js +72 -0
  29. package/utils/tests/customAuth.test.js +30 -0
  30. package/v2Components/NavigationBar/tests/saga.test.js +35 -0
  31. package/v2Containers/Assets/Gallery/sagas.js +1 -1
  32. package/v2Containers/Assets/Gallery/tests/saga.test.js +41 -0
  33. package/v2Containers/BeeEditor/test/saga.test.js +13 -0
  34. package/v2Containers/CallTask/test/saga.test.js +13 -0
  35. package/v2Containers/Cap/sagas.js +3 -3
  36. package/v2Containers/Cap/tests/Cap.test.js +2 -18
  37. package/v2Containers/Cap/tests/saga.test.js +73 -1
  38. package/v2Containers/CapFacebookPreview/tests/saga.test.js +13 -0
  39. package/v2Containers/Ebill/test/saga.test.js +13 -0
  40. package/v2Containers/Email/sagas.js +3 -2
  41. package/v2Containers/Email/tests/sagas.test.js +216 -0
  42. package/v2Containers/FTP/test/saga.test.js +12 -0
  43. package/v2Containers/Facebook/test/saga.test.js +171 -0
  44. package/v2Containers/InApp/tests/sagas.test.js +13 -0
  45. package/v2Containers/LanguageProvider/sagas.js +1 -1
  46. package/v2Containers/LanguageProvider/tests/saga.test.js +40 -0
  47. package/v2Containers/Line/Container/test/saga.test.js +228 -0
  48. package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
  49. package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
  50. package/v2Containers/Rcs/tests/saga.test.js +13 -0
  51. package/v2Containers/Sms/Create/test/saga.test.js +8 -0
  52. package/v2Containers/Sms/Edit/test/saga.test.js +12 -0
  53. package/v2Containers/SmsTrai/Create/tests/saga.test.js +13 -0
  54. package/v2Containers/TagList/index.js +20 -8
  55. package/v2Containers/TagList/tests/TagList.test.js +11 -4
  56. package/v2Containers/TagList/tests/mockdata.js +4 -20
  57. package/v2Containers/Templates/sagas.js +7 -7
  58. package/v2Containers/Templates/tests/sagas.test.js +138 -0
  59. package/v2Containers/Viber/tests/saga.test.js +187 -0
  60. package/v2Containers/WeChat/MapTemplates/test/saga.test.js +160 -0
  61. package/v2Containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +12 -0
  62. package/v2Containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +13 -0
  63. package/v2Containers/Whatsapp/tests/saga.test.js +9 -1
  64. package/v2Containers/Zalo/tests/saga.test.js +8 -1
@@ -0,0 +1,244 @@
1
+ import { expectSaga } from 'redux-saga-test-plan';
2
+ import { throwError } from 'redux-saga-test-plan/providers';
3
+ import * as matchers from 'redux-saga-test-plan/matchers';
4
+ import * as Api from '../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
7
+ import { templateSaga } from '../sagas';
8
+
9
+ describe('Template Management Sagas', () => {
10
+ describe('getAllTemplates Saga', () => {
11
+ const channel = { channel: 'email' };
12
+ const queryParams = { page: 1 };
13
+
14
+ it('handles failure in fetching all templates', () => {
15
+ const error = new Error('API error');
16
+
17
+ return expectSaga(sagas.getAllTemplates, channel, queryParams)
18
+ .provide([
19
+ [matchers.call.fn(Api.getAllTemplates, channel, queryParams), throwError(error)]
20
+ ])
21
+ .put({
22
+ type: types.GET_ALL_TEMPLATES_FAILURE,
23
+ error
24
+ })
25
+ .run();
26
+ });
27
+ });
28
+
29
+ describe('deleteTemplate Saga', () => {
30
+ const channel = 'email';
31
+ const id = '123';
32
+
33
+ it('handles successful deletion of a template', () => {
34
+ const fakeResponse = {
35
+ response: 'Template deleted successfully'
36
+ };
37
+
38
+ return expectSaga(sagas.deleteTemplate, channel, id)
39
+ .provide([
40
+ [matchers.call.fn(Api.deleteTemplate, channel, id), fakeResponse]
41
+ ])
42
+ .put({
43
+ type: types.DELETE_TEMPLATE_SUCCESS,
44
+ data: fakeResponse.response
45
+ })
46
+ .run();
47
+ });
48
+
49
+ it('handles failure in deleting a template', () => {
50
+ const error = new Error('Deletion failed');
51
+
52
+ return expectSaga(sagas.deleteTemplate, channel, id)
53
+ .provide([
54
+ [matchers.call.fn(Api.deleteTemplate, channel, id), throwError(error)]
55
+ ])
56
+ .put({
57
+ type: types.DELETE_TEMPLATE_FAILURE,
58
+ error
59
+ })
60
+ .run();
61
+ });
62
+ });
63
+
64
+ describe('fetchUserList Saga', () => {
65
+ it('handles successful fetching of user list', () => {
66
+ const fakeResponse = {
67
+ data: {
68
+ result: [{ id: 1, name: 'User One' }]
69
+ }
70
+ };
71
+
72
+ return expectSaga(sagas.fetchUserList)
73
+ .provide([
74
+ [matchers.call.fn(Api.getUserList), fakeResponse]
75
+ ])
76
+ .put({
77
+ type: types.GET_USER_LIST_SUCCESS,
78
+ data: fakeResponse.data.result
79
+ })
80
+ .run();
81
+ });
82
+
83
+ it('handles failure in fetching user list', () => {
84
+ const error = new Error('Fetch failed');
85
+
86
+ return expectSaga(sagas.fetchUserList)
87
+ .provide([
88
+ [matchers.call.fn(Api.getUserList), throwError(error)]
89
+ ])
90
+ .put({
91
+ type: types.GET_USER_LIST_FAILURE,
92
+ data: error
93
+ })
94
+ .run();
95
+ });
96
+ });
97
+
98
+ describe('fetchWeCrmAccounts Saga', () => {
99
+ const action = { source: 'CRM' };
100
+
101
+ it('handles successful fetching of WeCRM accounts', () => {
102
+ const fakeResponse = {
103
+ response: [{ id: 1, name: 'Account One' }]
104
+ };
105
+
106
+ return expectSaga(sagas.fetchWeCrmAccounts, action)
107
+ .provide([
108
+ [matchers.call.fn(Api.fetchWeCrmAccounts, action.source), fakeResponse]
109
+ ])
110
+ .put({
111
+ type: types.GET_WECRM_ACCOUNTS_SUCCESS,
112
+ data: fakeResponse.response
113
+ })
114
+ .run();
115
+ });
116
+
117
+ it('handles failure in fetching WeCRM accounts', () => {
118
+ const error = new Error('Fetch failed');
119
+
120
+ return expectSaga(sagas.fetchWeCrmAccounts, action)
121
+ .provide([
122
+ [matchers.call.fn(Api.fetchWeCrmAccounts, action.source), throwError(error)]
123
+ ])
124
+ .put({
125
+ type: types.GET_WECRM_ACCOUNTS_FAILURE,
126
+ data: error
127
+ })
128
+ .run();
129
+ });
130
+ });
131
+
132
+ describe('sendZippedFile Saga', () => {
133
+ const selectedFile = new Blob();
134
+
135
+ it('handles successful file sending', () => {
136
+ const fakeResponse = {
137
+ status: { isError: false },
138
+ response: { metaEntity: { htmlContent: encodeURIComponent('<html>Content</html>') } }
139
+ };
140
+
141
+ return expectSaga(sagas.sendZippedFile, { selectedFile })
142
+ .provide([
143
+ [matchers.call.fn(Api.sendZippedFile, selectedFile), fakeResponse]
144
+ ])
145
+ .put({
146
+ type: types.SEND_ZIPPED_FILE_SUCCESS,
147
+ selectedTemplate: decodeURIComponent(fakeResponse.response.metaEntity.htmlContent)
148
+ })
149
+ .run();
150
+ });
151
+
152
+ it('handles errors during file sending', () => {
153
+ const errorMessage = "Error sending file";
154
+ const fakeResponse = {
155
+ status: { isError: true },
156
+ message: errorMessage
157
+ };
158
+
159
+ return expectSaga(sagas.sendZippedFile, { selectedFile })
160
+ .provide([
161
+ [matchers.call.fn(Api.sendZippedFile, selectedFile), fakeResponse]
162
+ ])
163
+ .put({
164
+ type: types.SEND_ZIPPED_FILE_FAILURE,
165
+ data: errorMessage
166
+ })
167
+ .run();
168
+ });
169
+ });
170
+
171
+ describe('getEdmTemplates Saga', () => {
172
+ it('handles successful fetching of EDM templates', () => {
173
+ const fakeResponse = {
174
+ response: [{ id: 1, name: 'EDM Template One' }]
175
+ };
176
+
177
+ return expectSaga(sagas.getEdmTemplates)
178
+ .provide([
179
+ [matchers.call.fn(Api.getEdmTemplates), fakeResponse]
180
+ ])
181
+ .put({
182
+ type: types.GET_EDM_DEAFULT_TEMPLATES_SUCCESS,
183
+ data: fakeResponse.response
184
+ })
185
+ .run();
186
+ });
187
+
188
+ it('handles failure in fetching EDM templates', () => {
189
+ const error = new Error('Fetch failed');
190
+
191
+ return expectSaga(sagas.getEdmTemplates)
192
+ .provide([
193
+ [matchers.call.fn(Api.getEdmTemplates), throwError(error)]
194
+ ])
195
+ .put({
196
+ type: types.GET_EDM_DEAFULT_TEMPLATES_FAILURE,
197
+ error
198
+ })
199
+ .run();
200
+ });
201
+ });
202
+
203
+ describe('getTemplateDetails Saga', () => {
204
+ const id = '123';
205
+ const channel = 'email';
206
+
207
+ it('handles successful fetching of template details', () => {
208
+ const fakeResponse = {
209
+ response: { id: 123, name: 'Detailed Template' }
210
+ };
211
+
212
+ return expectSaga(sagas.getTemplateDetails, id, channel)
213
+ .provide([
214
+ [matchers.call.fn(Api.getTemplateDetails, id, channel), fakeResponse]
215
+ ])
216
+ .put({
217
+ type: types.GET_TEMPLATE_DETAILS_SUCCESS,
218
+ data: fakeResponse.response
219
+ })
220
+ .run();
221
+ });
222
+
223
+ it('handles failure in fetching template details', () => {
224
+ const error = new Error('Fetch failed');
225
+
226
+ return expectSaga(sagas.getTemplateDetails, id, channel)
227
+ .provide([
228
+ [matchers.call.fn(Api.getTemplateDetails, id, channel), throwError(error)]
229
+ ])
230
+ .put({
231
+ type: types.GET_TEMPLATE_DETAILS_FAILURE,
232
+ error
233
+ })
234
+ .run();
235
+ });
236
+ });
237
+ });
238
+
239
+ describe('Combined Watcher Sagas', () => {
240
+ it('templateSaga should initialize all watcher sagas without error', () => {
241
+ return expectSaga(templateSaga)
242
+ .run();
243
+ });
244
+ });
@@ -0,0 +1,159 @@
1
+ import { expectSaga } from 'redux-saga-test-plan';
2
+ import { call, put } from 'redux-saga/effects';
3
+ import { throwError } from 'redux-saga-test-plan/providers';
4
+ import * as Api from '../../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
7
+ import { mapTemplatesSaga } from '../sagas';
8
+
9
+ describe('WeChat Template Management Sagas', () => {
10
+ describe('getDefaultWeChatTemplates Saga', () => {
11
+ const params = { channel: 'WeChat', queryParams: { type: 'default' } };
12
+
13
+ it('handles fetching default WeChat templates successfully', () => {
14
+ const fakeResponse = {
15
+ response: {
16
+ unMapped: [{ id: 1, name: 'Template One' }],
17
+ mapped: [{ id: 2, name: 'Mapped Template' }]
18
+ }
19
+ };
20
+
21
+ return expectSaga(sagas.getDefaultWeChatTemplates, params)
22
+ .provide([
23
+ [call(Api.getAllTemplates, { channel: params.channel, queryParams: params.queryParams }), fakeResponse]
24
+ ])
25
+ .put({
26
+ type: types.GET_WECHAT_DEFAULT_TEMPLATES_SUCCESS,
27
+ data: fakeResponse.response.unMapped,
28
+ templateData: fakeResponse.response.mapped
29
+ })
30
+ .run();
31
+ });
32
+
33
+ it('handles failure in fetching default WeChat templates', () => {
34
+ const error = new Error('Fetch failed');
35
+
36
+ return expectSaga(sagas.getDefaultWeChatTemplates, params)
37
+ .provide([
38
+ [call(Api.getAllTemplates, { channel: params.channel, queryParams: params.queryParams }), throwError(error)]
39
+ ])
40
+ .put({
41
+ type: types.GET_WECHAT_DEFAULT_TEMPLATES_FAILURE,
42
+ error
43
+ })
44
+ .run();
45
+ });
46
+ });
47
+
48
+ describe('createTemplate Saga', () => {
49
+ const template = { name: 'New WeChat Template' };
50
+
51
+ it('handles creating a WeChat template successfully', () => {
52
+ const fakeResponse = {
53
+ response: template,
54
+ status: { code: 200 }
55
+ };
56
+
57
+ return expectSaga(sagas.createTemplate, template)
58
+ .provide([
59
+ [call(Api.createWeChatTemplate, template), fakeResponse]
60
+ ])
61
+ .put({
62
+ type: types.CREATE_TEMPLATE_SUCCESS,
63
+ data: fakeResponse.response,
64
+ statusCode: 200
65
+ })
66
+ .run();
67
+ });
68
+
69
+ it('handles failure when creating a WeChat template', () => {
70
+ const error = new Error('Creation failed');
71
+
72
+ return expectSaga(sagas.createTemplate, template)
73
+ .provide([
74
+ [call(Api.createWeChatTemplate, template), throwError(error)]
75
+ ])
76
+ .put({
77
+ type: types.CREATE_TEMPLATE_FAILURE,
78
+ error
79
+ })
80
+ .run();
81
+ });
82
+ });
83
+
84
+ describe('fetchWeCrmAccounts Saga', () => {
85
+ it('handles fetching WeCrm accounts successfully', () => {
86
+ const fakeResponse = {
87
+ response: [{ id: 1, name: 'Account One' }]
88
+ };
89
+
90
+ return expectSaga(sagas.fetchWeCrmAccounts)
91
+ .provide([
92
+ [call(Api.fetchWeCrmAccounts), fakeResponse]
93
+ ])
94
+ .put({
95
+ type: types.GET_WECRM_ACCOUNTS_SUCCESS,
96
+ data: fakeResponse.response
97
+ })
98
+ .run();
99
+ });
100
+
101
+ it('handles failure in fetching WeCrm accounts', () => {
102
+ const error = new Error('Fetch failed');
103
+
104
+ return expectSaga(sagas.fetchWeCrmAccounts)
105
+ .provide([
106
+ [call(Api.fetchWeCrmAccounts), throwError(error)]
107
+ ])
108
+ .put({
109
+ type: types.GET_WECRM_ACCOUNTS_FAILURE,
110
+ data: error
111
+ })
112
+ .run();
113
+ });
114
+ });
115
+
116
+ describe('getTemplateDetails Saga', () => {
117
+ const id = '123';
118
+
119
+ it('handles fetching template details successfully', () => {
120
+ const fakeResponse = {
121
+ response: { id: 123, name: 'Detailed Template' }
122
+ };
123
+
124
+ return expectSaga(sagas.getTemplateDetails, id)
125
+ .provide([
126
+ [call(Api.getTemplateDetails, id), fakeResponse]
127
+ ])
128
+ .put({
129
+ type: types.GET_TEMPLATE_DETAILS_SUCCESS,
130
+ data: fakeResponse.response
131
+ })
132
+ .run();
133
+ });
134
+
135
+ it('handles failure in fetching template details', () => {
136
+ const error = new Error('Fetch failed');
137
+
138
+ return expectSaga(sagas.getTemplateDetails, id)
139
+ .provide([
140
+ [call(Api.getTemplateDetails, id), throwError(error)]
141
+ ])
142
+ .put({
143
+ type: types.GET_TEMPLATE_DETAILS_FAILURE,
144
+ error
145
+ })
146
+ .run();
147
+ });
148
+ });
149
+
150
+
151
+
152
+ // Test combined saga
153
+ describe('Combined mapTemplatesSaga', () => {
154
+ it('should initialize all WeChat-related watcher sagas without error', () => {
155
+ return expectSaga(mapTemplatesSaga)
156
+ .run();
157
+ });
158
+ });
159
+ });
@@ -0,0 +1,13 @@
1
+ import { expectSaga } from "redux-saga-test-plan";
2
+
3
+ import {
4
+ richMediaTemplatesSaga,
5
+ } from "../sagas";
6
+
7
+ describe("RichMedia Template Sagas", () => {
8
+ describe("richMediaTemplatesSaga Combined", () => {
9
+ it("should initialize all RichMedia-related watcher sagas without error", () => {
10
+ return expectSaga(richMediaTemplatesSaga).run();
11
+ });
12
+ });
13
+ });
@@ -0,0 +1,12 @@
1
+
2
+ import { expectSaga } from "redux-saga-test-plan";
3
+
4
+ import {
5
+ richMediaTemplatesEditSaga,
6
+ } from "../sagas";
7
+
8
+ describe("richMediaTemplatesEditSaga Combined", () => {
9
+ it("should initialize all richMediaTemplatesEditSaga-related watcher sagas without error", () => {
10
+ return expectSaga(richMediaTemplatesEditSaga).run();
11
+ });
12
+ });
@@ -0,0 +1,135 @@
1
+ import React from 'react';
2
+ import { render, screen } from "@testing-library/react";
3
+ import { MemoryRouter } from "react-router-dom";
4
+ import withReactRouterV3Compatibility, { findRoute } from "../withReactRouterV3Compatibility"; // Update the import path as needed
5
+ import { Router } from 'react-router';
6
+ import { createMemoryHistory } from 'history';
7
+
8
+ // Mock componentRoutes
9
+ const componentRoutes = [
10
+ {
11
+ path: "/home",
12
+ component: () => <div>Home Component</div>,
13
+ routes: [
14
+ {
15
+ path: "/home/sub",
16
+ component: () => <div>Sub Home Component</div>
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ path: "/about",
22
+ component: () => <div>About Component</div>
23
+ }
24
+ ];
25
+
26
+ jest.mock("../../routes", () => componentRoutes);
27
+
28
+ // Mock Component for testing
29
+ const TestComponent = ({ router, params, route, location }) => (
30
+ <div>
31
+ <div data-testid="router">{JSON.stringify(router)}</div>
32
+ <div data-testid="params">{JSON.stringify(params)}</div>
33
+ <div data-testid="route">{JSON.stringify(route)}</div>
34
+ <div data-testid="location">{JSON.stringify(location)}</div>
35
+ </div>
36
+ );
37
+
38
+ const EnhancedComponent = withReactRouterV3Compatibility(TestComponent);
39
+
40
+ describe("withReactRouterV3Compatibility", () => {
41
+ // Existing tests for query parameters
42
+ it("converts URL search parameters to an object", () => {
43
+ render(
44
+ <MemoryRouter initialEntries={["/home?user=123&filter=active"]}>
45
+ <EnhancedComponent match={"/home"} />
46
+ </MemoryRouter>
47
+ );
48
+
49
+ const locationText = screen.getByTestId("location").textContent;
50
+ expect(locationText).toContain('"user":"123"');
51
+ expect(locationText).toContain('"filter":"active"');
52
+ });
53
+
54
+ it("supports multiple values for the same query parameter", () => {
55
+ render(
56
+ <MemoryRouter initialEntries={["/home?user=123&user=456"]}>
57
+ <EnhancedComponent />
58
+ </MemoryRouter>
59
+ );
60
+
61
+ const locationText = screen.getByTestId("location").textContent;
62
+ expect(locationText).toContain('"user":["123","456"]');
63
+ });
64
+ });
65
+
66
+
67
+ describe('findRoute function', () => {
68
+ // Setup sample routes array
69
+ const routes = [
70
+ { path: '/home', component: 'HomeComponent' },
71
+ {
72
+ path: '/about',
73
+ component: 'AboutComponent',
74
+ routes: [
75
+ { path: '/about/team', component: 'TeamComponent' },
76
+ { path: '/about/contact', component: 'ContactComponent' }
77
+ ]
78
+ },
79
+ {
80
+ path: '/services',
81
+ routes: [
82
+ {
83
+ path: '/services/design',
84
+ routes: [
85
+ { path: '/services/design/web', component: 'WebDesignComponent' }
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ ];
91
+
92
+ it('finds a top-level route', () => {
93
+ const path = '/home';
94
+ const result = findRoute(routes, path);
95
+ expect(result).toEqual({ path: '/home', component: 'HomeComponent' });
96
+ });
97
+
98
+ it('finds a nested route', () => {
99
+ const path = '/about/contact';
100
+ const result = findRoute(routes, path);
101
+ expect(result).toEqual({ path: '/about/contact', component: 'ContactComponent' });
102
+ });
103
+
104
+ it('returns undefined if no route is found', () => {
105
+ const path = '/non-existent';
106
+ const result = findRoute(routes, path);
107
+ expect(result).toBeUndefined();
108
+ });
109
+
110
+ it('handles routes without a path property safely', () => {
111
+ const badRoutes = [
112
+ { component: 'NoPathComponent' },
113
+ { path: '/valid', component: 'ValidComponent' }
114
+ ];
115
+ const path = '/valid';
116
+ const result = findRoute(badRoutes, path);
117
+ expect(result).toEqual({ path: '/valid', component: 'ValidComponent' });
118
+ });
119
+
120
+ it('finds a deeply nested route', () => {
121
+ const path = '/services/design/web';
122
+ const result = findRoute(routes, path);
123
+ expect(result).toEqual({ path: '/services/design/web', component: 'WebDesignComponent' });
124
+ });
125
+
126
+ it('does not find a route if null values are present', () => {
127
+ const nullRoutes = [
128
+ null,
129
+ { path: '/null-route', component: 'NullComponent' }
130
+ ];
131
+ const path = '/null-route';
132
+ const result = findRoute(nullRoutes, path);
133
+ expect(result).toEqual({ path: '/null-route', component: 'NullComponent' });
134
+ });
135
+ });
@@ -4,7 +4,7 @@ import { compose } from 'redux';
4
4
  import { withRouter } from 'react-router-dom';
5
5
  import componentRoutes from '../routes';
6
6
 
7
- function findRoute(routes, path) {
7
+ export function findRoute(routes, path) {
8
8
  let match;
9
9
  for (let i = 0; i < routes.length; i++) {
10
10
  const route = routes[i];
@@ -22,7 +22,7 @@ function findRoute(routes, path) {
22
22
  return match;
23
23
  }
24
24
 
25
- function getParamsObject(params = []) {
25
+ function getParamsObject(params) {
26
26
  const paramsObject = {};
27
27
  params.forEach((value, key) => {
28
28
  if (paramsObject[key]) {
@@ -40,11 +40,11 @@ function getParamsObject(params = []) {
40
40
  function withReactRouterV3Compatibility(Component) {
41
41
  const EnhancedComponent = (props) => {
42
42
  const { history = {}, location = {}, match = {} } = props;
43
- const matchedRoute = findRoute(componentRoutes, match.path);
43
+ const matchedRoute = findRoute(componentRoutes, match?.path);
44
44
  const newProps = {
45
45
  ...props,
46
46
  router: history,
47
- params: match.params,
47
+ params: match?.params || [],
48
48
  route: matchedRoute,
49
49
  location: {
50
50
  ...location,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.34-alpha.1",
4
+ "version": "8.0.35",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -50,7 +50,7 @@
50
50
  "reselect": "4.0.0",
51
51
  "save": "^2.4.0",
52
52
  "styled-components": "6.1.2",
53
- "uuid": "^10.0.0",
53
+ "uuid": "^8.3.2",
54
54
  "webpack-bugsnag-plugins": "^1.4.3",
55
55
  "whatwg-fetch": "3.0.0"
56
56
  }
@@ -255,15 +255,17 @@ describe("Creatives testing template creation", () => {
255
255
  // navigating to Viber channel
256
256
  await userEvent.click(viberTab);
257
257
  const createButton = creativesScreen.getByRole('button', {
258
- name: /create new/i,
258
+ name: /Create new/i,
259
259
  });
260
260
  await waitFor(() => expect(createButton).toBeEnabled(),{ timeout: 50000, interval: 500 });
261
+ userEvent.click(createButton);
261
262
  await userEvent.click(createButton);
263
+ screen.debug(null,Infinity);
262
264
  const doneButton = creativesScreen.getByRole('button', {
263
265
  name: globalMessages.done.defaultMessage,
264
266
  });
265
267
  //should be disabled as template is not yet confiured
266
- expect(doneButton).toBeDisabled();
268
+ expect(doneButton).toBeDisabled();
267
269
 
268
270
  // enter template name
269
271
  const templateNameInput = await creativesScreen.findByTestId(
@@ -1693,7 +1693,16 @@ export const lineTemplates = {
1693
1693
  message: "meta",
1694
1694
  response: [],
1695
1695
  };
1696
-
1696
+ export const viberTemplates = {
1697
+ "success": true,
1698
+ "status": {
1699
+ "isError": false,
1700
+ "code": 200,
1701
+ "message": "success"
1702
+ },
1703
+ "message": "meta",
1704
+ "response": "H4sIAAAAAAAAA9WbbW/bOBLHv4qP+9aU+TB8BPqi2ysOBXp7QNctDlcUBkVSthrL9llystnA3/1A2UnTxG6zcq1cESAPykih+P9xZjjD3KAmVqu5a2KN7McbNCkDskgqzhkBqYPOFQivi1AECQwN0WVc1+VyUSN7g3JXx/TVLxdNXDTp2xDrply4Zmfy8QY1y3R5NVsu4m+bKo9rZNHNzWWZx/VkU8f1pAzbLdpuPw3vP6aJfzTIIlej7XY7RLOybpbra2Q/ftoOUXO9isiiD29+ff0ODVFZv/RNeRmRbdabOEQLV6Vf1wENkV9H18Tw6zWySBCpOZMaDdFmFQ5dXq6nbwKyglCQd/e+TANhhAGmFFM2JsZyYkFmXLH/fHnW98wmk0tkyRA1y8bNXy036T0ZkUMUYlEuyjRhyC428/l2eKeCjEFyT4hyBTcAlErnBYG+VXj3r/e//V3c/5xGUIbYPnSzniOLZk2zqu1o5NcVXpTTWTO/xot4hYtyHuu4vix9zGqeucr9uVy4qzrzy2pULprlxs8m7UyXl3Hi6jo29YjTXDJFJJZa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/Yny5b/s/lAzFLKAxAAA="
1705
+ };
1697
1706
  export const emailTemplates = {
1698
1707
  success: true,
1699
1708
  status: {
@@ -61,6 +61,9 @@ export const server = setupServer(
61
61
  rest.get(`${API_ENDPOINT}/templates/v1/Line`, (req, res, ctx) =>
62
62
  res(ctx.status(200), ctx.json(apiResponse.lineTemplates)),
63
63
  ),
64
+ rest.get(`${API_ENDPOINT}/templates/v1/Viber`, (req, res, ctx) =>
65
+ res(ctx.status(200), ctx.json(apiResponse.viberTemplates)),
66
+ ),
64
67
  rest.get(`${API_ENDPOINT}/templates/v1/Email`, (req, res, ctx) =>
65
68
  res(ctx.status(200), ctx.json(apiResponse.emailTemplates)),
66
69
  ),
@@ -26,12 +26,6 @@ export const getIsLoggedIn = () => {
26
26
  return isLoggedIn;
27
27
  };
28
28
 
29
- const makeSelectAuthenticatedWithPredicate = state =>
30
- createSelector(
31
- makeSelectAuthenticated(state),
32
- global => global && global.isLoggedIn,
33
- );
34
-
35
29
  export const UserIsAuthenticated = connectedRouterRedirect({
36
30
  authenticatedSelector: getIsLoggedIn,
37
31
  wrapperDisplayName: 'UserIsAuthenticated',