@tiledesk/tiledesk-server 2.10.14 → 2.10.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/app.js +2 -1
  3. package/models/request.js +8 -0
  4. package/package.json +4 -3
  5. package/pubmodules/activities/test/activityRoute.js +6 -2
  6. package/pubmodules/events/test/eventRoute.js +7 -3
  7. package/pubmodules/pubModulesManager.js +24 -0
  8. package/pubmodules/voice-twilio/index.js +6 -0
  9. package/pubmodules/voice-twilio/listener.js +59 -0
  10. package/routes/campaigns.js +1 -1
  11. package/routes/files.js +6 -4
  12. package/routes/images.js +0 -2
  13. package/routes/kb.js +7 -1
  14. package/routes/request.js +10 -0
  15. package/routes/users.js +2 -2
  16. package/services/fileGridFsService.js +12 -10
  17. package/services/requestService.js +2 -1
  18. package/test/app-test.js +36 -1
  19. package/test/authentication.js +662 -796
  20. package/test/authenticationJwt.js +213 -315
  21. package/test/authorization.js +53 -72
  22. package/test/campaignsRoute.js +42 -47
  23. package/test/cannedRoute.js +30 -16
  24. package/test/departmentService.js +222 -274
  25. package/test/example.json +31 -1
  26. package/test/faqRoute.js +713 -622
  27. package/test/faqService.js +124 -159
  28. package/test/faqkbRoute.js +128 -100
  29. package/test/fileRoute.js +50 -46
  30. package/test/imageRoute.js +263 -254
  31. package/test/jwtRoute.js +128 -153
  32. package/test/kbRoute.js +40 -17
  33. package/test/kbsettingsRoute.js +78 -54
  34. package/test/keysRoute.js +6 -7
  35. package/test/labelRoute.js +591 -696
  36. package/test/labelService.js +40 -47
  37. package/test/leadService.js +100 -115
  38. package/test/logsRoute.js +13 -7
  39. package/test/messageRootRoute.js +112 -102
  40. package/test/messageRoute.js +1171 -1419
  41. package/test/messageService.js +41 -43
  42. package/test/openaiRoute.js +5 -1
  43. package/test/projectRoute.js +23 -4
  44. package/test/projectService.js +3 -1
  45. package/test/quoteManager.js +36 -13
  46. package/test/requestRoute.js +103 -72
  47. package/test/requestService.js +51 -51
  48. package/test/userRoute.js +37 -8
  49. package/test/userService.js +34 -31
  50. package/utils/promiseUtil.js +1 -1
@@ -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
- console.log("res.body", res.body);
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
- if (log) {
322
- console.log("res.body", res.body);
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
- if (log) {
334
- console.log("faq_list: ", res.body);
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
- if (log) {
403
- console.log("res.body", res.body);
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
- if (log) {
415
- console.log("faq_list: ", res.body);
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
- if (log) {
426
- console.log("res.body: ", res.body);
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
- if (log) {
438
- console.log("faq_list: ", res.body);
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
- if (log) {
490
- console.log("res.body: ", res.body);
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
- if (log) {
504
- console.log("fork private chatbot res.body: ", res.body)
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
- if (log) {
558
- console.log("res.body: ", res.body);
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
- if (log) {
572
- console.log("fork public chatbot res.body: ", res.body)
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
- if (log) {
600
- console.log("import json res: ", JSON.stringify(res.body, null, 2));
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
- if (log) {
614
- console.log("faq_list: ", res.body);
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
- if (log) {
643
- console.log("res.body: ", res.body);
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
- if (log) {
658
- console.log("import json res: ", JSON.stringify(res.body, null, 2));
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
- if (log) {
687
- console.log("res.body: ", res.body);
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.doby )};
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
- if (log) {
714
- console.log("import json res: ", JSON.stringify(res.body, null, 2));
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
- if (log) {
746
- console.log("res.body: ", res.body);
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
- if (log) {
761
- console.log("import json res: ", res.body);
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
- if (log) {
773
- console.log("faq_list: ", res.body);
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
- if (log) {
802
- console.log("res.body: ", res.body);
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
- if (log) {
817
- console.log("import json res: ", res.body);
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
- if (log) {
829
- console.log("faq_list: ", res.body);
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
- if (log) {
1028
- console.log("res.body: ", res.body);
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
- if (log) {
1036
- console.log("res.body._id: ", res.body._id)
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
- if (log) {
1044
- console.log("faq_list: ", res.body);
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
- if (log) {
1054
- console.log("export json res: ", res.body);
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
- //console.log("res", res);
1097
- if (log) {
1098
- console.log("res.body: ", res.body);
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
- if (log) {
1114
- console.log("faq_list: ", res.body);
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
- if (log) {
1124
- console.log("export json res: ", res.body);
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
- //console.log("res", res);
1172
- if (log) {
1173
- console.log("res.body", res.body);
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
- describe('/post', () => {
23
-
24
-
24
+ describe('/post', () => {
25
25
 
26
- it('post-user', (done) => {
26
+ it('post-user', (done) => {
27
27
 
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
- //console.log("res", res);
41
- console.log("res.body", res.body);
42
- res.should.have.status(201);
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
- .post('/files/public/')
60
- .set('Content-Type','application/pdf')
61
- .attach('file', fs.readFileSync('./test/sample.pdf'), 'sample.pdf')
62
- // .field('delimiter', ';')
63
- .end((err, res) => {
64
- //console.log("res", res);
65
- console.log("res.body", res.body);
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