@tiledesk/tiledesk-server 2.9.12 → 2.9.14
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/routes/faq_kb.js +501 -243
- package/routes/project.js +174 -67
- package/services/projectUserService.js +32 -0
- package/test/faqkbRoute.js +190 -133
- package/test/projectRoute.js +79 -1
package/test/faqkbRoute.js
CHANGED
@@ -7,7 +7,7 @@ var userService = require('../services/userService');
|
|
7
7
|
var faqService = require('../services/faqService');
|
8
8
|
|
9
9
|
let chatbot_mock = require('./chatbot-mock');
|
10
|
-
let log =
|
10
|
+
let log = true;
|
11
11
|
|
12
12
|
|
13
13
|
//Require the dev-dependencies
|
@@ -244,9 +244,7 @@ describe('FaqKBRoute', () => {
|
|
244
244
|
.auth(email, pwd)
|
245
245
|
.send({ "name": "testbot", type: "internal", template: "blank" })
|
246
246
|
.end((err, res) => {
|
247
|
-
if (log) {
|
248
|
-
}
|
249
|
-
console.log("res.body", res.body);
|
247
|
+
if (log) { console.log("res.body", res.body); }
|
250
248
|
res.should.have.status(200);
|
251
249
|
res.body.should.be.a('object');
|
252
250
|
expect(res.body.name).to.equal("testbot");
|
@@ -256,9 +254,7 @@ describe('FaqKBRoute', () => {
|
|
256
254
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
257
255
|
.auth(email, pwd)
|
258
256
|
.end((err, res) => {
|
259
|
-
if (log) {
|
260
|
-
}
|
261
|
-
console.log("faq_list: ", JSON.stringify(res.body, null, 2));
|
257
|
+
if (log) { console.log("faq_list: ", JSON.stringify(res.body, null, 2)); }
|
262
258
|
res.should.have.status(200);
|
263
259
|
res.body.should.be.an('array').that.is.not.empty;
|
264
260
|
|
@@ -558,18 +554,18 @@ describe('FaqKBRoute', () => {
|
|
558
554
|
})
|
559
555
|
|
560
556
|
|
561
|
-
it('import json
|
557
|
+
it('import json in an existing bot and replace all intents', (done) => {
|
562
558
|
|
563
559
|
var email = "test-signup-" + Date.now() + "@email.com";
|
564
560
|
var pwd = "pwd";
|
565
561
|
|
566
|
-
userService.signup(email, pwd, "Test Firstname", "Test
|
567
|
-
projectService.create(
|
562
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then(((savedUser) => {
|
563
|
+
projectService.create('test-faqkb-create', savedUser._id).then((savedProject) => {
|
568
564
|
|
569
565
|
chai.request(server)
|
570
|
-
.post('/' + savedProject._id + '/faq_kb')
|
566
|
+
.post('/' + savedProject._id + '/faq_kb?replace=true')
|
571
567
|
.auth(email, pwd)
|
572
|
-
.send({ "name": "testbot", type: "
|
568
|
+
.send({ "name": "testbot", type: "tilebot", language: "en", template: "blank " })
|
573
569
|
.end((err, res) => {
|
574
570
|
if (log) {
|
575
571
|
console.log("res.body: ", res.body);
|
@@ -577,44 +573,46 @@ describe('FaqKBRoute', () => {
|
|
577
573
|
res.should.have.status(200);
|
578
574
|
res.body.should.be.a('object');
|
579
575
|
expect(res.body.name).to.equal("testbot");
|
580
|
-
expect(res.body.language).to.equal("
|
576
|
+
expect(res.body.language).to.equal("en");
|
581
577
|
let id_faq_kb = res.body._id;
|
582
578
|
|
583
579
|
chai.request(server)
|
584
|
-
.
|
580
|
+
.get('/' + savedProject._id + '/faq/?id_faq_kb=' + id_faq_kb)
|
585
581
|
.auth(email, pwd)
|
586
|
-
.set('Content-Type', 'text/plain')
|
587
|
-
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example.json')), 'example.json')
|
588
582
|
.end((err, res) => {
|
589
|
-
|
590
|
-
|
591
|
-
}
|
592
|
-
|
593
|
-
res.should.
|
594
|
-
|
595
|
-
expect(res.body.
|
583
|
+
|
584
|
+
if (err) { console.error("err: ", err )};
|
585
|
+
if (log) { console.log("res.body: ", res.doby )};
|
586
|
+
|
587
|
+
res.should.have.status(200)
|
588
|
+
res.body.should.be.a('array');
|
589
|
+
expect(res.body.length).to.equal(0);
|
596
590
|
|
597
591
|
chai.request(server)
|
598
|
-
.
|
592
|
+
.post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb)
|
599
593
|
.auth(email, pwd)
|
594
|
+
.set('Content-Type', 'text/plain')
|
595
|
+
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-rules.txt')), 'example-json-rules')
|
600
596
|
.end((err, res) => {
|
601
597
|
if (log) {
|
602
|
-
console.log("
|
598
|
+
console.log("import json res: ", JSON.stringify(res.body, null, 2));
|
603
599
|
}
|
604
600
|
res.should.have.status(200);
|
605
|
-
res.
|
606
|
-
|
601
|
+
//res.should.be.a('object');
|
602
|
+
//expect(res.body.name).to.equal("examplebot");
|
603
|
+
//expect(res.body.language).to.equal("en");
|
604
|
+
|
607
605
|
done();
|
608
|
-
|
609
606
|
})
|
610
607
|
})
|
608
|
+
|
611
609
|
})
|
612
610
|
})
|
613
|
-
})
|
611
|
+
}))
|
614
612
|
})
|
615
613
|
|
616
|
-
|
617
|
-
it('import
|
614
|
+
// DEPRECATED
|
615
|
+
it('import-json-overwrite-true', (done) => {
|
618
616
|
|
619
617
|
var email = "test-signup-" + Date.now() + "@email.com";
|
620
618
|
var pwd = "pwd";
|
@@ -622,6 +620,7 @@ describe('FaqKBRoute', () => {
|
|
622
620
|
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
623
621
|
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
624
622
|
|
623
|
+
|
625
624
|
chai.request(server)
|
626
625
|
.post('/' + savedProject._id + '/faq_kb')
|
627
626
|
.auth(email, pwd)
|
@@ -637,10 +636,10 @@ describe('FaqKBRoute', () => {
|
|
637
636
|
let id_faq_kb = res.body._id;
|
638
637
|
|
639
638
|
chai.request(server)
|
640
|
-
.post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb)
|
639
|
+
.post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb + "?overwrite=true")
|
641
640
|
.auth(email, pwd)
|
642
641
|
.set('Content-Type', 'text/plain')
|
643
|
-
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example
|
642
|
+
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example.json')), 'example.json')
|
644
643
|
.end((err, res) => {
|
645
644
|
if (log) {
|
646
645
|
console.log("import json res: ", res.body);
|
@@ -669,7 +668,8 @@ describe('FaqKBRoute', () => {
|
|
669
668
|
})
|
670
669
|
})
|
671
670
|
|
672
|
-
|
671
|
+
|
672
|
+
it('import json', (done) => {
|
673
673
|
|
674
674
|
var email = "test-signup-" + Date.now() + "@email.com";
|
675
675
|
var pwd = "pwd";
|
@@ -680,7 +680,7 @@ describe('FaqKBRoute', () => {
|
|
680
680
|
chai.request(server)
|
681
681
|
.post('/' + savedProject._id + '/faq_kb')
|
682
682
|
.auth(email, pwd)
|
683
|
-
.send({ "name": "testbot", type: "internal", language: 'fr' })
|
683
|
+
.send({ "name": "testbot", type: "internal", language: 'fr', template: "blank" })
|
684
684
|
.end((err, res) => {
|
685
685
|
if (log) {
|
686
686
|
console.log("res.body: ", res.body);
|
@@ -692,17 +692,18 @@ describe('FaqKBRoute', () => {
|
|
692
692
|
let id_faq_kb = res.body._id;
|
693
693
|
|
694
694
|
chai.request(server)
|
695
|
-
.post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb
|
695
|
+
.post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb)
|
696
696
|
.auth(email, pwd)
|
697
697
|
.set('Content-Type', 'text/plain')
|
698
|
-
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json
|
698
|
+
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json.txt')), 'example-json.txt')
|
699
699
|
.end((err, res) => {
|
700
700
|
if (log) {
|
701
|
-
console.log("import
|
701
|
+
console.log("import json res: ", res.body);
|
702
702
|
}
|
703
703
|
res.should.have.status(200);
|
704
|
-
|
705
|
-
|
704
|
+
res.should.be.a('object');
|
705
|
+
expect(res.body.name).to.equal("examplebot");
|
706
|
+
expect(res.body.language).to.equal("en");
|
706
707
|
|
707
708
|
chai.request(server)
|
708
709
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
@@ -723,115 +724,172 @@ describe('FaqKBRoute', () => {
|
|
723
724
|
})
|
724
725
|
})
|
725
726
|
|
727
|
+
// DEPRECATED
|
728
|
+
// it('import json (simple)', (done) => {
|
726
729
|
|
727
|
-
|
730
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
731
|
+
// var pwd = "pwd";
|
728
732
|
|
729
|
-
|
730
|
-
|
733
|
+
// userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
734
|
+
// projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
731
735
|
|
732
|
-
|
733
|
-
|
736
|
+
// chai.request(server)
|
737
|
+
// .post('/' + savedProject._id + '/faq_kb')
|
738
|
+
// .auth(email, pwd)
|
739
|
+
// .send({ "name": "testbot", type: "internal", language: 'fr' })
|
740
|
+
// .end((err, res) => {
|
741
|
+
// if (log) {
|
742
|
+
// console.log("res.body: ", res.body);
|
743
|
+
// }
|
744
|
+
// res.should.have.status(200);
|
745
|
+
// res.body.should.be.a('object');
|
746
|
+
// expect(res.body.name).to.equal("testbot");
|
747
|
+
// expect(res.body.language).to.equal("fr");
|
748
|
+
// let id_faq_kb = res.body._id;
|
734
749
|
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
let id_faq_kb = res.body._id;
|
750
|
+
// chai.request(server)
|
751
|
+
// .post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb + '?intentsOnly=true&overwrite=true')
|
752
|
+
// .auth(email, pwd)
|
753
|
+
// .set('Content-Type', 'text/plain')
|
754
|
+
// .attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-intents.txt')), 'example-json-intents.txt')
|
755
|
+
// .end((err, res) => {
|
756
|
+
// if (log) {
|
757
|
+
// console.log("import (intents only) json res: ", res.body);
|
758
|
+
// }
|
759
|
+
// res.should.have.status(200);
|
760
|
+
// //res.should.be.a('object');
|
761
|
+
// //expect(res.body.success).to.equal(true);
|
748
762
|
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
res.should.have.status(200);
|
759
|
-
//res.should.be.a('object');
|
760
|
-
//expect(res.body.success).to.equal(true);
|
763
|
+
// chai.request(server)
|
764
|
+
// .get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
765
|
+
// .auth(email, pwd)
|
766
|
+
// .end((err, res) => {
|
767
|
+
// if (log) {
|
768
|
+
// console.log("faq_list: ", res.body);
|
769
|
+
// }
|
770
|
+
// res.should.have.status(200);
|
771
|
+
// res.body.should.be.an('array').that.is.not.empty;
|
761
772
|
|
762
|
-
|
763
|
-
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
764
|
-
.auth(email, pwd)
|
765
|
-
.end((err, res) => {
|
766
|
-
if (log) {
|
767
|
-
console.log("faq_list: ", res.body);
|
768
|
-
}
|
769
|
-
res.should.have.status(200);
|
770
|
-
res.body.should.be.an('array').that.is.not.empty;
|
773
|
+
// done();
|
771
774
|
|
772
|
-
|
775
|
+
// })
|
776
|
+
// })
|
777
|
+
// })
|
778
|
+
// })
|
779
|
+
// })
|
780
|
+
// })
|
773
781
|
|
774
|
-
})
|
775
|
-
})
|
776
|
-
})
|
777
|
-
})
|
778
|
-
})
|
779
|
-
})
|
780
782
|
|
783
|
+
// DEPRECATED
|
784
|
+
// it('import json (intents only) (overwrite true)', (done) => {
|
781
785
|
|
782
|
-
|
786
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
787
|
+
// var pwd = "pwd";
|
783
788
|
|
784
|
-
|
785
|
-
|
789
|
+
// userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
790
|
+
// projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
786
791
|
|
787
|
-
|
788
|
-
|
792
|
+
// chai.request(server)
|
793
|
+
// .post('/' + savedProject._id + '/faq_kb')
|
794
|
+
// .auth(email, pwd)
|
795
|
+
// .send({ "name": "testbot", type: "internal", language: 'fr', template: 'blank' })
|
796
|
+
// .end((err, res) => {
|
797
|
+
// if (log) {
|
798
|
+
// console.log("res.body: ", res.body);
|
799
|
+
// }
|
800
|
+
// res.should.have.status(200);
|
801
|
+
// res.body.should.be.a('object');
|
802
|
+
// expect(res.body.name).to.equal("testbot");
|
803
|
+
// expect(res.body.language).to.equal("fr");
|
804
|
+
// let id_faq_kb = res.body._id;
|
789
805
|
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
let id_faq_kb = res.body._id;
|
806
|
+
// chai.request(server)
|
807
|
+
// .post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb + '?intentsOnly=true&overwrite=true')
|
808
|
+
// .auth(email, pwd)
|
809
|
+
// .set('Content-Type', 'text/plain')
|
810
|
+
// .attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-intents.txt')), 'example-json-intents.txt')
|
811
|
+
// .end((err, res) => {
|
812
|
+
// if (log) {
|
813
|
+
// console.log("import (intents only) json res: ", res.body);
|
814
|
+
// }
|
815
|
+
// res.should.have.status(200);
|
816
|
+
// //res.should.be.a('object');
|
817
|
+
// //expect(res.body.success).to.equal(true);
|
803
818
|
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
res.should.have.status(200);
|
814
|
-
//res.should.be.a('object');
|
815
|
-
//expect(res.body.success).to.equal(true);
|
819
|
+
// chai.request(server)
|
820
|
+
// .get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
821
|
+
// .auth(email, pwd)
|
822
|
+
// .end((err, res) => {
|
823
|
+
// if (log) {
|
824
|
+
// console.log("faq_list: ", res.body);
|
825
|
+
// }
|
826
|
+
// res.should.have.status(200);
|
827
|
+
// res.body.should.be.an('array').that.is.not.empty;
|
816
828
|
|
817
|
-
|
818
|
-
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
819
|
-
.auth(email, pwd)
|
820
|
-
.end((err, res) => {
|
821
|
-
if (log) {
|
822
|
-
console.log("faq_list: ", res.body);
|
823
|
-
}
|
824
|
-
res.should.have.status(200);
|
825
|
-
res.body.should.be.an('array').that.is.not.empty;
|
829
|
+
// done();
|
826
830
|
|
827
|
-
|
831
|
+
// })
|
832
|
+
// })
|
833
|
+
// })
|
834
|
+
// })
|
835
|
+
// })
|
836
|
+
// })
|
828
837
|
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
838
|
+
|
839
|
+
// DEPRECATED
|
840
|
+
// it('import json (intents only) (overwrite false)', (done) => {
|
841
|
+
|
842
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
843
|
+
// var pwd = "pwd";
|
844
|
+
|
845
|
+
// userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
846
|
+
// projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
847
|
+
|
848
|
+
// chai.request(server)
|
849
|
+
// .post('/' + savedProject._id + '/faq_kb')
|
850
|
+
// .auth(email, pwd)
|
851
|
+
// .send({ "name": "testbot", type: "internal", language: 'fr', template: 'blank' })
|
852
|
+
// .end((err, res) => {
|
853
|
+
// if (log) {
|
854
|
+
// console.log("res.body: ", res.body);
|
855
|
+
// }
|
856
|
+
// res.should.have.status(200);
|
857
|
+
// res.body.should.be.a('object');
|
858
|
+
// expect(res.body.name).to.equal("testbot");
|
859
|
+
// expect(res.body.language).to.equal("fr");
|
860
|
+
// let id_faq_kb = res.body._id;
|
861
|
+
|
862
|
+
// chai.request(server)
|
863
|
+
// .post('/' + savedProject._id + '/faq_kb/importjson/' + id_faq_kb + '?intentsOnly=true')
|
864
|
+
// .auth(email, pwd)
|
865
|
+
// .set('Content-Type', 'text/plain')
|
866
|
+
// .attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-json-intents.txt')), 'example-json-intents.txt')
|
867
|
+
// .end((err, res) => {
|
868
|
+
// if (log) {
|
869
|
+
// console.log("import (intents only) json res: ", res.body);
|
870
|
+
// }
|
871
|
+
// res.should.have.status(200);
|
872
|
+
// //res.should.be.a('object');
|
873
|
+
// //expect(res.body.success).to.equal(true);
|
874
|
+
|
875
|
+
// chai.request(server)
|
876
|
+
// .get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
877
|
+
// .auth(email, pwd)
|
878
|
+
// .end((err, res) => {
|
879
|
+
// if (log) {
|
880
|
+
// console.log("faq_list: ", res.body);
|
881
|
+
// }
|
882
|
+
// res.should.have.status(200);
|
883
|
+
// res.body.should.be.an('array').that.is.not.empty;
|
884
|
+
|
885
|
+
// done();
|
886
|
+
|
887
|
+
// })
|
888
|
+
// })
|
889
|
+
// })
|
890
|
+
// })
|
891
|
+
// })
|
892
|
+
// })
|
835
893
|
|
836
894
|
|
837
895
|
it('exportjson', (done) => {
|
@@ -879,7 +937,6 @@ describe('FaqKBRoute', () => {
|
|
879
937
|
if (log) {
|
880
938
|
console.log("export json res: ", res.body);
|
881
939
|
}
|
882
|
-
console.log("export json res: ", res.body);
|
883
940
|
res.should.have.status(200);
|
884
941
|
//res.body.should.be.a('string');
|
885
942
|
|
package/test/projectRoute.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
3
|
process.env.ADMIN_EMAIL = "admin@tiledesk.com";
|
4
4
|
|
5
|
-
let log =
|
5
|
+
let log = false;
|
6
6
|
var projectService = require('../services/projectService');
|
7
7
|
var userService = require('../services/userService');
|
8
8
|
|
@@ -13,12 +13,16 @@ let server = require('../app');
|
|
13
13
|
let should = chai.should();
|
14
14
|
var fs = require('fs');
|
15
15
|
const path = require('path');
|
16
|
+
const departmentService = require('../services/departmentService');
|
17
|
+
const routingConstants = require('../models/routingConstants');
|
18
|
+
var Group = require('../models/group');
|
16
19
|
|
17
20
|
// chai.config.includeStack = true;
|
18
21
|
|
19
22
|
var expect = chai.expect;
|
20
23
|
var assert = chai.assert;
|
21
24
|
|
25
|
+
|
22
26
|
let timeSlotsSample = {
|
23
27
|
"819559cc": {
|
24
28
|
name: "Slot1",
|
@@ -176,6 +180,80 @@ describe('ProjectRoute', () => {
|
|
176
180
|
})
|
177
181
|
}).timeout(10000)
|
178
182
|
|
183
|
+
it('availableUsers', (done) => {
|
184
|
+
|
185
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
186
|
+
var pwd = "pwd";
|
187
|
+
|
188
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
189
|
+
projectService.create("test-project-create", savedUser._id).then((savedProject) => {
|
190
|
+
|
191
|
+
chai.request(server)
|
192
|
+
.get('/projects/' + savedProject._id + '/users/availables')
|
193
|
+
.auth(email, pwd)
|
194
|
+
.end((err, res) => {
|
195
|
+
|
196
|
+
console.error("err: ", err);
|
197
|
+
console.log("res.body: ", res.body);
|
198
|
+
|
199
|
+
done();
|
200
|
+
})
|
201
|
+
})
|
202
|
+
})
|
203
|
+
}).timeout(10000)
|
204
|
+
|
205
|
+
it('departmentGroupAvailableUsers', (done) => {
|
206
|
+
|
207
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
208
|
+
var pwd = "pwd";
|
209
|
+
|
210
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
211
|
+
projectService.create("test-project-create", savedUser._id).then((savedProject) => {
|
212
|
+
|
213
|
+
chai.request(server)
|
214
|
+
.post('/' + savedProject._id + '/groups')
|
215
|
+
.auth(email, pwd)
|
216
|
+
.send({ name: "test-department-group", members: [savedUser._id] })
|
217
|
+
.end((err, res) => {
|
218
|
+
|
219
|
+
if (err) { console.error("err: ", err) };
|
220
|
+
if (log) { console.log("create group res.body: ", res.body); }
|
221
|
+
let savedGroup = res.body;
|
222
|
+
|
223
|
+
chai.request(server)
|
224
|
+
.post('/' + savedProject._id + '/departments/')
|
225
|
+
.auth(email, pwd)
|
226
|
+
.send({ id_project: "66977908249376002d57a434", name: "test-department", routing: "assigned", id_group: savedGroup._id })
|
227
|
+
.end((err, res) => {
|
228
|
+
|
229
|
+
if (err) { console.error("err: ", err) };
|
230
|
+
if (log) { console.log("savedDepartment: ", res.body); }
|
231
|
+
let savedDepartment = res.body;
|
232
|
+
|
233
|
+
chai.request(server)
|
234
|
+
.get('/projects/' + savedProject._id + '/users/availables/?department=' + savedDepartment._id)
|
235
|
+
.auth(email, pwd)
|
236
|
+
.end((err, res) => {
|
237
|
+
|
238
|
+
if (err) { console.error("err: ", err); }
|
239
|
+
if (log) { console.log("res.body: ", res.body); }
|
240
|
+
|
241
|
+
res.should.have.status(200);
|
242
|
+
res.body.should.be.a('array');
|
243
|
+
expect(res.body.length).to.equal(1);
|
244
|
+
expect(res.body[0].id).to.equal(savedUser._id.toString());
|
245
|
+
expect(res.body[0].fullname).to.equal(savedUser.firstname + " " + savedUser.lastname);
|
246
|
+
expect(res.body[0].assigned_request).to.equal(0);
|
247
|
+
|
248
|
+
done();
|
249
|
+
})
|
250
|
+
|
251
|
+
})
|
252
|
+
})
|
253
|
+
})
|
254
|
+
})
|
255
|
+
}).timeout(10000)
|
256
|
+
|
179
257
|
});
|
180
258
|
|
181
259
|
});
|