@capillarytech/creatives-library 8.0.184-beta.0 → 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
|
@@ -226,15 +226,13 @@ export function* watchGetCdnTransformationConfig() {
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
// Zalo template info watcher - only for preview
|
|
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
|
-
//
|
|
233
|
-
|
|
234
|
-
if (action.payload && action.payload.preview && !action.payload.edit) {
|
|
232
|
+
// Honour only preview requests (Other functionality already handled by Zalo component saga)
|
|
233
|
+
if (action?.payload?.preview) {
|
|
235
234
|
yield call(getTemplateInfoById, action);
|
|
236
235
|
}
|
|
237
|
-
// If it's not a preview request or is an edit request, let the Zalo component handle it
|
|
238
236
|
});
|
|
239
237
|
}
|
|
240
238
|
|
|
@@ -251,7 +249,7 @@ export default [
|
|
|
251
249
|
watchGetOrgLevelCampaignSettings,
|
|
252
250
|
watchGetSenderDetails,
|
|
253
251
|
watchGetCdnTransformationConfig,
|
|
254
|
-
watchForGetTemplateInfoById, //
|
|
252
|
+
watchForGetTemplateInfoById, // Zalo preview functionality from Templates component
|
|
255
253
|
];
|
|
256
254
|
|
|
257
255
|
export function* v2TemplateSaga() {
|
|
@@ -264,7 +262,7 @@ export function* v2TemplateSaga() {
|
|
|
264
262
|
watchGetCdnTransformationConfig(),
|
|
265
263
|
watchFetchWeCrmAccounts(),
|
|
266
264
|
watchGetSenderDetails(),
|
|
267
|
-
watchForGetTemplateInfoById(), //
|
|
265
|
+
watchForGetTemplateInfoById(), // Zalo preview functionality from Templates component
|
|
268
266
|
]);
|
|
269
267
|
}
|
|
270
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,20 +132,15 @@ export const Zalo = (props) => {
|
|
|
132
132
|
}
|
|
133
133
|
}, [selectedZaloAccount, templateData]);
|
|
134
134
|
|
|
135
|
-
//gets template details
|
|
135
|
+
//gets template details
|
|
136
136
|
useEffect(() => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// Only make API call if we have all required data
|
|
140
|
-
// Add edit flag to distinguish from preview requests handled by Templates saga
|
|
141
|
-
if (hasRequiredData) {
|
|
137
|
+
if (zaloTempId && oa_id && token && username && hostName) {
|
|
142
138
|
actions.getTemplateInfoById({
|
|
143
139
|
username,
|
|
144
140
|
oa_id,
|
|
145
141
|
token,
|
|
146
142
|
host: hostName,
|
|
147
143
|
id: zaloTempId,
|
|
148
|
-
edit: true, // Flag to indicate this is an edit request, not preview
|
|
149
144
|
actionCallback,
|
|
150
145
|
});
|
|
151
146
|
}
|