@tiledesk/tiledesk-server 2.10.15 → 2.10.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +6 -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/users.js +2 -2
  15. package/services/fileGridFsService.js +12 -10
  16. package/services/requestService.js +2 -1
  17. package/test/app-test.js +36 -1
  18. package/test/authentication.js +662 -796
  19. package/test/authenticationJwt.js +213 -315
  20. package/test/authorization.js +53 -72
  21. package/test/campaignsRoute.js +42 -47
  22. package/test/cannedRoute.js +30 -16
  23. package/test/departmentService.js +222 -274
  24. package/test/example.json +31 -1
  25. package/test/faqRoute.js +713 -622
  26. package/test/faqService.js +124 -159
  27. package/test/faqkbRoute.js +128 -100
  28. package/test/fileRoute.js +50 -46
  29. package/test/imageRoute.js +263 -254
  30. package/test/jwtRoute.js +128 -153
  31. package/test/kbRoute.js +40 -17
  32. package/test/kbsettingsRoute.js +78 -54
  33. package/test/keysRoute.js +6 -7
  34. package/test/labelRoute.js +591 -696
  35. package/test/labelService.js +40 -47
  36. package/test/leadService.js +100 -115
  37. package/test/logsRoute.js +13 -7
  38. package/test/messageRootRoute.js +112 -102
  39. package/test/messageRoute.js +1171 -1419
  40. package/test/messageService.js +41 -43
  41. package/test/openaiRoute.js +5 -1
  42. package/test/projectRoute.js +23 -4
  43. package/test/projectService.js +3 -1
  44. package/test/quoteManager.js +36 -13
  45. package/test/requestRoute.js +103 -72
  46. package/test/requestService.js +51 -51
  47. package/test/userRoute.js +37 -8
  48. package/test/userService.js +34 -31
  49. package/utils/promiseUtil.js +1 -1
@@ -23,12 +23,14 @@ var jwt = require('jsonwebtoken');
23
23
  var expect = chai.expect;
24
24
  var assert = chai.assert;
25
25
 
26
+ let log = false;
27
+
26
28
  chai.use(chaiHttp);
27
29
 
28
30
  describe('MessageRoute', () => {
29
31
 
30
32
 
31
- // mocha test/messageRootRoute.js --grep 'createSimple'
33
+ // mocha test/messageRootRoute.js --grep 'createSimple'
32
34
 
33
35
  it('createSimple', function (done) {
34
36
  // this.timeout(10000);
@@ -36,156 +38,164 @@ describe('MessageRoute', () => {
36
38
  var email = "test-message-create-" + Date.now() + "@email.com";
37
39
  var pwd = "pwd";
38
40
 
39
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
41
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
40
42
 
41
43
  var email2 = "test-message-create-" + Date.now() + "@email.com";
42
- userService.signup( email2 ,pwd, "Test Firstname2", "Test lastname2").then(function(savedUser2) {
44
+ userService.signup(email2, pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
45
+
46
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function (savedProjectAndPU) {
43
47
 
44
- projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
45
-
46
- var savedProject = savedProjectAndPU.project;
48
+ var savedProject = savedProjectAndPU.project;
47
49
 
48
50
  chai.request(server)
49
- .post('/'+ savedProject._id + '/messages')
51
+ .post('/' + savedProject._id + '/messages')
50
52
  .auth(email, pwd)
51
53
  .set('content-type', 'application/json')
52
- .send({"recipient":savedUser2._id.toString(), "recipientFullname": "Dest", "text":"text"})
53
- .end(function(err, res) {
54
- //console.log("res", res);
55
- console.log("res.body", res.body);
56
- res.should.have.status(200);
57
- res.body.should.be.a('object');
58
-
59
- expect(res.body.sender).to.equal(savedUser._id.toString());
60
- expect(res.body.senderFullname).to.equal("Test Firstname Test lastname");
61
- expect(res.body.recipient).to.equal(savedUser2._id.toString());
62
- expect(res.body.type).to.equal("text");
63
- expect(res.body.text).to.equal("text");
64
- expect(res.body.id_project).to.equal(savedProject._id.toString());
65
- expect(res.body.createdBy).to.equal(savedUser._id.toString());
66
- expect(res.body.status).to.equal(0);
67
- expect(res.body.request).to.equal(undefined);
68
- expect(res.body.channel_type).to.equal("direct");
69
- expect(res.body.channel.name).to.equal("chat21");
70
-
71
-
72
- done();
54
+ .send({ "recipient": savedUser2._id.toString(), "recipientFullname": "Dest", "text": "text" })
55
+ .end(function (err, res) {
56
+
57
+ if (err) { console.error("err: ", err); }
58
+ if (log) { console.log("res.body: ", res.body); }
59
+
60
+ res.should.have.status(200);
61
+ res.body.should.be.a('object');
62
+
63
+ expect(res.body.sender).to.equal(savedUser._id.toString());
64
+ expect(res.body.senderFullname).to.equal("Test Firstname Test lastname");
65
+ expect(res.body.recipient).to.equal(savedUser2._id.toString());
66
+ expect(res.body.type).to.equal("text");
67
+ expect(res.body.text).to.equal("text");
68
+ expect(res.body.id_project).to.equal(savedProject._id.toString());
69
+ expect(res.body.createdBy).to.equal(savedUser._id.toString());
70
+ expect(res.body.status).to.equal(0);
71
+ expect(res.body.request).to.equal(undefined);
72
+ expect(res.body.channel_type).to.equal("direct");
73
+ expect(res.body.channel.name).to.equal("chat21");
74
+
75
+
76
+ done();
73
77
  });
74
- });
78
+ });
79
+ });
75
80
  });
76
81
  });
77
- });
78
82
 
