@tiledesk/tiledesk-server 2.9.13 → 2.9.14
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/routes/faq_kb.js +501 -243
- package/routes/project.js +8 -2
- package/test/faqkbRoute.js +190 -133
- package/test/projectRoute.js +42 -39
package/routes/project.js
CHANGED
@@ -941,7 +941,6 @@ router.get('/:projectid/users/availables', async (req, res) => {
|
|
941
941
|
}
|
942
942
|
|
943
943
|
query.id_user = { $in: group.members.map(id => mongoose.Types.ObjectId(id) )}
|
944
|
-
|
945
944
|
}
|
946
945
|
}
|
947
946
|
|
@@ -967,8 +966,15 @@ router.get('/:projectid/users/availables', async (req, res) => {
|
|
967
966
|
|
968
967
|
available_agents_array = [];
|
969
968
|
available_agents.forEach(agent => {
|
969
|
+
//console.log("agent: ", agent);
|
970
970
|
if (agent.id_user) {
|
971
|
-
available_agents_array.push({
|
971
|
+
available_agents_array.push({
|
972
|
+
"id": agent.id_user._id,
|
973
|
+
"pu_id": agent._id,
|
974
|
+
"fullname": agent.id_user.firstname + " " + agent.id_user.lastname,
|
975
|
+
"email": agent.id_user.email,
|
976
|
+
"assigned_request": agent.number_assigned_requests
|
977
|
+
});
|
972
978
|
} else {
|
973
979
|
winston.warn("(Users Availables) agent.id_user is undefined");
|
974
980
|
}
|
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
@@ -205,48 +205,51 @@ describe('ProjectRoute', () => {
|
|
205
205
|
it('departmentGroupAvailableUsers', (done) => {
|
206
206
|
|
207
207
|
var email = "test-signup-" + Date.now() + "@email.com";
|
208
|
-
var email2 = "test-signup2-" + Date.now() + "@email.com";
|
209
208
|
var pwd = "pwd";
|
210
209
|
|
211
210
|
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
.
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
.
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
.
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
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
|
+
})
|
250
253
|
})
|
251
254
|
})
|
252
255
|
}).timeout(10000)
|