@capillarytech/creatives-library 9.2.1 → 9.2.2-alpha.sprint-cap-214249.44
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +51 -12
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +100 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +86 -81
- package/v2Containers/Templates/tests/index.test.js +81 -0
|
@@ -7,7 +7,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
|
7
7
|
import { initialReducer } from '../../../../initialReducer';
|
|
8
8
|
import history from '../../../../utils/history';
|
|
9
9
|
import CtaButtons from '../CtaButtons';
|
|
10
|
-
import { PRIMARY,
|
|
10
|
+
import { PRIMARY, DEEP_LINK } from '../../constants';
|
|
11
11
|
|
|
12
12
|
// Mock the UI components
|
|
13
13
|
jest.mock('@capillarytech/cap-ui-library/CapRow', () =>
|
|
@@ -82,6 +82,10 @@ jest.mock('../../messages', () => ({
|
|
|
82
82
|
id: 'buttons',
|
|
83
83
|
defaultMessage: 'Buttons',
|
|
84
84
|
},
|
|
85
|
+
optionalText: {
|
|
86
|
+
id: 'optional.text',
|
|
87
|
+
defaultMessage: '(Optional)',
|
|
88
|
+
},
|
|
85
89
|
addPrimaryButton: {
|
|
86
90
|
id: 'add.primary.button',
|
|
87
91
|
defaultMessage: 'Add primary button',
|
|
@@ -128,7 +132,7 @@ describe('CtaButtons', () => {
|
|
|
128
132
|
describe('Initial Rendering', () => {
|
|
129
133
|
it('should render the component with default props', () => {
|
|
130
134
|
renderComponent();
|
|
131
|
-
expect(screen.
|
|
135
|
+
expect(screen.getAllByTestId('cap-row').length).toBeGreaterThan(0);
|
|
132
136
|
expect(screen.getByText('Buttons')).toBeInTheDocument();
|
|
133
137
|
});
|
|
134
138
|
|
|
@@ -221,114 +225,31 @@ describe('CtaButtons', () => {
|
|
|
221
225
|
});
|
|
222
226
|
});
|
|
223
227
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
renderComponent({ ctaData });
|
|
231
|
-
|
|
232
|
-
expect(screen.getByTestId('add-secondary-button')).toBeInTheDocument();
|
|
233
|
-
expect(screen.getByText('Add secondary button')).toBeInTheDocument();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('should not render add secondary button when primary button is not saved', () => {
|
|
237
|
-
const ctaData = [
|
|
238
|
-
{ index: 0, text: 'Primary Button', isSaved: false }
|
|
239
|
-
];
|
|
240
|
-
|
|
241
|
-
renderComponent({ ctaData });
|
|
242
|
-
|
|
243
|
-
expect(screen.queryByTestId('add-secondary-button')).not.toBeInTheDocument();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should handle adding secondary button', () => {
|
|
247
|
-
const setSecondaryButton = jest.fn();
|
|
248
|
-
const updateHandler = jest.fn();
|
|
249
|
-
const ctaData = [
|
|
250
|
-
{ index: 0, text: 'Primary Button', isSaved: true }
|
|
251
|
-
];
|
|
252
|
-
|
|
253
|
-
renderComponent({
|
|
254
|
-
ctaData,
|
|
255
|
-
setSecondaryButton,
|
|
256
|
-
updateHandler
|
|
228
|
+
// Secondary button is commented out until backend support lands
|
|
229
|
+
describe('Secondary Button (hidden)', () => {
|
|
230
|
+
it('does not render add secondary button even when the primary button is saved', () => {
|
|
231
|
+
renderComponent({
|
|
232
|
+
primaryButton: true,
|
|
233
|
+
ctaData: [{ index: 0, text: 'Primary Button', isSaved: true }],
|
|
257
234
|
});
|
|
258
|
-
|
|
259
|
-
// The secondary button should be disabled when primary button is saved
|
|
260
|
-
const secondaryButton = screen.getByTestId('add-secondary-button');
|
|
261
|
-
expect(secondaryButton).toBeDisabled();
|
|
262
|
-
|
|
263
|
-
// Since the button is disabled, clicking it should not trigger the handlers
|
|
264
|
-
fireEvent.click(secondaryButton);
|
|
265
|
-
|
|
266
|
-
// The handlers should not be called because the button is disabled
|
|
267
|
-
expect(updateHandler).not.toHaveBeenCalled();
|
|
268
|
-
expect(setSecondaryButton).not.toHaveBeenCalled();
|
|
269
|
-
});
|
|
270
235
|
|
|
271
|
-
it('should handle adding secondary button when primary button is not saved', () => {
|
|
272
|
-
const setSecondaryButton = jest.fn();
|
|
273
|
-
const updateHandler = jest.fn();
|
|
274
|
-
const ctaData = [
|
|
275
|
-
{ index: 0, text: 'Primary Button', isSaved: false }
|
|
276
|
-
];
|
|
277
|
-
|
|
278
|
-
renderComponent({
|
|
279
|
-
ctaData,
|
|
280
|
-
setSecondaryButton,
|
|
281
|
-
updateHandler
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// The secondary button should not be rendered when primary button is not saved
|
|
285
236
|
expect(screen.queryByTestId('add-secondary-button')).not.toBeInTheDocument();
|
|
237
|
+
expect(screen.queryByText('Add secondary button')).not.toBeInTheDocument();
|
|
286
238
|
});
|
|
287
239
|
|
|
288
|
-
it('
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const ctaData = [
|
|
292
|
-
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
293
|
-
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY' }
|
|
294
|
-
];
|
|
295
|
-
|
|
296
|
-
renderComponent({
|
|
297
|
-
ctaData,
|
|
240
|
+
it('does not render a secondary CTA form for a template that already has one', () => {
|
|
241
|
+
renderComponent({
|
|
242
|
+
primaryButton: true,
|
|
298
243
|
secondaryButton: true,
|
|
299
|
-
|
|
300
|
-
|
|
244
|
+
ctaData: [
|
|
245
|
+
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
246
|
+
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY', isSaved: true },
|
|
247
|
+
],
|
|
301
248
|
});
|
|
302
|
-
|
|
303
|
-
// Should not render add button when secondaryButton is true and button exists
|
|
304
|
-
expect(screen.queryByTestId('add-secondary-button')).not.toBeInTheDocument();
|
|
305
|
-
});
|
|
306
249
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
{ index: 1, text: 'Secondary Button', isSaved: true }
|
|
311
|
-
];
|
|
312
|
-
|
|
313
|
-
renderComponent({ ctaData });
|
|
314
|
-
|
|
315
|
-
expect(screen.queryByTestId('add-secondary-button')).not.toBeInTheDocument();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('should show secondary CTA when secondary button is active and exists', () => {
|
|
319
|
-
const ctaData = [
|
|
320
|
-
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
321
|
-
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY' }
|
|
322
|
-
];
|
|
323
|
-
|
|
324
|
-
renderComponent({
|
|
325
|
-
secondaryButton: true,
|
|
326
|
-
ctaData
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
const secondaryCTA = screen.getByTestId('cap-mpush-cta');
|
|
330
|
-
expect(secondaryCTA).toBeInTheDocument();
|
|
331
|
-
expect(secondaryCTA).toHaveAttribute('data-button-type', 'SECONDARY');
|
|
250
|
+
const ctas = screen.getAllByTestId('cap-mpush-cta');
|
|
251
|
+
expect(ctas).toHaveLength(1);
|
|
252
|
+
expect(ctas[0]).toHaveAttribute('data-button-type', 'PRIMARY');
|
|
332
253
|
});
|
|
333
254
|
});
|
|
334
255
|
|
|
@@ -379,12 +300,18 @@ describe('CtaButtons', () => {
|
|
|
379
300
|
it('should render proper component structure', () => {
|
|
380
301
|
renderComponent();
|
|
381
302
|
|
|
382
|
-
expect(screen.
|
|
303
|
+
expect(screen.getAllByTestId('cap-row')).toHaveLength(2);
|
|
383
304
|
expect(screen.getByTestId('cap-heading')).toBeInTheDocument();
|
|
384
305
|
expect(screen.getByTestId('cap-icon')).toBeInTheDocument();
|
|
385
306
|
expect(screen.getByTestId('cap-icon')).toHaveAttribute('data-icon-type', 'plus');
|
|
386
307
|
});
|
|
387
308
|
|
|
309
|
+
it('should render (Optional) beside the Buttons heading', () => {
|
|
310
|
+
renderComponent();
|
|
311
|
+
|
|
312
|
+
expect(screen.getByText('(Optional)')).toBeInTheDocument();
|
|
313
|
+
});
|
|
314
|
+
|
|
388
315
|
it('should render heading with correct type', () => {
|
|
389
316
|
renderComponent();
|
|
390
317
|
|
|
@@ -417,44 +344,6 @@ describe('CtaButtons', () => {
|
|
|
417
344
|
expect(updateHandler).not.toHaveBeenCalled();
|
|
418
345
|
});
|
|
419
346
|
|
|
420
|
-
it('should handle early return when secondary button exists and showSecondaryCTA is true', () => {
|
|
421
|
-
const updateHandler = jest.fn();
|
|
422
|
-
const setSecondaryButton = jest.fn();
|
|
423
|
-
const ctaData = [
|
|
424
|
-
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
425
|
-
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY' }
|
|
426
|
-
];
|
|
427
|
-
|
|
428
|
-
renderComponent({
|
|
429
|
-
secondaryButton: true,
|
|
430
|
-
ctaData,
|
|
431
|
-
updateHandler,
|
|
432
|
-
setSecondaryButton
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
// Since secondaryButton is true and button exists, updateHandler should not be called
|
|
436
|
-
expect(updateHandler).not.toHaveBeenCalled();
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it('should handle early return when shouldShowSecondaryCTA is true', () => {
|
|
440
|
-
const updateHandler = jest.fn();
|
|
441
|
-
const setSecondaryButton = jest.fn();
|
|
442
|
-
const ctaData = [
|
|
443
|
-
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
444
|
-
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY' }
|
|
445
|
-
];
|
|
446
|
-
|
|
447
|
-
renderComponent({
|
|
448
|
-
secondaryButton: true,
|
|
449
|
-
ctaData,
|
|
450
|
-
updateHandler,
|
|
451
|
-
setSecondaryButton
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
// Since shouldShowSecondaryCTA is true, updateHandler should not be called
|
|
455
|
-
expect(updateHandler).not.toHaveBeenCalled();
|
|
456
|
-
});
|
|
457
|
-
|
|
458
347
|
it('should handle early return in handleAddPrimary when primaryButton and showPrimaryCTA are true', () => {
|
|
459
348
|
const updateHandler = jest.fn();
|
|
460
349
|
const setPrimaryButton = jest.fn();
|
|
@@ -494,72 +383,5 @@ describe('CtaButtons', () => {
|
|
|
494
383
|
expect(setPrimaryButton).not.toHaveBeenCalled();
|
|
495
384
|
}
|
|
496
385
|
});
|
|
497
|
-
|
|
498
|
-
it('should handle early return in handleAddSecondary when secondaryButton and showSecondaryCTA are true', () => {
|
|
499
|
-
const updateHandler = jest.fn();
|
|
500
|
-
const setSecondaryButton = jest.fn();
|
|
501
|
-
const ctaData = [
|
|
502
|
-
{ index: 0, text: 'Primary Button', isSaved: true }
|
|
503
|
-
];
|
|
504
|
-
|
|
505
|
-
const { rerender } = renderComponent({
|
|
506
|
-
secondaryButton: true,
|
|
507
|
-
ctaData,
|
|
508
|
-
updateHandler,
|
|
509
|
-
setSecondaryButton
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
// First click to set showSecondaryCTA to true
|
|
513
|
-
const addButton = screen.getByTestId('add-secondary-button');
|
|
514
|
-
fireEvent.click(addButton);
|
|
515
|
-
|
|
516
|
-
// Clear the mock calls
|
|
517
|
-
updateHandler.mockClear();
|
|
518
|
-
setSecondaryButton.mockClear();
|
|
519
|
-
|
|
520
|
-
// Re-render with secondaryButton true and showSecondaryCTA true (from previous click)
|
|
521
|
-
rerender(
|
|
522
|
-
<Provider store={mockStore}>
|
|
523
|
-
<IntlProvider locale="en" messages={{}}>
|
|
524
|
-
<CtaButtons
|
|
525
|
-
{...defaultProps}
|
|
526
|
-
secondaryButton={true}
|
|
527
|
-
ctaData={ctaData}
|
|
528
|
-
updateHandler={updateHandler}
|
|
529
|
-
setSecondaryButton={setSecondaryButton}
|
|
530
|
-
/>
|
|
531
|
-
</IntlProvider>
|
|
532
|
-
</Provider>
|
|
533
|
-
);
|
|
534
|
-
|
|
535
|
-
// Try to click again - should hit early return
|
|
536
|
-
if (screen.queryByTestId('add-secondary-button')) {
|
|
537
|
-
fireEvent.click(screen.getByTestId('add-secondary-button'));
|
|
538
|
-
expect(updateHandler).not.toHaveBeenCalled();
|
|
539
|
-
expect(setSecondaryButton).not.toHaveBeenCalled();
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it('should handle early return in handleAddSecondary when shouldShowSecondaryCTA is true', () => {
|
|
544
|
-
const updateHandler = jest.fn();
|
|
545
|
-
const setSecondaryButton = jest.fn();
|
|
546
|
-
const ctaData = [
|
|
547
|
-
{ index: 0, text: 'Primary Button', isSaved: true },
|
|
548
|
-
{ index: 1, text: 'Secondary Button', ctaType: 'SECONDARY' }
|
|
549
|
-
];
|
|
550
|
-
|
|
551
|
-
renderComponent({
|
|
552
|
-
secondaryButton: true,
|
|
553
|
-
ctaData,
|
|
554
|
-
updateHandler,
|
|
555
|
-
setSecondaryButton
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
// Since shouldShowSecondaryCTA is true (secondaryButton is true and button exists),
|
|
559
|
-
// the add button should not be rendered
|
|
560
|
-
expect(screen.queryByTestId('add-secondary-button')).not.toBeInTheDocument();
|
|
561
|
-
expect(updateHandler).not.toHaveBeenCalled();
|
|
562
|
-
expect(setSecondaryButton).not.toHaveBeenCalled();
|
|
563
|
-
});
|
|
564
386
|
});
|
|
565
387
|
});
|