@capillarytech/creatives-library 7.10.48 → 7.10.49

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,35 +15,56 @@ 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();
18
21
  const handleClose = jest.fn();
19
22
  const onCreateComplete = jest.fn();
20
23
  const formatMessage = jest.fn();
21
24
  const location = mockData.location;
22
- beforeEach(() => {
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) => {
23
34
  renderedComponent = mountWithIntl(
24
35
  <Provider store={store}>
25
36
  <Whatsapp
26
- actions={{ createWhatsappTemplate, clearCreateResponse }}
37
+ actions={{
38
+ createWhatsappTemplate,
39
+ clearCreateResponse,
40
+ getTemplateDetails,
41
+ resetEditTemplate,
42
+ }}
43
+ globalActions={{ fetchSchemaForEntity }}
27
44
  onCreateComplete={onCreateComplete}
28
45
  handleClose={handleClose}
46
+ params={args.params}
47
+ editData={args.editData}
48
+ accountData={accountData}
29
49
  location={location}
30
50
  intl={{ formatMessage }}
31
51
  isFullMode={true}
32
- selectedWeChatAccount={{
33
- name: 'Test Account',
34
- configs: { accessToken: '123' },
35
- sourceAccountIdentifier: 'A123',
36
- }}
52
+ isEditFlow={args.isEditFlow || false}
53
+ loadingTags={args.loadingTags}
54
+ metaEntities={[]}
55
+ getDefaultTags={true}
37
56
  />
38
57
  </Provider>,
39
58
  );
40
- });
59
+ }
41
60
 
42
- it('should render', () => {
61
+ it('should render create mode', () => {
62
+ renderHelper({});
43
63
  expect(renderedComponent).toMatchSnapshot();
44
64
  });
45
65
 
46
66
  it('template name change', () => {
67
+ renderHelper({});
47
68
  const templateNameRenderHelper = (val) => {
48
69
  let event = { target: { value: val } };
49
70
  renderedComponent
@@ -60,6 +81,7 @@ describe('Creatives Whatsapp test/>', () => {
60
81
  });
61
82
 
62
83
  it('template category change', () => {
84
+ renderHelper({});
63
85
  renderedComponent
64
86
  .find('CapSelect#select-whatsapp-category')
65
87
  .props()
@@ -68,6 +90,7 @@ describe('Creatives Whatsapp test/>', () => {
68
90
  });
69
91
 
70
92
  it('template message', () => {
93
+ renderHelper({});
71
94
  const templateMessageRenderHelper = (val) => {
72
95
  let event = { target: { value: val } };
73
96
  renderedComponent
@@ -90,6 +113,7 @@ describe('Creatives Whatsapp test/>', () => {
90
113
  });
91
114
 
92
115
  it('send for approval should be disabled', () => {
116
+ renderHelper({});
93
117
  const sendForApprovalBtn = renderedComponent
94
118
  .find('CapButton.whatsapp-create-btn')
95
119
  .props();
@@ -100,6 +124,7 @@ describe('Creatives Whatsapp test/>', () => {
100
124
  });
101
125
 
102
126
  it('Cancel Btn', () => {
127
+ renderHelper({});
103
128
  const cancelBtn = renderedComponent
104
129
  .find('CapButton.whatsapp-cancel-btn')
105
130
  .props();
@@ -109,6 +134,7 @@ describe('Creatives Whatsapp test/>', () => {
109
134
  });
110
135
 
111
136
  it('set all valid values and send for approval', () => {
137
+ renderHelper({});
112
138
  let event = { target: { value: 'template_name' } };
113
139
  createWhatsappTemplate.mockImplementation((obj, callback) => {
114
140
  callback();
@@ -127,6 +153,20 @@ describe('Creatives Whatsapp test/>', () => {
127
153
  .at(1)
128
154
  .simulate('change', event);
129
155
  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);
130
170
  expect(renderedComponent).toMatchSnapshot();
131
171
  });
132
172
  });
@@ -1,6 +1,125 @@
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
+ },
2
121
  location: {
3
- pathname: '/whatsapp',
122
+ pathname: '/whatsapp/edit',
4
123
  query: {
5
124
  type: false,
6
125
  module: 'default',