@capillarytech/creatives-library 8.0.105 → 8.0.106
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/config/app.js
CHANGED
|
@@ -17,16 +17,16 @@ const config = {
|
|
|
17
17
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
18
18
|
},
|
|
19
19
|
development: {
|
|
20
|
-
api_endpoint: 'https://
|
|
21
|
-
campaigns_api_endpoint: 'https://
|
|
22
|
-
campaigns_api_org_endpoint: 'https://
|
|
23
|
-
auth_endpoint: 'https://
|
|
24
|
-
arya_endpoint: 'https://
|
|
25
|
-
subscription_api_endpoint: 'https://
|
|
26
|
-
exports_api_endpoint: 'https://
|
|
20
|
+
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
21
|
+
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
22
|
+
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
23
|
+
auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
|
|
24
|
+
arya_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1',
|
|
25
|
+
subscription_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/org-settings/subscription',
|
|
26
|
+
exports_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/export/data',
|
|
27
27
|
login_url: '/auth/login',
|
|
28
28
|
dashboard_url: '/sms',
|
|
29
|
-
liquid_endpoint: 'https://
|
|
29
|
+
liquid_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/template',
|
|
30
30
|
dashboard_url_v2: '/v2',
|
|
31
31
|
},
|
|
32
32
|
testing: {
|
package/package.json
CHANGED
|
@@ -740,7 +740,10 @@ export class Creatives extends React.Component {
|
|
|
740
740
|
forEach(androidContent.custom, (customKeyValue) => {
|
|
741
741
|
custom[customKeyValue.key] = customKeyValue.value;
|
|
742
742
|
});
|
|
743
|
-
|
|
743
|
+
//skipping it for MPUSH as custom key is already in the reqd format for hydra sdk
|
|
744
|
+
if (channel !== constants.MOBILE_PUSH) {
|
|
745
|
+
androidContent.custom = custom;
|
|
746
|
+
}
|
|
744
747
|
templateData.androidContent = androidContent;
|
|
745
748
|
templateData.androidContent.type = get(channelTemplate, 'definition.mode', '').toUpperCase();
|
|
746
749
|
templateData.androidContent.deviceType = 'ANDROID';
|
|
@@ -756,7 +759,10 @@ export class Creatives extends React.Component {
|
|
|
756
759
|
forEach(iosContent.custom, (customKeyValue) => {
|
|
757
760
|
custom[customKeyValue.key] = customKeyValue.value;
|
|
758
761
|
});
|
|
759
|
-
|
|
762
|
+
//skipping it for MPUSH as custom key is already in the reqd format for hydra sdk
|
|
763
|
+
if (channel !== constants.MOBILE_PUSH) {
|
|
764
|
+
iosContent.custom = custom;
|
|
765
|
+
}
|
|
760
766
|
templateData.iosContent = iosContent;
|
|
761
767
|
templateData.iosContent.type = get(channelTemplate, 'definition.mode').toUpperCase();
|
|
762
768
|
templateData.iosContent.deviceType = IOS.toUpperCase();
|
|
@@ -367,41 +367,83 @@ describe('useEmailWrapper', () => {
|
|
|
367
367
|
});
|
|
368
368
|
|
|
369
369
|
it('calls setEdmTemplate/setBEETemplate in useEffect when in EDITOR mode and CREATE_TEMPLATE_CONTENT step', async () => {
|
|
370
|
+
// 1. Setup
|
|
370
371
|
const templateId = 'editorTemplate456';
|
|
371
372
|
const mockTemplateData = { _id: templateId, name: 'Selected Editor Template' };
|
|
372
|
-
find.mockReturnValue(mockTemplateData);
|
|
373
373
|
|
|
374
|
-
|
|
374
|
+
// Ensure mocks are clean from previous tests
|
|
375
|
+
find.mockClear();
|
|
376
|
+
isEmpty.mockClear();
|
|
377
|
+
mockProps.templatesActions.setEdmTemplate.mockClear();
|
|
378
|
+
mockProps.templatesActions.setBEETemplate.mockClear();
|
|
379
|
+
mockProps.showNextStep.mockClear();
|
|
380
|
+
|
|
381
|
+
// 2. Mock find (this will be called by the *internal* handleEdmDefaultTemplateSelection)
|
|
382
|
+
find.mockImplementation((array, criteria) => {
|
|
383
|
+
// console.log('DEBUG: find called with', JSON.stringify(array), JSON.stringify(criteria)); // Optional debug
|
|
384
|
+
if (array && criteria && criteria._id === templateId && array[0]?._id === templateId) {
|
|
385
|
+
return mockTemplateData;
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// 3. Initial Render (Template Selection Step)
|
|
391
|
+
const initialProps = {
|
|
375
392
|
...mockProps,
|
|
376
393
|
step: STEPS.TEMPLATE_SELECTION,
|
|
377
394
|
emailCreateMode: EMAIL_CREATE_MODES.EDITOR,
|
|
378
395
|
CmsTemplates: [mockTemplateData],
|
|
379
396
|
SelectedEdmDefaultTemplate: null,
|
|
397
|
+
// selectedCreateMode is initially '' from hook's useState
|
|
380
398
|
};
|
|
381
|
-
|
|
382
399
|
const { result, rerender } = renderHook((props) => useEmailWrapper(props), {
|
|
383
|
-
|
|
400
|
+
initialProps: initialProps
|
|
384
401
|
});
|
|
385
402
|
|
|
403
|
+
// 4. Simulate user selecting a template ID via the exposed callback (useEditor)
|
|
386
404
|
reactAct(() => {
|
|
405
|
+
// This maps to useEditor which calls setModeContent and showNextStep
|
|
387
406
|
result.current.cmsTemplatesProps.handleEdmDefaultTemplateSelection(templateId);
|
|
388
407
|
});
|
|
389
|
-
|
|
390
|
-
expect(result.current.modeContent).toEqual({ id: templateId });
|
|
391
|
-
expect(mockProps.showNextStep).
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
408
|
+
// Verify internal state updated and mock called
|
|
409
|
+
expect(result.current.modeContent).toEqual({ id: templateId }); // State updated
|
|
410
|
+
expect(mockProps.showNextStep).toHaveBeenCalledTimes(1); // User action effect
|
|
411
|
+
|
|
412
|
+
// 5. Rerender with step changed to CREATE_TEMPLATE_CONTENT
|
|
413
|
+
const createContentProps = {
|
|
414
|
+
...initialProps, // Base props
|
|
415
|
+
step: STEPS.CREATE_TEMPLATE_CONTENT, // *** Change step ***
|
|
416
|
+
SelectedEdmDefaultTemplate: null // *** Ensure this is null ***
|
|
417
|
+
// The internal state `modeContent = { id: templateId }` persists
|
|
418
|
+
// The internal state `selectedCreateMode = ''` also persists (not changed yet)
|
|
396
419
|
};
|
|
397
420
|
|
|
398
|
-
rerender
|
|
421
|
+
// Mock isEmpty just before rerender for the specific check inside the effect
|
|
422
|
+
isEmpty.mockImplementation(val => {
|
|
423
|
+
// console.log('DEBUG: isEmpty called with', JSON.stringify(val)); // Optional debug
|
|
424
|
+
// Return true ONLY for the 'SelectedEdmDefaultTemplate' check (which is null)
|
|
425
|
+
if (val === null) return true;
|
|
426
|
+
// Provide a fallback for other potential isEmpty calls if needed
|
|
427
|
+
if (typeof val === 'object' && !val) return true;
|
|
428
|
+
if (typeof val === 'object' && Object.keys(val).length === 0) return true;
|
|
429
|
+
if (typeof val === 'string' && val.trim().length === 0) return true;
|
|
430
|
+
return !val;
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
rerender(createContentProps);
|
|
399
434
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
435
|
+
// 6. Wait for effects triggered by the rerender
|
|
436
|
+
await reactAct(async () => {
|
|
437
|
+
// Short pause allows React's scheduler to run effects
|
|
438
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
404
439
|
});
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
// Assert that the template setting actions were called as a result of the effect
|
|
443
|
+
expect(mockProps.templatesActions.setEdmTemplate).toHaveBeenCalledTimes(1);
|
|
444
|
+
expect(mockProps.templatesActions.setEdmTemplate).toHaveBeenCalledWith(mockTemplateData);
|
|
445
|
+
expect(mockProps.templatesActions.setBEETemplate).toHaveBeenCalledTimes(1);
|
|
446
|
+
expect(mockProps.templatesActions.setBEETemplate).toHaveBeenCalledWith(mockTemplateData);
|
|
405
447
|
});
|
|
406
448
|
|
|
407
449
|
it('sets selectedCreateMode in useEffect when in UPLOAD mode and CREATE_TEMPLATE_CONTENT step with EmailLayout', async () => {
|