@capillarytech/creatives-library 8.0.184 → 8.0.185

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.184",
4
+ "version": "8.0.185",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -229,8 +229,8 @@ export function* watchGetCdnTransformationConfig() {
229
229
  // Zalo template info watcher - only for preview if previewUrl is empty from Templates component
230
230
  export function* watchForGetTemplateInfoById() {
231
231
  yield takeLatest(ZALO_TEMPLATE_INFO_REQUEST, function* handleZaloTemplateInfoRequest(action) {
232
- // Ignore edit requests (Already handled by Zalo component saga)
233
- if (!action?.payload?.edit) {
232
+ // Honour only preview requests (Other functionality already handled by Zalo component saga)
233
+ if (action?.payload?.preview) {
234
234
  yield call(getTemplateInfoById, action);
235
235
  }
236
236
  });
@@ -249,7 +249,7 @@ export default [
249
249
  watchGetOrgLevelCampaignSettings,
250
250
  watchGetSenderDetails,
251
251
  watchGetCdnTransformationConfig,
252
- watchForGetTemplateInfoById, // Restored for preview functionality from Templates component
252
+ watchForGetTemplateInfoById, // Zalo preview functionality from Templates component
253
253
  ];
254
254
 
255
255
  export function* v2TemplateSaga() {
@@ -262,7 +262,7 @@ export function* v2TemplateSaga() {
262
262
  watchGetCdnTransformationConfig(),
263
263
  watchFetchWeCrmAccounts(),
264
264
  watchGetSenderDetails(),
265
- watchForGetTemplateInfoById(), // Restored for preview functionality from Templates component
265
+ watchForGetTemplateInfoById(), // Zalo preview functionality from Templates component
266
266
  ]);
267
267
  }
268
268
 
@@ -13,13 +13,15 @@ import {
13
13
  getSenderDetails,
14
14
  fetchWeCrmAccounts,
15
15
  sendZippedFile,
16
- fetchUserList
16
+ fetchUserList,
17
+ watchForGetTemplateInfoById
17
18
  } from '../sagas';
18
19
 
19
20
  import * as mockData from './mockData';
20
21
  import { ZALO } from '../../CreativesContainer/constants';
21
- import { VIET_GUYS } from '../../Zalo/constants';
22
+ import { VIET_GUYS, ZALO_TEMPLATE_INFO_REQUEST } from '../../Zalo/constants';
22
23
  import { throwError } from 'redux-saga-test-plan/providers';
24
+ import { getTemplateInfoById } from '../../Zalo/saga';
23
25
 
24
26
  describe('getCdnTransformationConfig saga', () => {
25
27
  it("handle valid response from api", () => {
@@ -322,4 +324,50 @@ describe('fetchUserList Saga', () => {
322
324
  })
323
325
  .run();
324
326
  });
327
+ });
328
+
329
+ describe('watchForGetTemplateInfoById saga', () => {
330
+ it('should call getTemplateInfoById when preview flag is true (preview request)', () => {
331
+ const action = {
332
+ type: ZALO_TEMPLATE_INFO_REQUEST,
333
+ payload: {
334
+ username: 'testUser',
335
+ oa_id: '12345',
336
+ token: 'testToken',
337
+ host: 'testHost',
338
+ id: 'template123',
339
+ preview: true,
340
+ },
341
+ };
342
+
343
+ expectSaga(watchForGetTemplateInfoById)
344
+ .provide([
345
+ [matchers.call.fn(getTemplateInfoById), undefined],
346
+ ])
347
+ .dispatch(action)
348
+ .call(getTemplateInfoById, action)
349
+ .run();
350
+ });
351
+
352
+ it('should not call getTemplateInfoById when preview flag is false or missing (edit request)', () => {
353
+ const action = {
354
+ type: ZALO_TEMPLATE_INFO_REQUEST,
355
+ payload: {
356
+ username: 'testUser',
357
+ oa_id: '12345',
358
+ token: 'testToken',
359
+ host: 'testHost',
360
+ id: 'template123',
361
+ // preview flag is missing (undefined)
362
+ },
363
+ };
364
+
365
+ expectSaga(watchForGetTemplateInfoById)
366
+ .provide([
367
+ [matchers.call.fn(getTemplateInfoById), undefined],
368
+ ])
369
+ .dispatch(action)
370
+ .not.call(getTemplateInfoById, action)
371
+ .run();
372
+ });
325
373
  });
@@ -132,9 +132,8 @@ export const Zalo = (props) => {
132
132
  }
133
133
  }, [selectedZaloAccount, templateData]);
134
134
 
135
- //gets template details - prevent duplicate calls with Templates saga
135
+ //gets template details
136
136
  useEffect(() => {
137
- // Add edit flag to distinguish from preview requests handled by Templates saga
138
137
  if (zaloTempId && oa_id && token && username && hostName) {
139
138
  actions.getTemplateInfoById({
140
139
  username,
@@ -142,7 +141,6 @@ export const Zalo = (props) => {
142
141
  token,
143
142
  host: hostName,
144
143
  id: zaloTempId,
145
- edit: true, // Flag to indicate this is an edit request, not preview
146
144
  actionCallback,
147
145
  });
148
146
  }