@capillarytech/creatives-library 7.10.49 → 7.10.50

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.
@@ -15,56 +15,35 @@ describe('Creatives Whatsapp test/>', () => {
15
15
  let renderedComponent;
16
16
  const createWhatsappTemplate = jest.fn();
17
17
  const clearCreateResponse = jest.fn();
18
- const getTemplateDetails = jest.fn();
19
- const resetEditTemplate = jest.fn();
20
- const fetchSchemaForEntity = jest.fn();
21
18
  const handleClose = jest.fn();
22
19
  const onCreateComplete = jest.fn();
23
20
  const formatMessage = jest.fn();
24
21
  const location = mockData.location;
25
- const params = {
26
- id: mockData.editData1.templateDetails._id,
27
- };
28
- const editData1 = mockData.editData1;
29
- const editData2 = mockData.editData2;
30
- const editData3 = mockData.editData3;
31
- const accountData = mockData.accountData;
32
-
33
- const renderHelper = (args) => {
22
+ beforeEach(() => {
34
23
  renderedComponent = mountWithIntl(
35
24
  <Provider store={store}>
36
25
  <Whatsapp
37
- actions={{
38
- createWhatsappTemplate,
39
- clearCreateResponse,
40
- getTemplateDetails,
41
- resetEditTemplate,
42
- }}
43
- globalActions={{ fetchSchemaForEntity }}
26
+ actions={{ createWhatsappTemplate, clearCreateResponse }}
44
27
  onCreateComplete={onCreateComplete}
45
28
  handleClose={handleClose}
46
- params={args.params}
47
- editData={args.editData}
48
- accountData={accountData}
49
29
  location={location}
50
30
  intl={{ formatMessage }}
51
31
  isFullMode={true}
52
- isEditFlow={args.isEditFlow || false}
53
- loadingTags={args.loadingTags}
54
- metaEntities={[]}
55
- getDefaultTags={true}
32
+ selectedWeChatAccount={{
33
+ name: 'Test Account',
34
+ configs: { accessToken: '123' },
35
+ sourceAccountIdentifier: 'A123',
36
+ }}
56
37
  />
57
38
  </Provider>,
58
39
  );
59
- }
40
+ });
60
41
 
61
- it('should render create mode', () => {
62
- renderHelper({});
42
+ it('should render', () => {
63
43
  expect(renderedComponent).toMatchSnapshot();
64
44
  });
65
45
 
66
46
  it('template name change', () => {
67
- renderHelper({});
68
47
  const templateNameRenderHelper = (val) => {
69
48
  let event = { target: { value: val } };
70
49
  renderedComponent
@@ -81,7 +60,6 @@ describe('Creatives Whatsapp test/>', () => {
81
60
  });
82
61
 
83
62
  it('template category change', () => {
84
- renderHelper({});
85
63
  renderedComponent
86
64
  .find('CapSelect#select-whatsapp-category')
87
65
  .props()
@@ -90,7 +68,6 @@ describe('Creatives Whatsapp test/>', () => {
90
68
  });
91
69
 
92
70
  it('template message', () => {
93
- renderHelper({});
94
71
  const templateMessageRenderHelper = (val) => {
95
72
  let event = { target: { value: val } };
96
73
  renderedComponent
@@ -113,7 +90,6 @@ describe('Creatives Whatsapp test/>', () => {
113
90
  });
114
91
 
115
92
  it('send for approval should be disabled', () => {
116
- renderHelper({});
117
93
  const sendForApprovalBtn = renderedComponent
118
94
  .find('CapButton.whatsapp-create-btn')
119
95
  .props();
@@ -124,7 +100,6 @@ describe('Creatives Whatsapp test/>', () => {
124
100
  });
125
101
 
126
102
  it('Cancel Btn', () => {
127
- renderHelper({});
128
103
  const cancelBtn = renderedComponent
129
104
  .find('CapButton.whatsapp-cancel-btn')
130
105
  .props();
@@ -134,7 +109,6 @@ describe('Creatives Whatsapp test/>', () => {
134
109
  });
135
110
 
136
111
  it('set all valid values and send for approval', () => {
137
- renderHelper({});
138
112
  let event = { target: { value: 'template_name' } };
139
113
  createWhatsappTemplate.mockImplementation((obj, callback) => {
140
114
  callback();
@@ -153,20 +127,6 @@ describe('Creatives Whatsapp test/>', () => {
153
127
  .at(1)
154
128
  .simulate('change', event);
155
129
  renderedComponent.find('CapButton.whatsapp-create-btn').props().onClick();
156
- });
157
-
158
- it('should render edit mode in various cases', () => {
159
- let event = { target: { value: '5454', id: '{{1}}_1' } };
160
- renderHelper({ params, editData: editData1, isEditFlow: true, loadingTags: false });
161
- expect(renderedComponent).toMatchSnapshot();
162
- renderHelper({ params, editData: editData2, isEditFlow: true, loadingTags: false });
163
- expect(renderedComponent).toMatchSnapshot();
164
- renderHelper({ params, editData: editData3, isEditFlow: true, loadingTags: false });
165
- expect(renderedComponent).toMatchSnapshot();
166
- renderHelper({ params, editData: editData1, isEditFlow: true, loadingTags: false });
167
- renderedComponent.find('textarea.TextArea__StyledTextArea-sc-177dfyt-2')
168
- .at(1)
169
- .simulate('change', event);
170
130
  expect(renderedComponent).toMatchSnapshot();
171
131
  });
172
132
  });
@@ -1,125 +1,6 @@
1
1
  export const mockData = {
2
- accountData: {
3
- selectedWhatsappAccount: {
4
- name: 'WhatsppTest',
5
- sourceAccountIdentifier: 'AC41030cebba9e2f1ce37c78235da0ee18',
6
- configs: { accessToken: '4676323eb5d1f975b0987070c03a8efc' },
7
- },
8
- },
9
- editData1: {
10
- templateDetails: {
11
- "_id": "62034b4683c75608cf2404ec",
12
- "name": "points_update",
13
- "type": "WHATSAPP",
14
- "versions": {
15
- "history": [],
16
- "base": {
17
- "content": {
18
- "whatsapp": {
19
- "status": "approved",
20
- "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
21
- "accountName": "WhatsppTest",
22
- "accessToken": "4676323eb5d1f975b0987070c03a8efc",
23
- "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
24
- "mediaType": "text",
25
- "languages": [
26
- {
27
- "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
28
- "language": "en"
29
- }
30
- ],
31
- "category": "ACCOUNT_UPDATE",
32
- "rejection_reason": null,
33
- "varMapped": {
34
- '{{1}}_1': '500',
35
- '{{2}}_3': 'tomorrow',
36
- }
37
- }
38
- }
39
- }
40
- },
41
- "isActive": true,
42
- "orgId": 50146,
43
- "createdBy": "15000449",
44
- "updatedBy": "15000449",
45
- "createdAt": "2022-02-09T05:04:06.579Z",
46
- "updatedAt": "2022-02-09T05:04:06.579Z"
47
- },
48
- },
49
- editData2: {
50
- templateDetails: {
51
- "_id": "62034b4683c75608cf2404ec",
52
- "name": "points_update",
53
- "type": "WHATSAPP",
54
- "versions": {
55
- "history": [],
56
- "base": {
57
- "content": {
58
- "whatsapp": {
59
- "status": "rejected",
60
- "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
61
- "accountName": "WhatsppTest",
62
- "accessToken": "4676323eb5d1f975b0987070c03a8efc",
63
- "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
64
- "mediaType": "text",
65
- "languages": [
66
- {
67
- "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
68
- "language": "en"
69
- }
70
- ],
71
- "category": "ACCOUNT_UPDATE",
72
- "rejection_reason": 'INVALID_FORMAT'
73
- }
74
- }
75
- }
76
- },
77
- "isActive": true,
78
- "orgId": 50146,
79
- "createdBy": "15000449",
80
- "updatedBy": "15000449",
81
- "createdAt": "2022-02-09T05:04:06.579Z",
82
- "updatedAt": "2022-02-09T05:04:06.579Z"
83
- },
84
- },
85
- editData3: {
86
- templateDetails: {
87
- "_id": "62034b4683c75608cf2404ec",
88
- "name": "points_update",
89
- "type": "WHATSAPP",
90
- "versions": {
91
- "history": [],
92
- "base": {
93
- "content": {
94
- "whatsapp": {
95
- "status": "rejected",
96
- "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
97
- "accountName": "WhatsppTest",
98
- "accessToken": "4676323eb5d1f975b0987070c03a8efc",
99
- "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
100
- "mediaType": "text",
101
- "languages": [
102
- {
103
- "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
104
- "language": "en"
105
- }
106
- ],
107
- "category": "ACCOUNT_UPDATE",
108
- "rejection_reason": 'TAG_CONTENT_MISMATCH'
109
- }
110
- }
111
- }
112
- },
113
- "isActive": true,
114
- "orgId": 50146,
115
- "createdBy": "15000449",
116
- "updatedBy": "15000449",
117
- "createdAt": "2022-02-09T05:04:06.579Z",
118
- "updatedAt": "2022-02-09T05:04:06.579Z"
119
- },
120
- },
121
2
  location: {
122
- pathname: '/whatsapp/edit',
3
+ pathname: '/whatsapp',
123
4
  query: {
124
5
  type: false,
125
6
  module: 'default',