@tiledesk/tiledesk-server 2.4.83 → 2.4.84

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.4.84
9
+ - Updated tybot-connector to 0.2.38
10
+ - Updated whatsapp-connector to 0.1.58
11
+
8
12
  # 2.4.83
9
13
  - Improved whatsapp log services
10
14
  - Updated whatsapp-connector to 0.1.57
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.4.83",
4
+ "version": "2.4.84",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -45,8 +45,8 @@
45
45
  "@tiledesk/tiledesk-messenger-connector": "^0.1.13",
46
46
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
47
47
  "@tiledesk/tiledesk-telegram-connector": "^0.1.10",
48
- "@tiledesk/tiledesk-tybot-connector": "^0.2.30",
49
- "@tiledesk/tiledesk-whatsapp-connector": "^0.1.57",
48
+ "@tiledesk/tiledesk-tybot-connector": "^0.2.38",
49
+ "@tiledesk/tiledesk-whatsapp-connector": "^0.1.58",
50
50
  "@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.7",
51
51
  "amqplib": "^0.5.5",
52
52
  "app-root-path": "^3.0.0",
package/routes/auth.js CHANGED
@@ -379,7 +379,16 @@ router.post('/signinWithCustomToken', [
379
379
  winston.debug('project user already exists ');
380
380
 
381
381
  if (project_user.status==="active") {
382
- return res.json({ success: true, token: req.headers["authorization"], user: userToReturn });
382
+
383
+ if (req.user.role && (req.user.role === RoleConstants.OWNER || req.user.role === RoleConstants.ADMIN || req.user.role === RoleConstants.AGENT)) {
384
+ let userFromDB = await User.findOne({email: req.user.email , status: 100}).exec();
385
+ return res.json({ success: true, token: req.headers["authorization"], user: userFromDB });
386
+
387
+ } else {
388
+ return res.json({ success: true, token: req.headers["authorization"], user: userToReturn });
389
+ }
390
+
391
+
383
392
  } else {
384
393
  winston.warn('Authentication failed. Project_user not active.');
385
394
  return res.status(401).send({ success: false, msg: 'Authentication failed. Project_user not active.' });
package/routes/faq.js CHANGED
@@ -13,6 +13,10 @@ const botEvent = require('../event/botEvent');
13
13
  const uuidv4 = require('uuid/v4');
14
14
  csv = require('csv-express');
15
15
  csv.separator = ';';
16
+ const axios = require("axios").default;
17
+ var configGlobal = require('../config/global');
18
+
19
+ const apiUrl = process.env.API_URL || configGlobal.apiUrl;
16
20
 
17
21
  // POST CSV FILE UPLOAD FROM CLIENT
18
22
  router.post('/uploadcsv', upload.single('uploadFile'), function (req, res, next) {
@@ -200,6 +204,122 @@ router.post('/', function (req, res) {
200
204
  });
201
205
  });
202
206
 
207
+ router.post('/ops_update', async (req, res) => {
208
+
209
+ let id_faq_kb = req.body.id_faq_kb;
210
+ let operations = req.body.operations;
211
+
212
+ for (let op of operations) {
213
+ let HTTPREQUEST;
214
+ let id;
215
+
216
+ // method post
217
+ switch (op.type) {
218
+ case 'post':
219
+ HTTPREQUEST = {
220
+ url: apiUrl + '/' + req.projectid + '/faq/',
221
+ headers: {
222
+ 'Content-Type': 'application/json',
223
+ 'Authorization': req.headers.authorization
224
+ },
225
+ json: op.intent,
226
+ method: 'post'
227
+ }
228
+ winston.debug("operation HTTPREQUEST: ", HTTPREQUEST);
229
+ myrequest(
230
+ HTTPREQUEST, async (err, resbody) => {
231
+ if (err) {
232
+ winston.error("err performing operation: ", err);
233
+ } else {
234
+ winston.debug("\n\nresbody operation: ", resbody);
235
+ }
236
+ }
237
+ )
238
+ break;
239
+
240
+ // method put
241
+ case 'put':
242
+ id = op.intent._id;
243
+ if (op.intent.intent_id) {
244
+ id = "intentId" + op.intent.intent_id;
245
+ }
246
+ HTTPREQUEST = {
247
+ url: apiUrl + '/' + req.projectid + '/faq/' + id,
248
+ headers: {
249
+ 'Content-Type': 'application/json',
250
+ 'Authorization': req.headers.authorization
251
+ },
252
+ json: op.intent,
253
+ method: 'put'
254
+ }
255
+ winston.debug("operation HTTPREQUEST: ", HTTPREQUEST);
256
+ myrequest(
257
+ HTTPREQUEST, async (err, resbody) => {
258
+ if (err) {
259
+ winston.error("err performing operation: ", err);
260
+ } else {
261
+ winston.debug("\n\nresbody operation: ", resbody);
262
+ }
263
+ }
264
+ )
265
+ break;
266
+
267
+ // method patch
268
+ case 'patch':
269
+ HTTPREQUEST = {
270
+ url: apiUrl + '/' + req.projectid + '/faq/' + op.intent._id + '/attributes',
271
+ headers: {
272
+ 'Content-Type': 'application/json',
273
+ 'Authorization': req.headers.authorization
274
+ },
275
+ json: op.intent.attributes,
276
+ method: 'patch'
277
+ }
278
+ winston.debug("operation HTTPREQUEST: ", HTTPREQUEST);
279
+ myrequest(
280
+ HTTPREQUEST, async (err, resbody) => {
281
+ if (err) {
282
+ winston.error("err performing operation: ", err);
283
+ } else {
284
+ winston.debug("\n\nresbody operation: ", resbody);
285
+ }
286
+ }
287
+ )
288
+ break;
289
+
290
+ // method delete
291
+ case 'delete':
292
+ id = op.intent._id;
293
+ if (op.intent.intent_id) {
294
+ id = "intentId" + op.intent.intent_id;
295
+ }
296
+ HTTPREQUEST = {
297
+ url: apiUrl + '/' + req.projectid + '/faq/' + id + '?id_faq_kb=' + id_faq_kb,
298
+ headers: {
299
+ 'Content-Type': 'application/json',
300
+ 'Authorization': req.headers.authorization
301
+ },
302
+ method: 'delete'
303
+ }
304
+ winston.debug("operation HTTPREQUEST: ", HTTPREQUEST);
305
+ myrequest(
306
+ HTTPREQUEST, async (err, resbody) => {
307
+ if (err) {
308
+ winston.error("err performing operation: ", err);
309
+ } else {
310
+ winston.debug("\n\nresbody operation: ", resbody);
311
+ }
312
+ }
313
+ )
314
+ break;
315
+ }
316
+ }
317
+
318
+ res.status(200).send({ success: true });
319
+
320
+
321
+ })
322
+
203
323
  router.patch('/:faqid/attributes', function (req, res) {
204
324
  let data = req.body;
205
325
  winston.debug("data: ", data);
@@ -259,7 +379,7 @@ router.put('/:faqid', function (req, res) {
259
379
  let faqid = req.params.faqid;
260
380
 
261
381
  if (!req.body.id_faq_kb) {
262
- return res.status(422).send({ err: "Missing id_faq_kb in Request Body"})
382
+ return res.status(422).send({ err: "Missing id_faq_kb in Request Body" })
263
383
  }
264
384
  let id_faq_kb = req.body.id_faq_kb;
265
385
 
@@ -307,7 +427,7 @@ router.put('/:faqid', function (req, res) {
307
427
 
308
428
  if (faqid.startsWith("intentId")) {
309
429
  let intent_id = faqid.substring(8);
310
- Faq.findOneAndUpdate({ id_faq_kb: id_faq_kb, intent_id: intent_id }, update, { new: true, upsert: true}, (err, updatedFaq) => {
430
+ Faq.findOneAndUpdate({ id_faq_kb: id_faq_kb, intent_id: intent_id }, update, { new: true, upsert: true }, (err, updatedFaq) => {
311
431
  if (err) {
312
432
  if (err.code == 11000) {
313
433
  return res.status(409).send({ success: false, msg: 'Duplicate intent_display_name.' });
@@ -318,12 +438,12 @@ router.put('/:faqid', function (req, res) {
318
438
 
319
439
  faqBotEvent.emit('faq.update', updatedFaq);
320
440
  //faqBotEvent.emit('faq_train.update', updatedFaq.id_faq_kb);
321
-
441
+
322
442
  res.status(200).send(updatedFaq);
323
443
  })
324
444
 
325
445
  } else {
326
-
446
+
327
447
  Faq.findByIdAndUpdate(req.params.faqid, update, { new: true, upsert: true }, function (err, updatedFaq) {
328
448
  if (err) {
329
449
  if (err.code == 11000) {
@@ -332,10 +452,10 @@ router.put('/:faqid', function (req, res) {
332
452
  return res.status(500).send({ success: false, msg: 'Error updating object.' });
333
453
  }
334
454
  }
335
-
455
+
336
456
  faqBotEvent.emit('faq.update', updatedFaq);
337
457
  //faqBotEvent.emit('faq_train.update', updatedFaq.id_faq_kb);
338
-
458
+
339
459
  res.status(200).send(updatedFaq);
340
460
  // updateRemoteFaq(updatedFaq)
341
461
  });
@@ -354,11 +474,11 @@ router.delete('/:faqid', function (req, res) {
354
474
  if (req.query && req.query.id_faq_kb) {
355
475
  id_faq_kb = req.query.id_faq_kb;
356
476
  }
357
-
477
+
358
478
  if (faqid.startsWith("intentId")) {
359
479
  let intent_id = faqid.substring(8);
360
480
  if (!id_faq_kb) {
361
- return res.status(500).send({ success: false, msg: "Unable to delete object. Query param 'id_faq_kb' is mandatory if you want to delete via intent_id"})
481
+ return res.status(500).send({ success: false, msg: "Unable to delete object. Query param 'id_faq_kb' is mandatory if you want to delete via intent_id" })
362
482
  }
363
483
 
364
484
  Faq.findOneAndDelete({ intent_id: intent_id, id_faq_kb: id_faq_kb }, (err, faq) => {
@@ -367,14 +487,14 @@ router.delete('/:faqid', function (req, res) {
367
487
  }
368
488
 
369
489
  if (!faq) {
370
- return res.status(404).send({ success: false, msg: "Error deleting object. The object does not exists."})
490
+ return res.status(404).send({ success: false, msg: "Error deleting object. The object does not exists." })
371
491
  }
372
492
 
373
493
  winston.debug('Deleted FAQ ', faq);
374
-
494
+
375
495
  faqBotEvent.emit('faq.delete', faq);
376
496
  //faqBotEvent.emit('faq_train.delete', faq.id_faq_kb);
377
-
497
+
378
498
  res.status(200).send(faq);
379
499
 
380
500
  })
@@ -385,12 +505,12 @@ router.delete('/:faqid', function (req, res) {
385
505
  return res.status(500).send({ success: false, msg: 'Error deleting object.' });
386
506
  }
387
507
  winston.debug('Deleted FAQ ', faq);
388
-
508
+
389
509
  faqBotEvent.emit('faq.delete', faq);
390
510
  //faqBotEvent.emit('faq_train.delete', faq.id_faq_kb);
391
-
511
+
392
512
  res.status(200).send(faq);
393
-
513
+
394
514
  });
395
515
  }
396
516
  });
@@ -517,7 +637,32 @@ router.get('/', function (req, res, next) {
517
637
 
518
638
  });
519
639
 
640
+ async function myrequest(options, callback) {
641
+
642
+ winston.debug("myrequest options: ", options)
643
+ return await axios({
644
+ url: options.url,
645
+ method: options.method,
646
+ data: options.json,
647
+ params: options.params,
648
+ headers: options.headers
649
+ }).then((res) => {
650
+ if (res && res.status == 200 && res.data) {
651
+ if (callback) {
652
+ callback(null, res.data);
653
+ }
654
+ }
655
+ else {
656
+ if (callback) {
657
+ callback(TiledeskClient.getErr({ message: "Response status not 200" }, options, res), null, null);
658
+ }
659
+ }
660
+ }).catch((err) => {
661
+ if (callback) {
662
+ callback(err, null, null);
663
+ }
664
+ })
665
+ }
520
666
 
521
667
 
522
-
523
- module.exports = router;
668
+ module.exports = router;
@@ -0,0 +1,287 @@
1
+ // const json_multiple_operation = {
2
+ // "id_faq_kb": "6543c2357be357002c682908",
3
+ // "operations": [
4
+ // {
5
+ // "type": "delete",
6
+ // "intent": {
7
+ // "webhook_enabled": false,
8
+ // "enabled": true,
9
+ // "topic": "default",
10
+ // "status": "live",
11
+ // "actions": [
12
+ // {
13
+ // "_tdActionTitle": "",
14
+ // "_tdActionId": "846d1b3c-3f2c-4a53-bf07-0b0b5cc7e3dd",
15
+ // "_tdActionType": "close"
16
+ // }
17
+ // ],
18
+ // "_id": "655b46ebbaddb8002c5a889e",
19
+ // "id_faq_kb": "6543c2357be357002c682908",
20
+ // "id_project": "64a6e63d4152c9002c927891",
21
+ // "language": "en",
22
+ // "intent_display_name": "untitled_block_4",
23
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
24
+ // "intent_id": "7c25c967-3162-451c-a7de-b240d8c8265b",
25
+ // "attributes": {
26
+ // "position": {
27
+ // "x": 2331,
28
+ // "y": -611.5
29
+ // },
30
+ // "nextBlockAction": {
31
+ // "_tdActionId": "9f12ef32-ca5f-4bc9-8a40-76a179e9ebcb",
32
+ // "_tdActionType": "intent",
33
+ // "intentName": ""
34
+ // }
35
+ // },
36
+ // "createdAt": "2023-11-20T11:45:47.448Z",
37
+ // "updatedAt": "2023-11-20T11:45:47.448Z",
38
+ // "faq_kb": [
39
+ // {
40
+ // "webhook_enabled": false,
41
+ // "type": "tilebot",
42
+ // "language": "en",
43
+ // "public": false,
44
+ // "certified": false,
45
+ // "intentsEngine": "none",
46
+ // "tags": [],
47
+ // "score": 0,
48
+ // "trained": true,
49
+ // "certifiedTags": [],
50
+ // "_id": "6543c2357be357002c682908",
51
+ // "name": "02nov16:37",
52
+ // "id_project": "64a6e63d4152c9002c927891",
53
+ // "trashed": false,
54
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
55
+ // "createdAt": "2023-11-02T15:37:25.364Z",
56
+ // "updatedAt": "2023-11-02T15:37:25.400Z",
57
+ // "url": "https://tiledesk-server-pre.herokuapp.com/modules/tilebot/ext/6543c2357be357002c682908"
58
+ // }
59
+ // ],
60
+ // "id": "655b46ebbaddb8002c5a889e"
61
+ // }
62
+ // },
63
+ // {
64
+ // "type": "put",
65
+ // "intent": {
66
+ // "webhook_enabled": false,
67
+ // "enabled": true,
68
+ // "topic": "default",
69
+ // "status": "live",
70
+ // "actions": [
71
+ // {
72
+ // "_tdActionTitle": "",
73
+ // "_tdActionId": "bee43d8a-03d7-4b51-a22a-83c55a13eadf",
74
+ // "_tdActionType": "close"
75
+ // }
76
+ // ],
77
+ // "_id": "65579a7fbcee1b003c6dd6fb",
78
+ // "id_faq_kb": "6543c2357be357002c682908",
79
+ // "id_project": "64a6e63d4152c9002c927891",
80
+ // "language": "en",
81
+ // "intent_display_name": "untitled_block_2",
82
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
83
+ // "intent_id": "ede5cf7f-ce09-49d2-921c-55a9faf099d8",
84
+ // "attributes": {
85
+ // "position": {
86
+ // "x": 1904,
87
+ // "y": -746
88
+ // },
89
+ // "nextBlockAction": {
90
+ // "_tdActionId": "481701dd-661d-45ee-97ec-7034720eb235",
91
+ // "_tdActionType": "intent",
92
+ // "intentName": ""
93
+ // }
94
+ // },
95
+ // "createdAt": "2023-11-17T16:53:19.856Z",
96
+ // "updatedAt": "2023-11-20T14:56:51.089Z",
97
+ // "answer": "",
98
+ // "question": "",
99
+ // "faq_kb": [
100
+ // {
101
+ // "webhook_enabled": false,
102
+ // "type": "tilebot",
103
+ // "language": "en",
104
+ // "public": false,
105
+ // "certified": false,
106
+ // "intentsEngine": "none",
107
+ // "tags": [],
108
+ // "score": 0,
109
+ // "trained": true,
110
+ // "certifiedTags": [],
111
+ // "_id": "6543c2357be357002c682908",
112
+ // "name": "02nov16:37",
113
+ // "id_project": "64a6e63d4152c9002c927891",
114
+ // "trashed": false,
115
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
116
+ // "createdAt": "2023-11-02T15:37:25.364Z",
117
+ // "updatedAt": "2023-11-02T15:37:25.400Z",
118
+ // "url": "https://tiledesk-server-pre.herokuapp.com/modules/tilebot/ext/6543c2357be357002c682908"
119
+ // }
120
+ // ],
121
+ // "id": "65579a7fbcee1b003c6dd6fb"
122
+ // }
123
+ // },
124
+ // {
125
+ // "type": "put",
126
+ // "intent": {
127
+ // "webhook_enabled": false,
128
+ // "enabled": true,
129
+ // "topic": "default",
130
+ // "status": "live",
131
+ // "actions": [
132
+ // {
133
+ // "_tdActionTitle": "",
134
+ // "_tdActionId": "34f6ae25-829b-4d9c-8899-5ba85a53861b",
135
+ // "_tdActionType": "reply",
136
+ // "attributes": {
137
+ // "disableInputMessage": false,
138
+ // "commands": [
139
+ // {
140
+ // "type": "wait",
141
+ // "time": 500
142
+ // },
143
+ // {
144
+ // "type": "message",
145
+ // "message": {
146
+ // "type": "text",
147
+ // "text": "A chat message will be sent to the visitor ...",
148
+ // "attributes": {
149
+ // "attachment": {
150
+ // "type": "template",
151
+ // "buttons": [
152
+ // {
153
+ // "uid": "5d18e074bded4b4b8ff2724cbfd44d04",
154
+ // "type": "action",
155
+ // "value": "Button",
156
+ // "link": "",
157
+ // "target": "blank",
158
+ // "action": "",
159
+ // "attributes": "",
160
+ // "show_echo": true
161
+ // }
162
+ // ]
163
+ // }
164
+ // }
165
+ // }
166
+ // }
167
+ // ]
168
+ // }
169
+ // }
170
+ // ],
171
+ // "_id": "655b44b3baddb8002c5a8708",
172
+ // "id_faq_kb": "6543c2357be357002c682908",
173
+ // "id_project": "64a6e63d4152c9002c927891",
174
+ // "language": "en",
175
+ // "intent_display_name": "untitled_block_3",
176
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
177
+ // "intent_id": "06e171e6-614e-4092-b949-b04e21c674f0",
178
+ // "attributes": {
179
+ // "position": {
180
+ // "x": 1851,
181
+ // "y": -435
182
+ // },
183
+ // "nextBlockAction": {
184
+ // "_tdActionId": "9cfa41bf-ef98-4bce-b37f-18eb52e17b3a",
185
+ // "_tdActionType": "intent",
186
+ // "intentName": ""
187
+ // }
188
+ // },
189
+ // "createdAt": "2023-11-20T11:36:19.054Z",
190
+ // "updatedAt": "2023-11-20T14:42:40.825Z",
191
+ // "answer": "",
192
+ // "question": "",
193
+ // "faq_kb": [
194
+ // {
195
+ // "webhook_enabled": false,
196
+ // "type": "tilebot",
197
+ // "language": "en",
198
+ // "public": false,
199
+ // "certified": false,
200
+ // "intentsEngine": "none",
201
+ // "tags": [],
202
+ // "score": 0,
203
+ // "trained": true,
204
+ // "certifiedTags": [],
205
+ // "_id": "6543c2357be357002c682908",
206
+ // "name": "02nov16:37",
207
+ // "id_project": "64a6e63d4152c9002c927891",
208
+ // "trashed": false,
209
+ // "createdBy": "5ab0f3fa57066e0014bfd71e",
210
+ // "createdAt": "2023-11-02T15:37:25.364Z",
211
+ // "updatedAt": "2023-11-02T15:37:25.400Z",
212
+ // "url": "https://tiledesk-server-pre.herokuapp.com/modules/tilebot/ext/6543c2357be357002c682908"
213
+ // }
214
+ // ],
215
+ // "id": "655b44b3baddb8002c5a8708"
216
+ // }
217
+ // }
218
+ // ]
219
+ // }
220
+
221
+ const json_multiple_operation = {
222
+ "id_faq_kb": "6543c2357be357002c682908",
223
+ "operations": [
224
+ {
225
+ "type": "delete",
226
+ "intent": {
227
+ "webhook_enabled": false,
228
+ "enabled": true,
229
+ "topic": "default",
230
+ "status": "live",
231
+ "actions": [
232
+ {
233
+ "_tdActionTitle": "",
234
+ "_tdActionId": "846d1b3c-3f2c-4a53-bf07-0b0b5cc7e3dd",
235
+ "_tdActionType": "close"
236
+ }
237
+ ],
238
+ "_id": "655b46ebbaddb8002c5a889e",
239
+ "id_faq_kb": "6543c2357be357002c682908",
240
+ "id_project": "64a6e63d4152c9002c927891",
241
+ "language": "en",
242
+ "intent_display_name": "untitled_block_4",
243
+ "createdBy": "5ab0f3fa57066e0014bfd71e",
244
+ "intent_id": "7c25c967-3162-451c-a7de-b240d8c8265b",
245
+ "attributes": {
246
+ "position": {
247
+ "x": 2331,
248
+ "y": -611.5
249
+ },
250
+ "nextBlockAction": {
251
+ "_tdActionId": "9f12ef32-ca5f-4bc9-8a40-76a179e9ebcb",
252
+ "_tdActionType": "intent",
253
+ "intentName": ""
254
+ }
255
+ },
256
+ "createdAt": "2023-11-20T11:45:47.448Z",
257
+ "updatedAt": "2023-11-20T11:45:47.448Z",
258
+ "faq_kb": [
259
+ {
260
+ "webhook_enabled": false,
261
+ "type": "tilebot",
262
+ "language": "en",
263
+ "public": false,
264
+ "certified": false,
265
+ "intentsEngine": "none",
266
+ "tags": [],
267
+ "score": 0,
268
+ "trained": true,
269
+ "certifiedTags": [],
270
+ "_id": "6543c2357be357002c682908",
271
+ "name": "02nov16:37",
272
+ "id_project": "64a6e63d4152c9002c927891",
273
+ "trashed": false,
274
+ "createdBy": "5ab0f3fa57066e0014bfd71e",
275
+ "createdAt": "2023-11-02T15:37:25.364Z",
276
+ "updatedAt": "2023-11-02T15:37:25.400Z",
277
+ "url": "https://tiledesk-server-pre.herokuapp.com/modules/tilebot/ext/6543c2357be357002c682908"
278
+ }
279
+ ],
280
+ "id": "655b46ebbaddb8002c5a889e"
281
+ }
282
+ }
283
+ ]
284
+ }
285
+
286
+
287
+ module.exports = { json_multiple_operation };
package/test/faqRoute.js CHANGED
@@ -5,6 +5,8 @@ var User = require('../models/user');
5
5
  var projectService = require('../services/projectService');
6
6
  var userService = require('../services/userService');
7
7
 
8
+ const example_data = require('./example-json-multiple-operation-mock');
9
+
8
10
  //Require the dev-dependencies
9
11
  let chai = require('chai');
10
12
  let chaiHttp = require('chai-http');
@@ -37,6 +39,9 @@ describe('FaqKBRoute', () => {
37
39
 
38
40
  userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
39
41
  projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
42
+
43
+
44
+ console.log("#### savedProject: ", savedProject)
40
45
  chai.request(server)
41
46
  .post('/' + savedProject._id + '/faq_kb')
42
47
  .auth(email, pwd)
@@ -359,6 +364,32 @@ describe('FaqKBRoute', () => {
359
364
  });
360
365
  })
361
366
 
367
+ it('updateBulkOperations', (done) => {
368
+
369
+ var email = "test-signup-" + Date.now() + "@email.com";
370
+ var pwd = "pwd";
371
+
372
+ userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
373
+ projectService.create("test-updatebulkops", savedUser._id).then((savedProject) => {
374
+
375
+ //console.log("EXAMPLE DATA: ", JSON.stringify(example_data));
376
+
377
+ chai.request(server)
378
+ .post('/' + savedProject._id + '/faq/ops_update')
379
+ .auth(email, pwd)
380
+ .send(example_data.json_multiple_operation) // set up the payload
381
+ .end((err, res) => {
382
+ if (log) { console.log("res.body", res.body); }
383
+ res.should.have.status(200);
384
+ res.body.should.be.a('object');
385
+
386
+ done();
387
+ })
388
+
389
+ })
390
+ })
391
+ })
392
+
362
393
 
363
394
  it('uploadcsv', (done) => {
364
395
 
@@ -713,4 +744,3 @@ describe('FaqKBRoute', () => {
713
744
 
714
745
  });
715
746
 
716
-