@capillarytech/creatives-library 8.0.310-alpha.0 → 8.0.311

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 (29) hide show
  1. package/package.json +1 -1
  2. package/services/api.js +0 -17
  3. package/services/tests/api.test.js +0 -85
  4. package/utils/commonUtils.js +0 -10
  5. package/utils/tests/commonUtil.test.js +0 -169
  6. package/v2Components/CommonTestAndPreview/SendTestMessage.js +49 -78
  7. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -134
  8. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  9. package/v2Components/CommonTestAndPreview/constants.js +1 -15
  10. package/v2Components/CommonTestAndPreview/index.js +19 -80
  11. package/v2Components/CommonTestAndPreview/messages.js +0 -94
  12. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  13. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -53
  14. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  15. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -36
  16. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  17. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -377
  18. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  19. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1276 -1408
  20. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +288 -321
  21. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5246
  22. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  23. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -284
  24. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -72
  25. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  26. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -657
  27. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +0 -172
  28. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -466
  29. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
@@ -1,114 +0,0 @@
1
- /**
2
- * Unit tests for ExistingCustomerModal
3
- */
4
-
5
- import React from 'react';
6
- import { render, screen, fireEvent } from '@testing-library/react';
7
- import { IntlProvider } from 'react-intl';
8
- import PropTypes from 'prop-types';
9
- import ExistingCustomerModal from '../ExistingCustomerModal';
10
- import { CHANNELS, CUSTOMER_MODAL_EXISTING } from '../constants';
11
-
12
- const mockMessages = {
13
- 'app.v2Components.TestAndPreviewSlidebox.customerCreationModalTitle': 'Add new test customer',
14
- 'app.v2Components.TestAndPreviewSlidebox.existingCustomerModalDescription': 'This user profile already exists in the system.',
15
- 'app.v2Components.TestAndPreviewSlidebox.saveButton': 'Save',
16
- 'app.v2Components.TestAndPreviewSlidebox.cancelButton': 'Cancel',
17
- 'app.v2Components.TestAndPreviewSlidebox.customerEmail': 'Email',
18
- 'app.v2Components.TestAndPreviewSlidebox.customerMobileNumber': 'Mobile Number',
19
- 'app.v2Components.TestAndPreviewSlidebox.customerID': 'Customer ID',
20
- };
21
-
22
- const TestWrapper = ({ children }) => (
23
- <IntlProvider locale="en" messages={mockMessages}>
24
- {children}
25
- </IntlProvider>
26
- );
27
- TestWrapper.propTypes = { children: PropTypes.node };
28
-
29
- describe('ExistingCustomerModal', () => {
30
- const defaultProps = {
31
- customerModal: [true, CUSTOMER_MODAL_EXISTING],
32
- setCustomerModal: jest.fn(),
33
- customerData: { name: 'John Doe', email: 'john@example.com', mobile: '', customerId: 'cust-123' },
34
- channel: CHANNELS.EMAIL,
35
- onSave: jest.fn(),
36
- };
37
-
38
- beforeEach(() => {
39
- jest.clearAllMocks();
40
- });
41
-
42
- it('renders modal with customer details when visible', () => {
43
- render(
44
- <TestWrapper>
45
- <ExistingCustomerModal {...defaultProps} />
46
- </TestWrapper>
47
- );
48
- expect(screen.getByText(/add new test customer/i)).toBeTruthy();
49
- expect(screen.getByText(/this user profile already exists/i)).toBeTruthy();
50
- expect(screen.getByText('John Doe')).toBeTruthy();
51
- expect(screen.getByText(/john@example.com/)).toBeTruthy();
52
- expect(screen.getByText(/cust-123/)).toBeTruthy();
53
- expect(screen.getByRole('button', { name: /save/i })).toBeTruthy();
54
- expect(screen.getByRole('button', { name: /cancel/i })).toBeTruthy();
55
- });
56
-
57
- it('shows mobile when channel is SMS', () => {
58
- render(
59
- <TestWrapper>
60
- <ExistingCustomerModal
61
- {...defaultProps}
62
- channel={CHANNELS.SMS}
63
- customerData={{ name: 'Jane', email: '', mobile: '9123456789', customerId: 'cust-456' }}
64
- />
65
- </TestWrapper>
66
- );
67
- expect(screen.getByText(/9123456789/)).toBeTruthy();
68
- });
69
-
70
- it('calls setCustomerModal when Cancel is clicked', () => {
71
- render(
72
- <TestWrapper>
73
- <ExistingCustomerModal {...defaultProps} />
74
- </TestWrapper>
75
- );
76
- fireEvent.click(screen.getByRole('button', { name: /cancel/i }));
77
- expect(defaultProps.setCustomerModal).toHaveBeenCalledWith([false, '']);
78
- });
79
-
80
- it('calls onSave when Save is clicked', () => {
81
- render(
82
- <TestWrapper>
83
- <ExistingCustomerModal {...defaultProps} />
84
- </TestWrapper>
85
- );
86
- fireEvent.click(screen.getByRole('button', { name: /save/i }));
87
- expect(defaultProps.onSave).toHaveBeenCalled();
88
- expect(defaultProps.onSave.mock.calls[0][0]).toEqual({});
89
- expect(typeof defaultProps.onSave.mock.calls[0][1]).toBe('function');
90
- });
91
-
92
- it('shows dash for missing name', () => {
93
- render(
94
- <TestWrapper>
95
- <ExistingCustomerModal {...defaultProps} customerData={{ name: '', email: 'a@b.co', mobile: '', customerId: 'c1' }} />
96
- </TestWrapper>
97
- );
98
- expect(screen.getByText('-')).toBeTruthy();
99
- });
100
-
101
- it('does not show email row when channel is EMAIL but customerData.email is empty', () => {
102
- render(
103
- <TestWrapper>
104
- <ExistingCustomerModal
105
- {...defaultProps}
106
- customerData={{ name: 'No Email', email: '', mobile: '', customerId: 'c2' }}
107
- />
108
- </TestWrapper>
109
- );
110
- expect(screen.getByText('No Email')).toBeTruthy();
111
- expect(screen.getByText('Customer ID')).toBeTruthy();
112
- expect(screen.getByText('c2')).toBeTruthy();
113
- });
114
- });