79
83
 
80
84
 
81
85
 
82
86
 
83
- // mocha test/messageRootRoute.js --grep 'createValidationNoRecipient'
84
- it('createValidationNoRecipient', function (done) {
85
- // this.timeout(10000);
87
+ // mocha test/messageRootRoute.js --grep 'createValidationNoRecipient'
88
+ it('createValidationNoRecipient', function (done) {
89
+ // this.timeout(10000);
90
+
91
+ var email = "test-message-create-" + Date.now() + "@email.com";
92
+ var pwd = "pwd";
86
93
 
87
- var email = "test-message-create-" + Date.now() + "@email.com";
88
- var pwd = "pwd";
94
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
95
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function (savedProjectAndPU) {
89
96
 
90
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
91
- projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
92
-
93
- var savedProject = savedProjectAndPU.project;
97
+ var savedProject = savedProjectAndPU.project;
94
98
 
95
99
  chai.request(server)
96
- .post('/'+ savedProject._id + '/messages')
100
+ .post('/' + savedProject._id + '/messages')
97
101
  .auth(email, pwd)
98
102
  .set('content-type', 'application/json')
99
- .send({"text":"text"})
100
- .end(function(err, res) {
101
- //console.log("res", res);
102
- console.log("res.body", res.body);
103
- res.should.have.status(422);
104
- res.body.should.be.a('object');
105
-
106
- done();
103
+ .send({ "text": "text" })
104
+ .end(function (err, res) {
105
+
106
+ if (err) { console.error("err: ", err); }
107
+ if (log) { console.log("res.body: ", res.body); }
108
+
109
+ res.should.have.status(422);
110
+ res.body.should.be.a('object');
111
+
112
+ done();
107
113
  });
114
+ });
115
+ });
108
116
  });
109
- });
110
- });
111
117
 
112
118
 
113
119
 
114
120
 
115
- // mocha test/messageRootRoute.js --grep 'createValidationNoText'
116
- it('createValidationNoText', function (done) {
117
- // this.timeout(10000);
121
+ // mocha test/messageRootRoute.js --grep 'createValidationNoText'
122
+ it('createValidationNoText', function (done) {
123
+ // this.timeout(10000);
124
+
125
+ var email = "test-message-create-" + Date.now() + "@email.com";
126
+ var pwd = "pwd";
118
127
 
119
- var email = "test-message-create-" + Date.now() + "@email.com";
120
- var pwd = "pwd";
128
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
129
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function (savedProjectAndPU) {
121
130
 
122
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
123
- projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
124
-
125
- var savedProject = savedProjectAndPU.project;
131
+ var savedProject = savedProjectAndPU.project;
126
132
 
127
133
  chai.request(server)
128
- .post('/'+ savedProject._id + '/messages')
134
+ .post('/' + savedProject._id + '/messages')
129
135
  .auth(email, pwd)
130
136
  .set('content-type', 'application/json')
131
- .send({"recipient":"5ddd30bff0195f0017f72c6d", "recipientFullname": "Dest"})
132
- .end(function(err, res) {
133
- //console.log("res", res);
134
- console.log("res.body", res.body);
135
- res.should.have.status(422);
136
- res.body.should.be.a('object');
137
-
138
- done();
137
+ .send({ "recipient": "5ddd30bff0195f0017f72c6d", "recipientFullname": "Dest" })
138
+ .end(function (err, res) {
139
+
140
+ if (err) { console.error("err: ", err); }
141
+ if (log) { console.log("res.body: ", res.body); }
142
+
143
+ res.should.have.status(422);
144
+ res.body.should.be.a('object');
145
+
146
+ done();
139
147
  });
148
+ });
149
+ });
140
150
  });
141
- });
142
- });
143
151
 
