@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.
- package/CHANGELOG.md +6 -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
@@ -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 expect = require('chai').expect;
|
5
6
|
|
@@ -21,14 +22,12 @@ require('../services/mongoose-cache-fn')(mongoose);
|
|
21
22
|
var projectService = require('../services/projectService');
|
22
23
|
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
let log = false;
|
26
26
|
|
27
27
|
// var appRules = require('../rules/appRules');
|
28
28
|
// appRules.start();
|
29
29
|
|
30
30
|
|
31
|
-
|
32
31
|
describe('DepartmentService()', function () {
|
33
32
|
|
34
33
|
it('createFirstWithAssignedDepartment', function (done) {
|
@@ -37,299 +36,266 @@ describe('DepartmentService()', function () {
|
|
37
36
|
var email = "test-department-create" + Date.now() + "@email.com";
|
38
37
|
var pwd = "pwd";
|
39
38
|
|
40
|
-
userService.signup(
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
40
|
+
userService.signup(email + '2', pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
|
41
|
+
userService.signup(email + '3', pwd, "Test Firstname3", "Test lastname3").then(function (savedUser3) {
|
42
|
+
projectService.create("createWithAssignedDepartment", savedUser._id).then(function (savedProject) {
|
44
43
|
|
45
44
|
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
var pu2 = new Project_user({
|
62
|
-
// _id: new mongoose.Types.ObjectId(),
|
63
|
-
id_project: savedProject._id,
|
64
|
-
id_user: savedUser3._id,
|
65
|
-
role: roleConstants.AGENT,
|
66
|
-
user_available: true,
|
67
|
-
createdBy: savedUser3._id,
|
68
|
-
updatedBy: savedUser3._id,
|
69
|
-
});
|
46
|
+
var pu1 = new Project_user({
|
47
|
+
// _id: new mongoose.Types.ObjectId(),
|
48
|
+
id_project: savedProject._id,
|
49
|
+
id_user: savedUser2._id,
|
50
|
+
role: roleConstants.AGENT,
|
51
|
+
user_available: true,
|
52
|
+
createdBy: savedUser2._id,
|
53
|
+
updatedBy: savedUser2._id,
|
54
|
+
});
|
55
|
+
pu1.save(function (err, savedProject_user2) {
|
56
|
+
winston.debug("err", err);
|
57
|
+
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
70
58
|
|
71
|
-
pu2.save(function (err, savedProject_user3) {
|
72
|
-
winston.debug("savedProject_user3", savedProject_user3.toObject());
|
73
59
|
|
74
|
-
|
60
|
+
var pu2 = new Project_user({
|
61
|
+
// _id: new mongoose.Types.ObjectId(),
|
62
|
+
id_project: savedProject._id,
|
63
|
+
id_user: savedUser3._id,
|
64
|
+
role: roleConstants.AGENT,
|
65
|
+
user_available: true,
|
66
|
+
createdBy: savedUser3._id,
|
67
|
+
updatedBy: savedUser3._id,
|
68
|
+
});
|
75
69
|
|
76
|
-
|
77
|
-
|
70
|
+
pu2.save(function (err, savedProject_user3) {
|
71
|
+
winston.debug("savedProject_user3", savedProject_user3.toObject());
|
78
72
|
|
79
|
-
|
73
|
+
departmentService.create("PooledDepartment-for-createWithIdWith-createFirstWithAssignedDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
80
74
|
|
81
|
-
|
82
|
-
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function(operatorsResult0) {
|
83
|
-
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
84
|
-
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function(operatorsResult) {
|
85
|
-
winston.info("resolve operatorsResult", operatorsResult);
|
75
|
+
expect(createdDepartment.hasBot).to.equal(false);
|
86
76
|
|
87
|
-
expect(operatorsResult.department._id.toString()).to.equal(createdDepartment._id.toString());
|
88
|
-
expect(operatorsResult.available_agents.length).to.equal(3);
|
89
77
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
78
|
+
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
79
|
+
|
80
|
+
// getOperators(departmentid, projectid, nobot) {
|
81
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult0) {
|
82
|
+
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
83
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult) {
|
84
|
+
winston.info("resolve operatorsResult", operatorsResult);
|
85
|
+
|
86
|
+
expect(operatorsResult.department._id.toString()).to.equal(createdDepartment._id.toString());
|
87
|
+
expect(operatorsResult.available_agents.length).to.equal(3);
|
88
|
+
|
89
|
+
//time invariant?
|
90
|
+
expect(operatorsResult0.available_agents[0]._id.toString()).to.equal(operatorsResult.available_agents[0]._id.toString());
|
91
|
+
expect(operatorsResult0.available_agents[1]._id.toString()).to.equal(operatorsResult.available_agents[1]._id.toString());
|
92
|
+
expect(operatorsResult0.available_agents[2]._id.toString()).to.equal(operatorsResult.available_agents[2]._id.toString());
|
93
|
+
|
94
|
+
expect(operatorsResult.operators.length).to.equal(1);
|
95
|
+
expect(operatorsResult.agents.length).to.equal(3);
|
96
|
+
expect(operatorsResult.group).to.equal(undefined);
|
97
|
+
|
98
|
+
done();
|
99
|
+
});
|
100
|
+
});
|
101
|
+
});
|
102
|
+
});
|
100
103
|
});
|
104
|
+
});
|
101
105
|
});
|
102
106
|
});
|
103
|
-
});
|
104
|
-
});
|
105
|
-
});
|
106
|
-
});
|
107
|
-
|
108
|
-
});
|
109
|
-
|
110
107
|
});
|
111
108
|
});
|
112
109
|
|
113
110
|
|
114
|
-
|
115
111
|
it('createRoundRobinWithAssignedDepartment', function (done) {
|
116
112
|
// this.timeout(10000);
|
117
113
|
|
118
114
|
var email = "test-department-create" + Date.now() + "@email.com";
|
119
115
|
var pwd = "pwd";
|
120
116
|
|
121
|
-
userService.signup(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
118
|
+
userService.signup(email + '2', pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
|
119
|
+
userService.signup(email + '3', pwd, "Test Firstname3", "Test lastname3").then(function (savedUser3) {
|
120
|
+
// projectService.create("createWithAssignedDepartment", savedUser._id).then(function(savedProject) {
|
121
|
+
projectService.createAndReturnProjectAndProjectUser("createWithAssignedDepartment", savedUser._id).then(function (savedProjectAndPU) {
|
122
|
+
var savedProject = savedProjectAndPU.project;
|
123
|
+
|
124
|
+
var pu1 = new Project_user({
|
125
|
+
// _id: new mongoose.Types.ObjectId(),
|
126
|
+
id_project: savedProject._id,
|
127
|
+
id_user: savedUser2._id,
|
128
|
+
role: roleConstants.AGENT,
|
129
|
+
user_available: true,
|
130
|
+
createdBy: savedUser2._id,
|
131
|
+
updatedBy: savedUser2._id,
|
132
|
+
});
|
133
|
+
pu1.save(function (err, savedProject_user2) {
|
134
|
+
winston.debug("err", err);
|
135
|
+
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
129
136
|
|
130
|
-
var pu1 = new Project_user({
|
131
|
-
// _id: new mongoose.Types.ObjectId(),
|
132
|
-
id_project: savedProject._id,
|
133
|
-
id_user: savedUser2._id,
|
134
|
-
role: roleConstants.AGENT,
|
135
|
-
user_available: true,
|
136
|
-
createdBy: savedUser2._id,
|
137
|
-
updatedBy: savedUser2._id,
|
138
|
-
});
|
139
|
-
pu1.save(function (err, savedProject_user2) {
|
140
|
-
winston.debug("err",err);
|
141
|
-
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
142
137
|
|
138
|
+
// var pu2 = new Project_user({
|
139
|
+
// // _id: new mongoose.Types.ObjectId(),
|
140
|
+
// id_project: savedProject._id,
|
141
|
+
// id_user: savedUser3._id,
|
142
|
+
// role: roleConstants.AGENT,
|
143
|
+
// user_available: true,
|
144
|
+
// createdBy: savedUser3._id,
|
145
|
+
// updatedBy: savedUser3._id,
|
146
|
+
// });
|
143
147
|
|
144
|
-
|
145
|
-
|
146
|
-
// id_project: savedProject._id,
|
147
|
-
// id_user: savedUser3._id,
|
148
|
-
// role: roleConstants.AGENT,
|
149
|
-
// user_available: true,
|
150
|
-
// createdBy: savedUser3._id,
|
151
|
-
// updatedBy: savedUser3._id,
|
152
|
-
// });
|
148
|
+
// pu2.save(function (err, savedProject_user3) {
|
149
|
+
// winston.debug("savedProject_user3", savedProject_user3.toObject());
|
153
150
|
|
154
|
-
|
155
|
-
// winston.debug("savedProject_user3", savedProject_user3.toObject());
|
151
|
+
departmentService.create("PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
156
152
|
|
157
|
-
|
153
|
+
leadService.createIfNotExists("request_id1-PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedDepartment", "email@getallWithLoLead.com", savedProject._id).then(function (createdLead) {
|
158
154
|
|
155
|
+
// winston.info("createdLead", createdLead.toObject());
|
156
|
+
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
157
|
+
var now = Date.now();
|
159
158
|
|
159
|
+
requestService.createWithIdAndRequester("request_id1-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest) {
|
160
160
|
|
161
|
-
|
162
|
-
|
163
|
-
// winston.info("createdLead", createdLead.toObject());
|
164
|
-
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
165
|
-
var now = Date.now();
|
161
|
+
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
166
162
|
|
167
|
-
|
168
|
-
|
169
|
-
|
163
|
+
// getOperators(departmentid, projectid, nobot) {
|
164
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult0) {
|
165
|
+
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
170
166
|
|
171
|
-
|
172
|
-
|
173
|
-
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
167
|
+
// requestService.createWithId("request_id2", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest2) {
|
168
|
+
requestService.createWithIdAndRequester("request_id2-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest2) {
|
174
169
|
|
175
|
-
|
176
|
-
|
170
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult) {
|
171
|
+
winston.info("resolve operatorsResult", operatorsResult);
|
177
172
|
|
178
|
-
|
179
|
-
|
173
|
+
expect(operatorsResult.department._id.toString()).to.equal(createdDepartment._id.toString());
|
174
|
+
expect(operatorsResult.available_agents.length).to.equal(2);
|
180
175
|
|
181
|
-
|
182
|
-
|
176
|
+
//time invariant?
|
177
|
+
expect(operatorsResult0.available_agents[0]._id.toString()).to.equal(operatorsResult.available_agents[0]._id.toString());
|
178
|
+
expect(operatorsResult0.available_agents[1]._id.toString()).to.equal(operatorsResult.available_agents[1]._id.toString());
|
179
|
+
// expect(operatorsResult0.available_agents[2]._id.toString()).to.equal(operatorsResult.available_agents[2]._id.toString());
|
183
180
|
|
184
|
-
|
185
|
-
|
186
|
-
expect(operatorsResult0.available_agents[1]._id.toString()).to.equal(operatorsResult.available_agents[1]._id.toString());
|
187
|
-
// expect(operatorsResult0.available_agents[2]._id.toString()).to.equal(operatorsResult.available_agents[2]._id.toString());
|
181
|
+
expect(operatorsResult.agents.length).to.equal(2);
|
182
|
+
expect(operatorsResult.group).to.equal(undefined);
|
188
183
|
|
189
|
-
|
190
|
-
|
184
|
+
expect(operatorsResult0.operators[0].id_user.toString()).to.not.equal(savedRequest.participants[0].toString());
|
185
|
+
expect(operatorsResult.operators[0].id_user.toString()).to.not.equal(savedRequest2.participants[0].toString());
|
186
|
+
// expect(operatorsResult.operators[0].id_user.toString()).to.equal(savedRequest.participants[0].toString());
|
191
187
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
188
|
+
done();
|
189
|
+
});
|
190
|
+
});
|
191
|
+
});
|
192
|
+
});
|
193
|
+
});
|
194
|
+
});
|
198
195
|
});
|
196
|
+
});
|
199
197
|
});
|
200
198
|
});
|
201
|
-
});
|
202
|
-
});
|
203
|
-
});
|
204
|
-
// });
|
205
|
-
});
|
206
|
-
});
|
207
|
-
|
208
|
-
});
|
209
|
-
|
210
199
|
});
|
211
|
-
});
|
212
|
-
|
213
200
|
|
214
201
|
}).timeout(20000);
|
215
202
|
|
216
203
|
|
217
|
-
|
218
|
-
// mocha test/departmentService.js --grep 'createRoundRobinWithAssignedDepartmentNoBeforeRequestOneAgent'
|
219
|
-
|
204
|
+
// mocha test/departmentService.js --grep 'createRoundRobinWithAssignedDepartmentNoBeforeRequestOneAgent'
|
220
205
|
it('createRoundRobinWithAssignedDepartmentNoBeforeRequestOneAgent', function (done) {
|
221
206
|
// this.timeout(10000);
|
222
207
|
|
223
208
|
var email = "test-department-create" + Date.now() + "@email.com";
|
224
209
|
var pwd = "pwd";
|
225
210
|
|
226
|
-
userService.signup(
|
227
|
-
|
228
|
-
|
229
|
-
|
211
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
212
|
+
userService.signup(email + '2', pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
|
213
|
+
userService.signup(email + '3', pwd, "Test Firstname3", "Test lastname3").then(function (savedUser3) {
|
214
|
+
projectService.create("createWithAssignedDepartment", savedUser._id).then(function (savedProject) {
|
230
215
|
|
231
|
-
|
216
|
+
departmentService.create("PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedDepartmentNoBeforeRequestOneAgent", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
232
217
|
|
233
|
-
|
234
|
-
|
235
|
-
|
218
|
+
// getOperators(departmentid, projectid, nobot) {
|
219
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult0) {
|
220
|
+
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
236
221
|
expect(operatorsResult0.operators[0].id_user.toString()).to.equal(savedUser._id.toString());
|
237
222
|
done();
|
223
|
+
});
|
238
224
|
});
|
239
225
|
});
|
240
|
-
|
241
226
|
});
|
242
|
-
|
243
|
-
});
|
244
|
-
|
227
|
+
});
|
245
228
|
});
|
246
|
-
});
|
247
|
-
|
248
|
-
|
249
229
|
}).timeout(20000);
|
250
230
|
|
251
231
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
232
|
it('createRoundRobinWithAssignedALLOFFLINEDepartment', function (done) {
|
258
233
|
// this.timeout(10000);
|
259
234
|
|
260
235
|
var email = "test-department-create" + Date.now() + "@email.com";
|
261
236
|
var pwd = "pwd";
|
262
237
|
|
263
|
-
userService.signup(
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
pu1.save(function (err, savedProject_user2) {
|
280
|
-
winston.debug("err",err);
|
281
|
-
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
238
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
239
|
+
userService.signup(email + '2', pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
|
240
|
+
// projectService.create("createWithAssignedDepartment", savedUser._id).then(function(savedProject) {
|
241
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId-createWithAssignedDepartment", savedUser._id).then(function (savedProjectAndPU) {
|
242
|
+
var savedProject = savedProjectAndPU.project;
|
243
|
+
Project_user.findOneAndUpdate({ id_project: savedProject._id, id_user: savedUser._id, }, { user_available: false }, { new: true, upsert: false }, function (err, updatedProject_user) {
|
244
|
+
winston.debug("updatedProject_user", updatedProject_user);
|
245
|
+
|
246
|
+
var pu1 = new Project_user({
|
247
|
+
id_project: savedProject._id,
|
248
|
+
id_user: savedUser2._id,
|
249
|
+
role: roleConstants.AGENT,
|
250
|
+
user_available: false,
|
251
|
+
createdBy: savedUser2._id,
|
252
|
+
updatedBy: savedUser2._id,
|
253
|
+
});
|
282
254
|
|
255
|
+
pu1.save(function (err, savedProject_user2) {
|
256
|
+
winston.debug("err", err);
|
257
|
+
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
283
258
|
|
284
|
-
departmentService.create("PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedALLOFFLINEDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function(createdDepartment) {
|
285
|
-
// requestService.createWithIdAndRequester("request_id1-createRoundRobinWithAssignedALLOFFLINEDepartment", savedProjectAndPU.project_user._id, null, savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
286
|
-
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
287
259
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
292
|
-
var now = Date.now();
|
293
|
-
requestService.createWithIdAndRequester("request_id1-"+now, savedProjectAndPU.project_user._id,createdLead._id, savedProject._id, "first_text",createdDepartment._id).then(function(savedRequest) {
|
294
|
-
|
260
|
+
departmentService.create("PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedALLOFFLINEDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
261
|
+
// requestService.createWithIdAndRequester("request_id1-createRoundRobinWithAssignedALLOFFLINEDepartment", savedProjectAndPU.project_user._id, null, savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
262
|
+
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
295
263
|
|
296
|
-
|
297
|
-
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function(operatorsResult0) {
|
298
|
-
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
264
|
+
leadService.createIfNotExists("request_id1-PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedALLOFFLINEDepartment", "email@getallWithLoLead.com", savedProject._id).then(function (createdLead) {
|
299
265
|
|
300
|
-
|
301
|
-
|
266
|
+
// winston.info("createdLead", createdLead.toObject());
|
267
|
+
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
268
|
+
var now = Date.now();
|
269
|
+
requestService.createWithIdAndRequester("request_id1-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest) {
|
270
|
+
|
271
|
+
// getOperators(departmentid, projectid, nobot) {
|
272
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult0) {
|
273
|
+
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
302
274
|
|
303
|
-
|
304
|
-
|
275
|
+
// requestService.createWithId("request_id2", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest2) {
|
276
|
+
requestService.createWithIdAndRequester("request_id2-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest2) {
|
305
277
|
|
306
|
-
|
307
|
-
|
278
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult) {
|
279
|
+
winston.info("resolve operatorsResult", operatorsResult);
|
308
280
|
|
309
|
-
|
281
|
+
expect(operatorsResult.department._id.toString()).to.equal(createdDepartment._id.toString());
|
282
|
+
expect(operatorsResult.available_agents.length).to.equal(0);
|
310
283
|
|
311
|
-
|
312
|
-
|
284
|
+
expect(operatorsResult.agents.length).to.equal(2);
|
285
|
+
expect(operatorsResult.group).to.equal(undefined);
|
313
286
|
|
314
|
-
|
315
|
-
|
287
|
+
done();
|
288
|
+
});
|
289
|
+
});
|
290
|
+
});
|
291
|
+
});
|
316
292
|
});
|
293
|
+
});
|
294
|
+
});
|
317
295
|
});
|
318
296
|
});
|
319
297
|
});
|
320
298
|
});
|
321
|
-
});
|
322
|
-
});
|
323
|
-
|
324
|
-
});
|
325
|
-
});
|
326
|
-
|
327
|
-
});
|
328
|
-
|
329
|
-
});
|
330
|
-
// });
|
331
|
-
|
332
|
-
|
333
299
|
}).timeout(20000);
|
334
300
|
|
335
301
|
|
@@ -338,10 +304,10 @@ describe('DepartmentService()', function () {
|
|
338
304
|
|
339
305
|
|
340
306
|
|
341
|
-
// (node:74274) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id_user' of undefined
|
342
|
-
// at /Users/andrealeo/dev/chat21/tiledesk-server/services/requestService.js:55:56
|
343
|
-
// at processTicksAndRejections (internal/process/next_tick.js:81:5)
|
344
|
-
// (node:74274) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
|
307
|
+
// (node:74274) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id_user' of undefined
|
308
|
+
// at /Users/andrealeo/dev/chat21/tiledesk-server/services/requestService.js:55:56
|
309
|
+
// at processTicksAndRejections (internal/process/next_tick.js:81:5)
|
310
|
+
// (node:74274) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
|
345
311
|
|
346
312
|
it('createRoundRobinWithAssignedLastOperatorNotAvailableAndOtherNotAvailableDepartment', function (done) {
|
347
313
|
// this.timeout(10000);
|
@@ -349,81 +315,63 @@ describe('DepartmentService()', function () {
|
|
349
315
|
var email = "test-department-create" + Date.now() + "@email.com";
|
350
316
|
var pwd = "pwd";
|
351
317
|
|
352
|
-
userService.signup(
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
var savedProject = savedProjectAndPU.project;
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
var pu1 = new Project_user({
|
362
|
-
id_project: savedProject._id,
|
363
|
-
id_user: savedUser2._id,
|
364
|
-
role: roleConstants.AGENT,
|
365
|
-
user_available: false,
|
366
|
-
createdBy: savedUser2._id,
|
367
|
-
updatedBy: savedUser2._id,
|
368
|
-
});
|
369
|
-
pu1.save(function (err, savedProject_user2) {
|
370
|
-
winston.debug("err",err);
|
371
|
-
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
372
|
-
|
318
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
319
|
+
userService.signup(email + '2', pwd, "Test Firstname2", "Test lastname2").then(function (savedUser2) {
|
320
|
+
projectService.createAndReturnProjectAndProjectUser("createWithAssignedDepartment", savedUser._id).then(function (savedProjectAndPU) {
|
373
321
|
|
374
|
-
|
375
|
-
var now = Date.now();
|
376
|
-
leadService.createIfNotExists("request_id1-getallWithLoLead", "email@getallWithLoLead.com", savedProject._id).then(function(createdLead) {
|
377
|
-
requestService.createWithIdAndRequester("request_id1-"+now, savedProjectAndPU.project_user._id,createdLead._id, savedProject._id, "first_text",createdDepartment._id).then(function(savedRequest) {
|
322
|
+
var savedProject = savedProjectAndPU.project;
|
378
323
|
|
379
|
-
|
324
|
+
var pu1 = new Project_user({
|
325
|
+
id_project: savedProject._id,
|
326
|
+
id_user: savedUser2._id,
|
327
|
+
role: roleConstants.AGENT,
|
328
|
+
user_available: false,
|
329
|
+
createdBy: savedUser2._id,
|
330
|
+
updatedBy: savedUser2._id,
|
331
|
+
});
|
380
332
|
|
381
|
-
|
382
|
-
|
383
|
-
|
333
|
+
pu1.save(function (err, savedProject_user2) {
|
334
|
+
winston.debug("err", err);
|
335
|
+
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
384
336
|
|
337
|
+
departmentService.create("PooledDepartment-for-createWithIdWith-createRoundRobinWithAssignedLastOperatorNotAvailableAndOtherNotAvailableDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
338
|
+
var now = Date.now();
|
339
|
+
leadService.createIfNotExists("request_id1-getallWithLoLead", "email@getallWithLoLead.com", savedProject._id).then(function (createdLead) {
|
340
|
+
requestService.createWithIdAndRequester("request_id1-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest) {
|
385
341
|
|
386
|
-
|
387
|
-
winston.debug("updatedProject_user",updatedProject_user);
|
342
|
+
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
388
343
|
|
344
|
+
// getOperators(departmentid, projectid, nobot) {
|
345
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult0) {
|
346
|
+
winston.debug("resolve operatorsResult0", operatorsResult0); //time invariant?
|
389
347
|
|
390
|
-
|
391
|
-
|
348
|
+
Project_user.findOneAndUpdate({ id_project: savedProject._id, id_user: savedUser._id, }, { user_available: false }, { new: true, upsert: false }, function (err, updatedProject_user) {
|
349
|
+
winston.debug("updatedProject_user", updatedProject_user);
|
392
350
|
|
393
|
-
|
394
|
-
|
351
|
+
// requestService.createWithId("request_id2", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest2) {
|
352
|
+
requestService.createWithIdAndRequester("request_id2-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text", createdDepartment._id).then(function (savedRequest2) {
|
395
353
|
|
396
|
-
|
397
|
-
|
354
|
+
departmentService.getOperators(createdDepartment._id, savedProject._id, false).then(function (operatorsResult) {
|
355
|
+
winston.info("resolve operatorsResult", operatorsResult);
|
398
356
|
|
399
|
-
|
357
|
+
expect(operatorsResult.department._id.toString()).to.equal(createdDepartment._id.toString());
|
358
|
+
expect(operatorsResult.available_agents.length).to.equal(0);
|
400
359
|
|
401
|
-
|
402
|
-
|
360
|
+
expect(operatorsResult.agents.length).to.equal(2);
|
361
|
+
expect(operatorsResult.group).to.equal(undefined);
|
403
362
|
|
404
|
-
|
405
|
-
|
363
|
+
done();
|
364
|
+
});
|
365
|
+
});
|
366
|
+
});
|
367
|
+
});
|
368
|
+
});
|
369
|
+
});
|
406
370
|
});
|
371
|
+
});
|
407
372
|
});
|
408
373
|
});
|
409
374
|
});
|
410
|
-
});
|
411
|
-
});
|
412
|
-
});
|
413
|
-
|
414
|
-
});
|
415
|
-
});
|
416
|
-
|
417
|
-
});
|
418
|
-
|
419
|
-
});
|
420
|
-
// });
|
421
|
-
|
422
|
-
|
423
375
|
}).timeout(20000);
|
424
376
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
377
|
});
|