@tiledesk/tiledesk-server 2.10.15 → 2.10.17
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -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/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/messageRootRoute.js
CHANGED
@@ -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(
|
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(
|
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
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
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
|
-
|
88
|
-
|
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
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
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
|
-
|
120
|
-
|
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
|
-
|
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
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
-
|
157
|
+
it('createWithSenderFullName', function (done) {
|
158
|
+
// this.timeout(10000);
|
151
159
|
|
152
|
-
|
153
|
-
|
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
|
-
|
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",
|
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
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
});
|