144
152
 
145
153
 
146
154
 
147
- // mocha test/messageRootRoute.js --grep 'createWithSenderFullName'
155
+ // mocha test/messageRootRoute.js --grep 'createWithSenderFullName'
148
156
 
149
- it('createWithSenderFullName', function (done) {
150
- // this.timeout(10000);
157
+ it('createWithSenderFullName', function (done) {
158
+ // this.timeout(10000);
151
159
 
152
- var email = "test-message-create-" + Date.now() + "@email.com";
153
- var pwd = "pwd";
160
+ var email = "test-message-create-" + Date.now() + "@email.com";
161
+ var pwd = "pwd";
162
+
163
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
164
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function (savedProjectAndPU) {
154
165
 
155
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
156
- projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
157
-
158
- var savedProject = savedProjectAndPU.project;
166
+ var savedProject = savedProjectAndPU.project;
159
167
 
160
168
  chai.request(server)
161
- .post('/'+ savedProject._id + '/messages')
169
+ .post('/' + savedProject._id + '/messages')
162
170
  .auth(email, pwd)
163
171
  .set('content-type', 'application/json')
164
- .send({"senderFullname":"Pippo","recipient":"5ddd30bff0195f0017f72c6d", "recipientFullname": "Dest", "text":"text"})
165
- .end(function(err, res) {
166
- //console.log("res", res);
167
- console.log("res.body", res.body);
168
- res.should.have.status(200);
169
- res.body.should.be.a('object');
172
+ .send({ "senderFullname": "Pippo", "recipient": "5ddd30bff0195f0017f72c6d", "recipientFullname": "Dest", "text": "text" })
173
+ .end(function (err, res) {
170
174
 
171
- expect(res.body.sender).to.equal(savedUser._id.toString());
172
- expect(res.body.senderFullname).to.equal("Pippo");
173
- expect(res.body.recipient).to.equal("5ddd30bff0195f0017f72c6d");
174
- expect(res.body.type).to.equal("text");
175
- expect(res.body.text).to.equal("text");
176
- expect(res.body.id_project).to.equal(savedProject._id.toString());
177
- expect(res.body.createdBy).to.equal(savedUser._id.toString());
178
- expect(res.body.status).to.equal(0);
179
- expect(res.body.request).to.equal(undefined);
180
- expect(res.body.channel_type).to.equal("direct");
181
- expect(res.body.channel.name).to.equal("chat21");
182
-
183
-
184
- done();
175
+ if (err) { console.error("err: ", err); }
176
+ if (log) { console.log("res.body: ", res.body); }
177
+
178
+ res.should.have.status(200);
179
+ res.body.should.be.a('object');
180
+
181
+ expect(res.body.sender).to.equal(savedUser._id.toString());
182
+ expect(res.body.senderFullname).to.equal("Pippo");
183
+ expect(res.body.recipient).to.equal("5ddd30bff0195f0017f72c6d");
184
+ expect(res.body.type).to.equal("text");
185
+ expect(res.body.text).to.equal("text");
186
+ expect(res.body.id_project).to.equal(savedProject._id.toString());
187
+ expect(res.body.createdBy).to.equal(savedUser._id.toString());
188
+ expect(res.body.status).to.equal(0);
189
+ expect(res.body.request).to.equal(undefined);
190
+ expect(res.body.channel_type).to.equal("direct");
191
+ expect(res.body.channel.name).to.equal("chat21");
192
+
193
+
194
+ done();
185
195
  });
196
+ });
197
+ });
186
198
  });
187
- });
188
- });
189
199
 
190
200
 
191
201
  });