@tiledesk/tiledesk-server 2.10.14 → 2.10.16
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/CHANGELOG.md +9 -0
- package/app.js +2 -1
- package/models/request.js +8 -0
- package/package.json +4 -3
- package/pubmodules/activities/test/activityRoute.js +6 -2
- package/pubmodules/events/test/eventRoute.js +7 -3
- package/pubmodules/pubModulesManager.js +24 -0
- package/pubmodules/voice-twilio/index.js +6 -0
- package/pubmodules/voice-twilio/listener.js +59 -0
- package/routes/campaigns.js +1 -1
- package/routes/files.js +6 -4
- package/routes/images.js +0 -2
- package/routes/kb.js +7 -1
- package/routes/request.js +10 -0
- package/routes/users.js +2 -2
- package/services/fileGridFsService.js +12 -10
- package/services/requestService.js +2 -1
- package/test/app-test.js +36 -1
- package/test/authentication.js +662 -796
- package/test/authenticationJwt.js +213 -315
- package/test/authorization.js +53 -72
- package/test/campaignsRoute.js +42 -47
- package/test/cannedRoute.js +30 -16
- package/test/departmentService.js +222 -274
- package/test/example.json +31 -1
- package/test/faqRoute.js +713 -622
- package/test/faqService.js +124 -159
- package/test/faqkbRoute.js +128 -100
- package/test/fileRoute.js +50 -46
- package/test/imageRoute.js +263 -254
- package/test/jwtRoute.js +128 -153
- package/test/kbRoute.js +40 -17
- package/test/kbsettingsRoute.js +78 -54
- package/test/keysRoute.js +6 -7
- package/test/labelRoute.js +591 -696
- package/test/labelService.js +40 -47
- package/test/leadService.js +100 -115
- package/test/logsRoute.js +13 -7
- package/test/messageRootRoute.js +112 -102
- package/test/messageRoute.js +1171 -1419
- package/test/messageService.js +41 -43
- package/test/openaiRoute.js +5 -1
- package/test/projectRoute.js +23 -4
- package/test/projectService.js +3 -1
- package/test/quoteManager.js +36 -13
- package/test/requestRoute.js +103 -72
- package/test/requestService.js +51 -51
- package/test/userRoute.js +37 -8
- package/test/userService.js +34 -31
- package/utils/promiseUtil.js +1 -1
package/test/faqkbRoute.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
//During the test the env variable is set to test
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
|
+
process.env.LOG_LEVEL = 'critical';
|
3
4
|
|
4
5
|
var Faq = require('../models/faq');
|
5
6
|
var projectService = require('../services/projectService');
|
@@ -174,7 +175,7 @@ describe('FaqKBRoute', () => {
|
|
174
175
|
|
175
176
|
if (err) { console.error("err: ", err); }
|
176
177
|
if (log) { console.log("res.body", res.body); }
|
177
|
-
|
178
|
+
|
178
179
|
res.should.have.status(200);
|
179
180
|
|
180
181
|
done();
|
@@ -318,9 +319,10 @@ describe('FaqKBRoute', () => {
|
|
318
319
|
.auth(email, pwd)
|
319
320
|
.send({ "name": "testbot", type: "internal", template: "example" })
|
320
321
|
.end((err, res) => {
|
321
|
-
|
322
|
-
|
323
|
-
}
|
322
|
+
|
323
|
+
if (err) { console.error("err: ", err); }
|
324
|
+
if (log) { console.log("res.body", res.body); }
|
325
|
+
|
324
326
|
res.should.have.status(200);
|
325
327
|
res.body.should.be.a('object');
|
326
328
|
expect(res.body.name).to.equal("testbot");
|
@@ -330,9 +332,10 @@ describe('FaqKBRoute', () => {
|
|
330
332
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
331
333
|
.auth(email, pwd)
|
332
334
|
.end((err, res) => {
|
333
|
-
|
334
|
-
|
335
|
-
}
|
335
|
+
|
336
|
+
if (err) { console.error("err: ", err); }
|
337
|
+
if (log) { console.log("res.body", res.body); }
|
338
|
+
|
336
339
|
res.should.have.status(200);
|
337
340
|
res.body.should.be.an('array').that.is.not.empty;
|
338
341
|
|
@@ -360,7 +363,10 @@ describe('FaqKBRoute', () => {
|
|
360
363
|
.auth(email, pwd)
|
361
364
|
.send({ "name": "testbot", type: "internal", template: "blank" })
|
362
365
|
.end((err, res) => {
|
366
|
+
|
367
|
+
if (err) { console.error("err: ", err); }
|
363
368
|
if (log) { console.log("res.body", res.body); }
|
369
|
+
|
364
370
|
res.should.have.status(200);
|
365
371
|
res.body.should.be.a('object');
|
366
372
|
expect(res.body.name).to.equal("testbot");
|
@@ -370,7 +376,10 @@ describe('FaqKBRoute', () => {
|
|
370
376
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
371
377
|
.auth(email, pwd)
|
372
378
|
.end((err, res) => {
|
379
|
+
|
380
|
+
if (err) { console.error("err: ", err); }
|
373
381
|
if (log) { console.log("faq_list: ", JSON.stringify(res.body, null, 2)); }
|
382
|
+
|
374
383
|
res.should.have.status(200);
|
375
384
|
res.body.should.be.an('array').that.is.not.empty;
|
376
385
|
|
@@ -399,9 +408,10 @@ describe('FaqKBRoute', () => {
|
|
399
408
|
.auth(email, pwd)
|
400
409
|
.send({ "name": "testbot", type: "internal", template: "example", language: "en" })
|
401
410
|
.end((err, res) => {
|
402
|
-
|
403
|
-
|
404
|
-
}
|
411
|
+
|
412
|
+
if (err) { console.error("err: ", err); }
|
413
|
+
if (log) { console.log("res.body", res.body); }
|
414
|
+
|
405
415
|
res.should.have.status(200);
|
406
416
|
res.body.should.be.a('object');
|
407
417
|
expect(res.body.name).to.equal("testbot");
|
@@ -411,9 +421,10 @@ describe('FaqKBRoute', () => {
|
|
411
421
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
412
422
|
.auth(email, pwd)
|
413
423
|
.end((err, res) => {
|
414
|
-
|
415
|
-
|
416
|
-
}
|
424
|
+
|
425
|
+
if (err) { console.error("err: ", err); }
|
426
|
+
if (log) { console.log("res.body", res.body); }
|
427
|
+
|
417
428
|
res.should.have.status(200);
|
418
429
|
res.body.should.be.an('array').that.is.not.empty;
|
419
430
|
|
@@ -422,9 +433,10 @@ describe('FaqKBRoute', () => {
|
|
422
433
|
.put('/' + savedProject._id + '/faq_kb/' + id_faq_kb + '/language/it')
|
423
434
|
.auth(email, pwd)
|
424
435
|
.end((err, res) => {
|
425
|
-
|
426
|
-
|
427
|
-
}
|
436
|
+
|
437
|
+
if (err) { console.error("err: ", err); }
|
438
|
+
if (log) { console.log("res.body", res.body); }
|
439
|
+
|
428
440
|
res.should.have.status(200);
|
429
441
|
res.body.should.be.a('object');
|
430
442
|
expect(res.body.name).to.equal("testbot");
|
@@ -434,9 +446,10 @@ describe('FaqKBRoute', () => {
|
|
434
446
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
435
447
|
.auth(email, pwd)
|
436
448
|
.end((err, res) => {
|
437
|
-
|
438
|
-
|
439
|
-
}
|
449
|
+
|
450
|
+
if (err) { console.error("err: ", err); }
|
451
|
+
if (log) { console.log("res.body", res.body); }
|
452
|
+
|
440
453
|
res.should.have.status(200);
|
441
454
|
res.body.should.be.an('array').that.is.not.empty;
|
442
455
|
|
@@ -486,9 +499,10 @@ describe('FaqKBRoute', () => {
|
|
486
499
|
.auth(email, pwd)
|
487
500
|
.send({ "name": "privateBot", type: "internal", language: 'en', public: "false", template: "blank" })
|
488
501
|
.end((err, res) => {
|
489
|
-
|
490
|
-
|
491
|
-
}
|
502
|
+
|
503
|
+
if (err) { console.error("err: ", err); }
|
504
|
+
if (log) { console.log("res.body", res.body); }
|
505
|
+
|
492
506
|
res.should.have.status(200);
|
493
507
|
res.body.should.be.a('object');
|
494
508
|
expect(res.body.name).to.equal("privateBot");
|
@@ -500,9 +514,9 @@ describe('FaqKBRoute', () => {
|
|
500
514
|
.auth(email, pwd)
|
501
515
|
.set('Content-Type', 'application/json')
|
502
516
|
.end((err, res) => {
|
503
|
-
|
504
|
-
|
505
|
-
}
|
517
|
+
|
518
|
+
if (err) { console.error("err: ", err); }
|
519
|
+
if (log) { console.log("res.body", res.body); }
|
506
520
|
res.should.have.status(200);
|
507
521
|
res.should.have.be.a('object');
|
508
522
|
expect(res.body.bot_id).to.equal(chatbot_mock.empty_chatbot_mock._id)
|
@@ -529,9 +543,7 @@ describe('FaqKBRoute', () => {
|
|
529
543
|
projectService.create("current-project", user1._id).then(function (currentProject) {
|
530
544
|
projectService.create("landing-project", user2._id).then(function (landingProject) {
|
531
545
|
|
532
|
-
if (log) {
|
533
|
-
console.log("mock: ", chatbot_mock.existing_chatbot_mock);
|
534
|
-
}
|
546
|
+
if (log) { console.log("mock: ", chatbot_mock.existing_chatbot_mock); }
|
535
547
|
|
536
548
|
class chatbot_service {
|
537
549
|
async getBotById(id, published, api_url, chatbot_templates_api_url, token, project_id) {
|
@@ -554,9 +566,10 @@ describe('FaqKBRoute', () => {
|
|
554
566
|
.auth(email_user1, pwd)
|
555
567
|
.send({ "name": "publicBot", type: "internal", language: 'en', public: "true", template: "blank" })
|
556
568
|
.end((err, res) => {
|
557
|
-
|
558
|
-
|
559
|
-
}
|
569
|
+
|
570
|
+
if (err) { console.error("err: ", err); }
|
571
|
+
if (log) { console.log("res.body", res.body); }
|
572
|
+
|
560
573
|
res.should.have.status(200);
|
561
574
|
res.body.should.be.a('object');
|
562
575
|
expect(res.body.name).to.equal("publicBot");
|
@@ -568,9 +581,10 @@ describe('FaqKBRoute', () => {
|
|
568
581
|
.auth(email_user2, pwd)
|
569
582
|
.set('Content-Type', 'application/json')
|
570
583
|
.end((err, res) => {
|
571
|
-
|
572
|
-
|
573
|
-
}
|
584
|
+
|
585
|
+
if (err) { console.error("err: ", err); }
|
586
|
+
if (log) { console.log("res.body", res.body); }
|
587
|
+
|
574
588
|
res.should.have.status(200);
|
575
589
|
|
576
590
|
done();
|
@@ -596,9 +610,10 @@ describe('FaqKBRoute', () => {
|
|
596
610
|
.set('Content-Type', 'text/plain')
|
597
611
|
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-rules.txt')), 'example-json-rules')
|
598
612
|
.end((err, res) => {
|
599
|
-
|
600
|
-
|
601
|
-
}
|
613
|
+
|
614
|
+
if (err) { console.error("err: ", err); }
|
615
|
+
if (log) { console.log("res.body", res.body); }
|
616
|
+
|
602
617
|
res.should.have.status(200);
|
603
618
|
res.should.be.a('object');
|
604
619
|
expect(res.body.name).to.equal("examplebot");
|
@@ -610,9 +625,10 @@ describe('FaqKBRoute', () => {
|
|
610
625
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
611
626
|
.auth(email, pwd)
|
612
627
|
.end((err, res) => {
|
613
|
-
|
614
|
-
|
615
|
-
}
|
628
|
+
|
629
|
+
if (err) { console.error("err: ", err); }
|
630
|
+
if (log) { console.log("res.body", res.body); }
|
631
|
+
|
616
632
|
res.should.have.status(200);
|
617
633
|
//res.body.should.be.an('array').that.is.not.empty;
|
618
634
|
|
@@ -639,9 +655,10 @@ describe('FaqKBRoute', () => {
|
|
639
655
|
.auth(email, pwd)
|
640
656
|
.send({ "name": "testbot", type: "tilebot", language: "en", template: "blank " })
|
641
657
|
.end((err, res) => {
|
642
|
-
|
643
|
-
|
644
|
-
}
|
658
|
+
|
659
|
+
if (err) { console.error("err: ", err); }
|
660
|
+
if (log) { console.log("res.body", res.body); }
|
661
|
+
|
645
662
|
res.should.have.status(200);
|
646
663
|
res.body.should.be.a('object');
|
647
664
|
expect(res.body.name).to.equal("testbot");
|
@@ -654,9 +671,10 @@ describe('FaqKBRoute', () => {
|
|
654
671
|
.set('Content-Type', 'text/plain')
|
655
672
|
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-rules.txt')), 'example-json-rules')
|
656
673
|
.end((err, res) => {
|
657
|
-
|
658
|
-
|
659
|
-
}
|
674
|
+
|
675
|
+
if (err) { console.error("err: ", err); }
|
676
|
+
if (log) { console.log("import json res: ", JSON.stringify(res.body, null, 2)); }
|
677
|
+
|
660
678
|
res.should.have.status(200);
|
661
679
|
//res.should.be.a('object');
|
662
680
|
//expect(res.body.name).to.equal("examplebot");
|
@@ -683,9 +701,10 @@ describe('FaqKBRoute', () => {
|
|
683
701
|
.auth(email, pwd)
|
684
702
|
.send({ "name": "testbot", type: "tilebot", language: "en", template: "blank " })
|
685
703
|
.end((err, res) => {
|
686
|
-
|
687
|
-
|
688
|
-
}
|
704
|
+
|
705
|
+
if (err) { console.error("err: ", err); }
|
706
|
+
if (log) { console.log("res.body", res.body); }
|
707
|
+
|
689
708
|
res.should.have.status(200);
|
690
709
|
res.body.should.be.a('object');
|
691
710
|
expect(res.body.name).to.equal("testbot");
|
@@ -698,7 +717,7 @@ describe('FaqKBRoute', () => {
|
|
698
717
|
.end((err, res) => {
|
699
718
|
|
700
719
|
if (err) { console.error("err: ", err )};
|
701
|
-
if (log) { console.log("res.body: ", res.
|
720
|
+
if (log) { console.log("res.body: ", res.body )};
|
702
721
|
|
703
722
|
res.should.have.status(200)
|
704
723
|
res.body.should.be.a('array');
|
@@ -710,9 +729,10 @@ describe('FaqKBRoute', () => {
|
|
710
729
|
.set('Content-Type', 'text/plain')
|
711
730
|
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-rules.txt')), 'example-json-rules')
|
712
731
|
.end((err, res) => {
|
713
|
-
|
714
|
-
|
715
|
-
}
|
732
|
+
|
733
|
+
if (err) { console.error("err: ", err); }
|
734
|
+
if (log) { console.log("import json res: ", JSON.stringify(res.body, null, 2)); }
|
735
|
+
|
716
736
|
res.should.have.status(200);
|
717
737
|
//res.should.be.a('object');
|
718
738
|
//expect(res.body.name).to.equal("examplebot");
|
@@ -742,9 +762,10 @@ describe('FaqKBRoute', () => {
|
|
742
762
|
.auth(email, pwd)
|
743
763
|
.send({ "name": "testbot", type: "internal", language: 'fr', template: "blank" })
|
744
764
|
.end((err, res) => {
|
745
|
-
|
746
|
-
|
747
|
-
}
|
765
|
+
|
766
|
+
if (err) { console.error("err: ", err )};
|
767
|
+
if (log) { console.log("res.body: ", res.body )};
|
768
|
+
|
748
769
|
res.should.have.status(200);
|
749
770
|
res.body.should.be.a('object');
|
750
771
|
expect(res.body.name).to.equal("testbot");
|
@@ -757,9 +778,10 @@ describe('FaqKBRoute', () => {
|
|
757
778
|
.set('Content-Type', 'text/plain')
|
758
779
|
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example.json')), 'example.json')
|
759
780
|
.end((err, res) => {
|
760
|
-
|
761
|
-
|
762
|
-
}
|
781
|
+
|
782
|
+
if (err) { console.error("err: ", err )};
|
783
|
+
if (log) { console.log("res.body: ", res.body )};
|
784
|
+
|
763
785
|
res.should.have.status(200);
|
764
786
|
res.should.be.a('object');
|
765
787
|
expect(res.body.name).to.equal("examplebot");
|
@@ -769,9 +791,10 @@ describe('FaqKBRoute', () => {
|
|
769
791
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
770
792
|
.auth(email, pwd)
|
771
793
|
.end((err, res) => {
|
772
|
-
|
773
|
-
|
774
|
-
}
|
794
|
+
|
795
|
+
if (err) { console.error("err: ", err )};
|
796
|
+
if (log) { console.log("res.body: ", res.body )};
|
797
|
+
|
775
798
|
res.should.have.status(200);
|
776
799
|
res.body.should.be.an('array').that.is.not.empty;
|
777
800
|
|
@@ -798,9 +821,10 @@ describe('FaqKBRoute', () => {
|
|
798
821
|
.auth(email, pwd)
|
799
822
|
.send({ "name": "testbot", type: "internal", language: 'fr', template: "blank" })
|
800
823
|
.end((err, res) => {
|
801
|
-
|
802
|
-
|
803
|
-
}
|
824
|
+
|
825
|
+
if (err) { console.error("err: ", err )};
|
826
|
+
if (log) { console.log("res.body: ", res.body )};
|
827
|
+
|
804
828
|
res.should.have.status(200);
|
805
829
|
res.body.should.be.a('object');
|
806
830
|
expect(res.body.name).to.equal("testbot");
|
@@ -813,9 +837,10 @@ describe('FaqKBRoute', () => {
|
|
813
837
|
.set('Content-Type', 'text/plain')
|
814
838
|
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json.txt')), 'example-json.txt')
|
815
839
|
.end((err, res) => {
|
816
|
-
|
817
|
-
|
818
|
-
}
|
840
|
+
|
841
|
+
if (err) { console.error("err: ", err )};
|
842
|
+
if (log) { console.log("res.body: ", res.body )};
|
843
|
+
|
819
844
|
res.should.have.status(200);
|
820
845
|
res.should.be.a('object');
|
821
846
|
expect(res.body.name).to.equal("examplebot");
|
@@ -825,9 +850,10 @@ describe('FaqKBRoute', () => {
|
|
825
850
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
826
851
|
.auth(email, pwd)
|
827
852
|
.end((err, res) => {
|
828
|
-
|
829
|
-
|
830
|
-
}
|
853
|
+
|
854
|
+
if (err) { console.error("err: ", err )};
|
855
|
+
if (log) { console.log("res.body: ", res.body )};
|
856
|
+
|
831
857
|
res.should.have.status(200);
|
832
858
|
res.body.should.be.an('array').that.is.not.empty;
|
833
859
|
|
@@ -1024,25 +1050,26 @@ describe('FaqKBRoute', () => {
|
|
1024
1050
|
.auth(email, pwd)
|
1025
1051
|
.send({ "name": "testbot", type: "internal", template: "example", language: 'fr' })
|
1026
1052
|
.end((err, res) => {
|
1027
|
-
|
1028
|
-
|
1029
|
-
}
|
1053
|
+
|
1054
|
+
if (err) { console.error("err: ", err )};
|
1055
|
+
if (log) { console.log("res.body: ", res.body )};
|
1056
|
+
|
1030
1057
|
res.should.have.status(200);
|
1031
1058
|
res.body.should.be.a('object');
|
1032
1059
|
expect(res.body.name).to.equal("testbot");
|
1033
1060
|
expect(res.body.language).to.equal("fr");
|
1034
1061
|
let id_faq_kb = res.body._id;
|
1035
|
-
|
1036
|
-
|
1037
|
-
}
|
1062
|
+
|
1063
|
+
if (log) { console.log("id_faq_kb: ", id_faq_kb); }
|
1038
1064
|
|
1039
1065
|
chai.request(server)
|
1040
1066
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
1041
1067
|
.auth(email, pwd)
|
1042
1068
|
.end((err, res) => {
|
1043
|
-
|
1044
|
-
|
1045
|
-
}
|
1069
|
+
|
1070
|
+
if (err) { console.error("err: ", err )};
|
1071
|
+
if (log) { console.log("res.body: ", res.body )};
|
1072
|
+
|
1046
1073
|
res.should.have.status(200);
|
1047
1074
|
res.body.should.be.an('array').that.is.not.empty;
|
1048
1075
|
|
@@ -1050,9 +1077,10 @@ describe('FaqKBRoute', () => {
|
|
1050
1077
|
.get('/' + savedProject._id + '/faq_kb/exportjson/' + id_faq_kb)
|
1051
1078
|
.auth(email, pwd)
|
1052
1079
|
.end((err, res) => {
|
1053
|
-
|
1054
|
-
|
1055
|
-
}
|
1080
|
+
|
1081
|
+
if (err) { console.error("err: ", err )};
|
1082
|
+
if (log) { console.log("res.body: ", res.body )};
|
1083
|
+
|
1056
1084
|
res.should.have.status(200);
|
1057
1085
|
//res.body.should.be.a('string');
|
1058
1086
|
|
@@ -1093,26 +1121,25 @@ describe('FaqKBRoute', () => {
|
|
1093
1121
|
.auth(email, pwd)
|
1094
1122
|
.send({ "name": "testbot", type: "internal", template: "example", language: 'fr' })
|
1095
1123
|
.end((err, res) => {
|
1096
|
-
|
1097
|
-
if (
|
1098
|
-
|
1099
|
-
|
1124
|
+
|
1125
|
+
if (err) { console.error("err: ", err )};
|
1126
|
+
if (log) { console.log("res.body: ", res.body )};
|
1127
|
+
|
1100
1128
|
res.should.have.status(200);
|
1101
1129
|
res.body.should.be.a('object');
|
1102
1130
|
expect(res.body.name).to.equal("testbot");
|
1103
1131
|
expect(res.body.language).to.equal("fr");
|
1104
1132
|
let id_faq_kb = res.body._id;
|
1105
|
-
if (log) {
|
1106
|
-
console.log("res.body._id: ", res.body._id)
|
1107
|
-
}
|
1133
|
+
if (log) { console.log("id_faq_kb: ", id_faq_kb); }
|
1108
1134
|
|
1109
1135
|
chai.request(server)
|
1110
1136
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
1111
1137
|
.auth(email, pwd)
|
1112
1138
|
.end((err, res) => {
|
1113
|
-
|
1114
|
-
|
1115
|
-
}
|
1139
|
+
|
1140
|
+
if (err) { console.error("err: ", err )};
|
1141
|
+
if (log) { console.log("res.body: ", res.body )};
|
1142
|
+
|
1116
1143
|
res.should.have.status(200);
|
1117
1144
|
res.body.should.be.an('array').that.is.not.empty;
|
1118
1145
|
|
@@ -1120,9 +1147,10 @@ describe('FaqKBRoute', () => {
|
|
1120
1147
|
.get('/' + savedProject._id + '/faq_kb/exportjson/' + id_faq_kb + "?intentsOnly=true")
|
1121
1148
|
.auth(email, pwd)
|
1122
1149
|
.end((err, res) => {
|
1123
|
-
|
1124
|
-
|
1125
|
-
}
|
1150
|
+
|
1151
|
+
if (err) { console.error("err: ", err )};
|
1152
|
+
if (log) { console.log("res.body: ", res.body )};
|
1153
|
+
|
1126
1154
|
res.should.have.status(200);
|
1127
1155
|
//res.body.should.be.a('string');
|
1128
1156
|
|
@@ -1168,10 +1196,10 @@ describe('FaqKBRoute', () => {
|
|
1168
1196
|
.auth(email, pwd)
|
1169
1197
|
.send({ "id_faq_kb": savedBot._id })
|
1170
1198
|
.end((err, res) => {
|
1171
|
-
|
1172
|
-
if (
|
1173
|
-
|
1174
|
-
|
1199
|
+
|
1200
|
+
if (err) { console.error("err: ", err )};
|
1201
|
+
if (log) { console.log("res.body: ", res.body )};
|
1202
|
+
|
1175
1203
|
res.should.have.status(200);
|
1176
1204
|
res.body.should.be.a('object');
|
1177
1205
|
expect(res.body.train.nlu.intent).to.equal(savedBot.intent_display_name);
|
package/test/fileRoute.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
//During the test the env variable is set to test
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
|
-
|
3
|
+
process.env.LOG_LEVEL = 'critical';
|
4
4
|
|
5
5
|
//Require the dev-dependencies
|
6
6
|
let chai = require('chai');
|
@@ -10,6 +10,8 @@ let should = chai.should();
|
|
10
10
|
var fs = require('fs');
|
11
11
|
var userService = require('../services/userService');
|
12
12
|
|
13
|
+
let log = false;
|
14
|
+
|
13
15
|
// chai.config.includeStack = true;
|
14
16
|
|
15
17
|
var expect = chai.expect;
|
@@ -19,64 +21,66 @@ chai.use(chaiHttp);
|
|
19
21
|
|
20
22
|
describe('FileRoute', () => {
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
describe('/post', () => {
|
25
25
|
|
26
|
-
|
26
|
+
it('post-user', (done) => {
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
res.body.should.be.a('object');
|
44
|
-
expect(res.body.message).to.equal('File uploded successfully');
|
45
|
-
expect(res.body.filename).to.not.equal(null);
|
46
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
47
|
-
done();
|
48
|
-
});
|
49
|
-
|
50
|
-
});
|
51
|
-
});
|
28
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
29
|
+
var pwd = "pwd";
|
30
|
+
|
31
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
32
|
+
|
33
|
+
chai.request(server)
|
34
|
+
.post('/files/users/')
|
35
|
+
.auth(email, pwd)
|
36
|
+
.set('Content-Type', 'application/pdf')
|
37
|
+
.attach('file', fs.readFileSync('./test/sample.pdf'), 'sample.pdf')
|
38
|
+
// .field('delimiter', ';')
|
39
|
+
.end((err, res) => {
|
40
|
+
|
41
|
+
if (err) { console.error("err: ", err); }
|
42
|
+
if (log) { console.log("res.body", res.body); }
|
52
43
|
|
44
|
+
res.should.have.status(201);
|
45
|
+
res.body.should.be.a('object');
|
46
|
+
expect(res.body.message).to.equal('File uploded successfully');
|
47
|
+
expect(res.body.filename).to.not.equal(null);
|
48
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
49
|
+
|
50
|
+
done();
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}).timeout(5000)
|
53
54
|
|
54
55
|
|
55
|
-
it('post-public', (done) => {
|
56
56
|
|
57
|
-
|
57
|
+
it('post-public', (done) => {
|
58
|
+
|
59
|
+
|
58
60
|
chai.request(server)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
console.
|
61
|
+
.post('/files/public/')
|
62
|
+
.set('Content-Type', 'application/pdf')
|
63
|
+
.attach('file', fs.readFileSync('./test/sample.pdf'), 'sample.pdf')
|
64
|
+
.field('delimiter', ';')
|
65
|
+
.end((err, res) => {
|
66
|
+
|
67
|
+
if (err) { console.error("err: ", err); }
|
68
|
+
if (log) { console.log("res.body", res.body); }
|
69
|
+
|
66
70
|
res.should.have.status(201);
|
67
71
|
res.body.should.be.a('object');
|
68
|
-
expect(res.body.message).to.equal('File uploded successfully');
|
69
|
-
expect(res.body.filename).to.not.equal(null);
|
70
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
72
|
+
expect(res.body.message).to.equal('File uploded successfully');
|
73
|
+
expect(res.body.filename).to.not.equal(null);
|
74
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
71
75
|
done();
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
});
|
76
|
+
});
|
76
77
|
|
77
78
|
|
79
|
+
});
|
78
80
|
|
79
|
-
|
81
|
+
|
82
|
+
|
83
|
+
});
|
80
84
|
|
81
85
|
});
|
82
86
|
|