@tiledesk/tiledesk-server 2.7.15 → 2.7.17
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -3
- package/package.json +3 -3
- package/routes/request.js +22 -0
- package/services/emailService.js +34 -132
- package/services/requestService.js +21 -2
- package/test/requestRoute.js +811 -768
package/test/requestRoute.js
CHANGED
@@ -31,7 +31,7 @@ describe('RequestRoute', () => {
|
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
-
// mocha test/requestRoute.js --grep 'createSimple'
|
34
|
+
// mocha test/requestRoute.js --grep 'createSimple'
|
35
35
|
|
36
36
|
it('createSimple', function (done) {
|
37
37
|
// this.timeout(10000);
|
@@ -39,246 +39,246 @@ describe('RequestRoute', () => {
|
|
39
39
|
var email = "test-request-create-" + Date.now() + "@email.com";
|
40
40
|
var pwd = "pwd";
|
41
41
|
|
42
|
-
userService.signup(
|
43
|
-
|
44
|
-
|
42
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
43
|
+
projectService.create("request-create", savedUser._id, { email: { template: { assignedRequest: "123" } } }).then(function (savedProject) {
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
45
|
+
|
46
|
+
chai.request(server)
|
47
|
+
.post('/' + savedProject._id + '/requests/')
|
48
|
+
.auth(email, pwd)
|
49
|
+
.set('content-type', 'application/json')
|
50
|
+
.send({ "first_text": "first_text" })
|
51
|
+
.end(function (err, res) {
|
52
|
+
//console.log("res", res);
|
53
|
+
//console.log("res.body", res.body);
|
54
|
+
res.should.have.status(200);
|
55
|
+
res.body.should.be.a('object');
|
56
|
+
|
57
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
58
|
+
// res.body.should.have.property('request_id').eql('request_id');
|
59
|
+
// res.body.should.have.property('requester_id').eql('requester_id');
|
60
|
+
res.body.should.have.property('first_text').eql('first_text');
|
61
|
+
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
62
|
+
res.body.should.have.property('createdBy').eql(savedUser._id.toString());
|
63
|
+
|
64
|
+
// res.body.should.have.property('messages_count').gt(0);
|
65
|
+
|
66
|
+
res.body.should.have.property('status').eql(200);
|
67
|
+
|
68
|
+
// res.body.should.have.property('agents').eql(savedUser._id);
|
69
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
70
|
+
expect(res.body.participants.length).to.equal(1);
|
71
|
+
|
72
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
73
|
+
expect(res.body.participantsBots).to.have.lengthOf(0);
|
74
|
+
expect(res.body.hasBot).to.equal(false);
|
75
|
+
|
76
|
+
res.body.should.have.property('department').not.eql(null);
|
77
|
+
// res.body.should.have.property('lead').eql(undefined);
|
78
|
+
|
79
|
+
|
80
|
+
done();
|
81
|
+
});
|
82
|
+
});
|
82
83
|
});
|
83
84
|
});
|
84
|
-
});
|
85
85
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
89
|
|
90
|
-
it('createUpperCaseEmail', function (done) {
|
91
|
-
|
90
|
+
it('createUpperCaseEmail', function (done) {
|
91
|
+
// this.timeout(10000);
|
92
|
+
|
93
|
+
var now = Date.now();
|
94
|
+
var email = "test-REQUEST-create-" + now + "@email.com";
|
95
|
+
var pwd = "pwd";
|
92
96
|
|
93
|
-
|
94
|
-
|
95
|
-
var pwd = "pwd";
|
97
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
98
|
+
projectService.create("request-create", savedUser._id).then(function (savedProject) {
|
96
99
|
|
97
|
-
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
98
|
-
projectService.create("request-create", savedUser._id).then(function(savedProject) {
|
99
|
-
|
100
100
|
|
101
101
|
chai.request(server)
|
102
|
-
.post('/'+ savedProject._id + '/requests/')
|
102
|
+
.post('/' + savedProject._id + '/requests/')
|
103
103
|
.auth("test-request-create-" + now + "@email.com", pwd)
|
104
104
|
.set('content-type', 'application/json')
|
105
|
-
.send({"first_text":"first_text"})
|
106
|
-
.end(function(err, res) {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
expect(res.body.snapshot.agents.length).to.equal(1);
|
113
|
-
// res.body.should.have.property('request_id').eql('request_id');
|
114
|
-
// res.body.should.have.property('requester_id').eql('requester_id');
|
115
|
-
res.body.should.have.property('first_text').eql('first_text');
|
116
|
-
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
117
|
-
res.body.should.have.property('createdBy').eql(savedUser._id.toString());
|
105
|
+
.send({ "first_text": "first_text" })
|
106
|
+
.end(function (err, res) {
|
107
|
+
//console.log("res", res);
|
108
|
+
console.log("res.body", res.body);
|
109
|
+
res.should.have.status(200);
|
110
|
+
res.body.should.be.a('object');
|
118
111
|
|
119
|
-
|
112
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
113
|
+
// res.body.should.have.property('request_id').eql('request_id');
|
114
|
+
// res.body.should.have.property('requester_id').eql('requester_id');
|
115
|
+
res.body.should.have.property('first_text').eql('first_text');
|
116
|
+
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
117
|
+
res.body.should.have.property('createdBy').eql(savedUser._id.toString());
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
// res.body.should.have.property('agents').eql(savedUser._id);
|
124
|
-
expect(res.body.snapshot.agents.length).to.equal(1);
|
125
|
-
expect(res.body.participants.length).to.equal(1);
|
119
|
+
// res.body.should.have.property('messages_count').gt(0);
|
126
120
|
|
127
|
-
|
128
|
-
expect(res.body.participantsBots).to.have.lengthOf(0);
|
129
|
-
expect(res.body.hasBot).to.equal(false);
|
121
|
+
res.body.should.have.property('status').eql(200);
|
130
122
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
// res.body.should.have.property('agents').eql(savedUser._id);
|
124
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
125
|
+
expect(res.body.participants.length).to.equal(1);
|
126
|
+
|
127
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
128
|
+
expect(res.body.participantsBots).to.have.lengthOf(0);
|
129
|
+
expect(res.body.hasBot).to.equal(false);
|
130
|
+
|
131
|
+
res.body.should.have.property('department').not.eql(null);
|
132
|
+
// res.body.should.have.property('lead').eql(undefined);
|
133
|
+
|
134
|
+
|
135
|
+
done();
|
136
136
|
});
|
137
|
+
});
|
138
|
+
});
|
137
139
|
});
|
138
|
-
});
|
139
|
-
});
|
140
140
|
|
141
141
|
|
142
142
|
|
143
143
|
|
144
|
-
// mocha test/requestRoute.js --grep 'getbyid'
|
144
|
+
// mocha test/requestRoute.js --grep 'getbyid'
|
145
145
|
it('getbyid', function (done) {
|
146
146
|
// this.timeout(10000);
|
147
147
|
|
148
148
|
var email = "test-signup-" + Date.now() + "@email.com";
|
149
149
|
var pwd = "pwd";
|
150
150
|
|
151
|
-
userService.signup(
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
152
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
153
|
+
var savedProject = savedProjectAndPU.project;
|
154
|
+
var now = Date.now();
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
requestService.createWithIdAndRequester("request_requestroute-getbyid-"+now, savedProjectAndPU.project_user._id,null, savedProject._id, "first_text").then(function(savedRequest) {
|
156
|
+
// leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function(createdLead) {
|
157
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
158
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
159
|
+
requestService.createWithIdAndRequester("request_requestroute-getbyid-" + now, savedProjectAndPU.project_user._id, null, savedProject._id, "first_text").then(function (savedRequest) {
|
160
160
|
winston.debug("resolve", savedRequest.toObject());
|
161
|
-
|
161
|
+
|
162
162
|
|
163
163
|
chai.request(server)
|
164
|
-
.get('/'+ savedProject._id + '/requests/'+savedRequest.request_id)
|
164
|
+
.get('/' + savedProject._id + '/requests/' + savedRequest.request_id)
|
165
165
|
.auth(email, pwd)
|
166
|
-
.end(function(err, res) {
|
167
|
-
|
166
|
+
.end(function (err, res) {
|
167
|
+
//console.log("res", res);
|
168
168
|
|
169
|
-
|
169
|
+
console.log("res.body", res.body);
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
171
|
+
res.should.have.status(200);
|
172
|
+
res.body.should.be.a('object');
|
173
|
+
|
174
|
+
res.body.should.have.property('department').not.eql(null);
|
175
|
+
// res.body.should.have.property('lead').eql(null);
|
176
|
+
res.body.should.have.property('request_id').eql("request_requestroute-getbyid-" + now);
|
177
|
+
res.body.should.have.property('requester').not.eql(null);
|
178
|
+
|
179
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
180
|
+
expect(res.body.participantsBots).to.have.lengthOf(0);
|
181
|
+
expect(res.body.hasBot).to.equal(false);
|
182
|
+
|
183
|
+
expect(res.body.participatingAgents.length).to.equal(1);
|
184
|
+
expect(res.body.participatingBots.length).to.equal(0);
|
185
|
+
|
186
|
+
expect(res.body.participatingAgents.length).to.equal(1);
|
187
|
+
expect(res.body.participatingBots).to.have.lengthOf(0);
|
188
|
+
|
189
|
+
expect(res.body.requester._id).to.not.equal(savedProjectAndPU.project_user._id);
|
190
|
+
expect(res.body.requester.isAuthenticated).to.equal(true);
|
191
|
+
|
192
|
+
expect(res.body.snapshot.agents).to.equal(undefined);
|
193
|
+
|
194
|
+
done();
|
195
195
|
});
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
});
|
196
|
+
// .catch(function(err) {
|
197
|
+
// console.log("test reject", err);
|
198
|
+
// assert.isNotOk(err,'Promise error');
|
199
|
+
// done();
|
200
|
+
// });
|
201
|
+
// });
|
202
|
+
});
|
203
|
+
});
|
204
204
|
});
|
205
|
-
});
|
206
|
-
// mocha test/requestRoute.js --grep 'getbyidWithPartecipatingBots'
|
205
|
+
});
|
206
|
+
// mocha test/requestRoute.js --grep 'getbyidWithPartecipatingBots'
|
207
207
|
|
208
|
-
it('getbyidWithPartecipatingBots', function (done) {
|
209
|
-
|
208
|
+
it('getbyidWithPartecipatingBots', function (done) {
|
209
|
+
// this.timeout(10000);
|
210
210
|
|
211
|
-
|
212
|
-
|
211
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
212
|
+
var pwd = "pwd";
|
213
213
|
|
214
|
-
|
215
|
-
|
216
|
-
|
214
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
215
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
216
|
+
var savedProject = savedProjectAndPU.project;
|
217
217
|
|
218
218
|
|
219
|
-
|
220
|
-
|
219
|
+
faqService.create("testbot", null, savedProject._id, savedUser._id, "internal").then(function (savedBot) {
|
221
220
|
|
222
221
|
|
223
|
-
Department.findOneAndUpdate({id_project: savedProject._id, default:true}, {id_bot:savedBot._id},{ new: true, upsert: false }, function (err, updatedDepartment) {
|
224
222
|
|
225
|
-
|
226
|
-
winston.info("updatedDepartment", updatedDepartment.toObject());
|
227
|
-
var now = Date.now();
|
223
|
+
Department.findOneAndUpdate({ id_project: savedProject._id, default: true }, { id_bot: savedBot._id }, { new: true, upsert: false }, function (err, updatedDepartment) {
|
228
224
|
|
225
|
+
winston.error("err", err);
|
226
|
+
winston.info("updatedDepartment", updatedDepartment.toObject());
|
227
|
+
var now = Date.now();
|
229
228
|
|
230
|
-
// leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function(createdLead) {
|
231
|
-
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
232
|
-
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
233
|
-
requestService.createWithIdAndRequester("request_requestroute-getbyidWithPartecipatingBots-"+now, savedProjectAndPU.project_user._id,null, savedProject._id, "first_text").then(function(savedRequest) {
|
234
|
-
winston.debug("resolve", savedRequest.toObject());
|
235
|
-
|
236
229
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
230
|
+
// leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function(createdLead) {
|
231
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
232
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
233
|
+
requestService.createWithIdAndRequester("request_requestroute-getbyidWithPartecipatingBots-" + now, savedProjectAndPU.project_user._id, null, savedProject._id, "first_text").then(function (savedRequest) {
|
234
|
+
winston.debug("resolve", savedRequest.toObject());
|
242
235
|
|
243
|
-
console.log("res.body", res.body);
|
244
236
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
237
|
+
chai.request(server)
|
238
|
+
.get('/' + savedProject._id + '/requests/' + savedRequest.request_id)
|
239
|
+
.auth(email, pwd)
|
240
|
+
.end(function (err, res) {
|
241
|
+
//console.log("res", res);
|
242
|
+
|
243
|
+
console.log("res.body", res.body);
|
244
|
+
|
245
|
+
res.should.have.status(200);
|
246
|
+
res.body.should.be.a('object');
|
254
247
|
|
255
|
-
|
256
|
-
expect(res.body.participatingBots.length).to.equal(1);
|
248
|
+
res.body.should.have.property('department').not.eql(null);
|
257
249
|
|
258
|
-
|
259
|
-
|
260
|
-
|
250
|
+
// res.body.should.have.property('lead').eql(null);
|
251
|
+
res.body.should.have.property('request_id').eql("request_requestroute-getbyidWithPartecipatingBots-" + now);
|
252
|
+
res.body.should.have.property('requester').not.eql(null);
|
253
|
+
expect(res.body.requester._id).to.not.equal(savedProjectAndPU.project_user._id);
|
261
254
|
|
262
|
-
|
263
|
-
|
255
|
+
expect(res.body.participatingAgents.length).to.equal(0);
|
256
|
+
expect(res.body.participatingBots.length).to.equal(1);
|
264
257
|
|
265
|
-
|
258
|
+
expect(res.body.participantsAgents.length).to.equal(0);
|
259
|
+
expect(res.body.participantsBots).to.have.lengthOf(1);
|
260
|
+
expect(res.body.hasBot).to.equal(true);
|
261
|
+
|
262
|
+
expect(res.body.snapshot.agents).to.equal(undefined);
|
263
|
+
expect(res.body.department.hasBot).to.equal(true);
|
264
|
+
|
265
|
+
done();
|
266
|
+
});
|
267
|
+
// .catch(function(err) {
|
268
|
+
// console.log("test reject", err);
|
269
|
+
// assert.isNotOk(err,'Promise error');
|
270
|
+
// done();
|
271
|
+
// });
|
272
|
+
// });
|
273
|
+
});
|
266
274
|
});
|
267
|
-
|
268
|
-
// console.log("test reject", err);
|
269
|
-
// assert.isNotOk(err,'Promise error');
|
270
|
-
// done();
|
271
|
-
// });
|
272
|
-
// });
|
273
|
-
});
|
274
|
-
});
|
275
|
+
});
|
275
276
|
});
|
276
277
|
});
|
277
278
|
});
|
278
|
-
});
|
279
279
|
|
280
280
|
|
281
|
-
// mocha test/requestRoute.js --grep 'getallSimple'
|
281
|
+
// mocha test/requestRoute.js --grep 'getallSimple'
|
282
282
|
|
283
283
|
it('getallSimple', function (done) {
|
284
284
|
// this.timeout(10000);
|
@@ -286,57 +286,57 @@ it('getbyidWithPartecipatingBots', function (done) {
|
|
286
286
|
var email = "test-getallsimple-" + Date.now() + "@email.com";
|
287
287
|
var pwd = "pwd";
|
288
288
|
|
289
|
-
userService.signup(
|
289
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
290
290
|
|
291
|
-
|
291
|
+
console.log("savedUser", savedUser);
|
292
292
|
|
293
|
-
|
293
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
294
294
|
|
295
|
-
|
295
|
+
var savedProject = savedProjectAndPU.project;
|
296
296
|
|
297
|
-
|
297
|
+
console.log("savedProjectAndPU", savedProjectAndPU);
|
298
298
|
|
299
|
-
|
299
|
+
leadService.createIfNotExists("leadfullname", "email-getallSimple@email.com", savedProject._id).then(function (createdLead) {
|
300
300
|
|
301
|
-
|
301
|
+
console.log("createdLead", createdLead);
|
302
302
|
|
303
|
-
|
303
|
+
var now = Date.now();
|
304
304
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
requestService.create(new_request).then(function(savedRequest) {
|
305
|
+
var new_request = {
|
306
|
+
request_id: "request_id-getallSimple-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
307
|
+
id_project: savedProject._id, first_text: "first_text",
|
308
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
309
|
+
};
|
314
310
|
|
315
|
-
console.log("savedRequest", savedRequest);
|
316
311
|
|
317
|
-
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
318
|
-
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
319
|
-
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
320
312
|
|
321
|
-
|
322
|
-
|
313
|
+
requestService.create(new_request).then(function (savedRequest) {
|
323
314
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
.
|
315
|
+
console.log("savedRequest", savedRequest);
|
316
|
+
|
317
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
318
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
319
|
+
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
320
|
+
|
321
|
+
winston.debug("resolve", savedRequest.toObject());
|
322
|
+
|
323
|
+
|
324
|
+
chai.request(server)
|
325
|
+
.get('/' + savedProject._id + '/requests/')
|
326
|
+
.auth(email, pwd)
|
327
|
+
.end(function (err, res) {
|
328
328
|
//console.log("res", res);
|
329
|
-
console.log("res.body",
|
329
|
+
console.log("res.body", res.body);
|
330
330
|
res.should.have.status(200);
|
331
331
|
res.body.should.be.a('object');
|
332
332
|
|
333
333
|
expect(res.body.requests[0].department).to.not.equal(null);
|
334
334
|
expect(res.body.requests[0].requester).to.not.equal(null);
|
335
|
-
console.log("res.body.requests[0].requester",
|
335
|
+
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
336
336
|
|
337
337
|
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
338
338
|
|
339
|
-
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
339
|
+
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
340
340
|
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
341
341
|
expect(res.body.requests[0].hasBot).to.equal(false);
|
342
342
|
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
@@ -345,644 +345,569 @@ it('getbyidWithPartecipatingBots', function (done) {
|
|
345
345
|
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
346
346
|
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
347
347
|
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
348
|
-
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
348
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
349
349
|
|
350
350
|
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
351
351
|
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
352
|
-
|
353
|
-
|
352
|
+
done();
|
353
|
+
});
|
354
354
|
// .catch(function(err) {
|
355
355
|
// console.log("test reject", err);
|
356
356
|
// assert.isNotOk(err,'Promise error');
|
357
357
|
// done();
|
358
358
|
// });
|
359
|
+
});
|
360
|
+
});
|
361
|
+
});
|
359
362
|
});
|
360
363
|
});
|
361
|
-
});
|
362
|
-
});
|
363
|
-
});
|
364
364
|
|
365
365
|
|
366
366
|
|
367
367
|
// mocha test/requestRoute.js --grep 'getallNoPopulate'
|
368
368
|
|
369
|
-
it('getallNoPopulate', function (done) {
|
370
|
-
|
371
|
-
|
372
|
-
var email = "test-signup-" + Date.now() + "@email.com";
|
373
|
-
var pwd = "pwd";
|
374
|
-
|
375
|
-
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
376
|
-
projectService.createAndReturnProjectAndProjectUser("createWithId-getallNoPopulate", savedUser._id).then(function(savedProjectAndPU) {
|
377
|
-
var savedProject = savedProjectAndPU.project;
|
369
|
+
it('getallNoPopulate', function (done) {
|
370
|
+
// this.timeout(10000);
|
378
371
|
|
379
|
-
|
380
|
-
|
381
|
-
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
382
|
-
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
383
|
-
var now = Date.now();
|
372
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
373
|
+
var pwd = "pwd";
|
384
374
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
lead:createdLead, requester: savedProjectAndPU.project_user };
|
375
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
376
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId-getallNoPopulate", savedUser._id).then(function (savedProjectAndPU) {
|
377
|
+
var savedProject = savedProjectAndPU.project;
|
389
378
|
|
390
379
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
380
|
+
leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function (createdLead) {
|
381
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
382
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
383
|
+
var now = Date.now();
|
395
384
|
|
396
|
-
|
397
|
-
|
385
|
+
var request = {
|
386
|
+
request_id: "request_getallNoPopulate-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
387
|
+
id_project: savedProject._id, first_text: "first_text",
|
388
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
389
|
+
};
|
398
390
|
|
399
|
-
chai.request(server)
|
400
|
-
.get('/'+ savedProject._id + '/requests/?no_populate=true')
|
401
|
-
.auth(email, pwd)
|
402
|
-
.end(function(err, res) {
|
403
|
-
//console.log("res", res);
|
404
|
-
console.log("res.body", res.body);
|
405
|
-
res.should.have.status(200);
|
406
|
-
res.body.should.be.a('object');
|
407
|
-
// assert.isString(res.body.requests[0].department, 'order placed');
|
408
|
-
|
409
|
-
expect(res.body.requests[0].department).to.be.a('string');
|
410
|
-
expect(res.body.requests[0].requester).to.be.a('string');
|
411
|
-
// console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
412
|
-
// expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
413
|
-
|
414
|
-
console.log("res.body.requests[0].participantsAgents", res.body.requests[0].participantsAgents);
|
415
|
-
expect(res.body.requests[0].participantsAgents).to.have.lengthOf(1);
|
416
|
-
expect(res.body.requests[0].participantsAgents[0]).to.equal(savedUser._id.toString());
|
417
|
-
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
418
|
-
expect(res.body.requests[0].hasBot).to.equal(false);
|
419
|
-
|
420
|
-
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
421
|
-
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
422
|
-
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
423
|
-
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
424
|
-
// expect(res.body.requests[0].test).to.not.equal(undefined);
|
425
|
-
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
426
|
-
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
427
|
-
done();
|
428
|
-
});
|
429
|
-
// .catch(function(err) {
|
430
|
-
// console.log("test reject", err);
|
431
|
-
// assert.isNotOk(err,'Promise error');
|
432
|
-
// done();
|
433
|
-
// });
|
434
|
-
// });
|
435
|
-
});
|
436
|
-
});
|
437
|
-
});
|
438
|
-
});
|
439
|
-
});
|
440
391
|
|
441
392
|
|
393
|
+
requestService.create(request).then(function (savedRequest) {
|
442
394
|
|
395
|
+
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
443
396
|
|
397
|
+
winston.debug("resolve", savedRequest.toObject());
|
444
398
|
|
445
|
-
// mocha test/requestRoute.js --grep 'getallSimple'
|
446
399
|
|
447
|
-
|
448
|
-
|
400
|
+
chai.request(server)
|
401
|
+
.get('/' + savedProject._id + '/requests/?no_populate=true')
|
402
|
+
.auth(email, pwd)
|
403
|
+
.end(function (err, res) {
|
404
|
+
//console.log("res", res);
|
405
|
+
console.log("res.body", res.body);
|
406
|
+
res.should.have.status(200);
|
407
|
+
res.body.should.be.a('object');
|
408
|
+
// assert.isString(res.body.requests[0].department, 'order placed');
|
449
409
|
|
450
|
-
|
451
|
-
|
410
|
+
expect(res.body.requests[0].department).to.be.a('string');
|
411
|
+
expect(res.body.requests[0].requester).to.be.a('string');
|
412
|
+
// console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
413
|
+
// expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
452
414
|
|
453
|
-
|
415
|
+
console.log("res.body.requests[0].participantsAgents", res.body.requests[0].participantsAgents);
|
416
|
+
expect(res.body.requests[0].participantsAgents).to.have.lengthOf(1);
|
417
|
+
expect(res.body.requests[0].participantsAgents[0]).to.equal(savedUser._id.toString());
|
418
|
+
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
419
|
+
expect(res.body.requests[0].hasBot).to.equal(false);
|
454
420
|
|
455
|
-
|
421
|
+
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
422
|
+
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
423
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
424
|
+
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
425
|
+
// expect(res.body.requests[0].test).to.not.equal(undefined);
|
426
|
+
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
427
|
+
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
428
|
+
done();
|
429
|
+
});
|
430
|
+
// .catch(function(err) {
|
431
|
+
// console.log("test reject", err);
|
432
|
+
// assert.isNotOk(err,'Promise error');
|
433
|
+
// done();
|
434
|
+
// });
|
435
|
+
// });
|
436
|
+
});
|
437
|
+
});
|
438
|
+
});
|
439
|
+
});
|
440
|
+
});
|
456
441
|
|
457
|
-
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function(savedProjectAndPU) {
|
458
442
|
|
459
|
-
var savedProject = savedProjectAndPU.project;
|
460
443
|
|
461
|
-
console.log("savedProjectAndPU", savedProjectAndPU);
|
462
444
|
|
463
|
-
leadService.createIfNotExists("leadfullname", "email-getallfilter@email.com", savedProject._id).then(function(createdLead) {
|
464
445
|
|
465
|
-
|
466
|
-
var now = Date.now();
|
446
|
+
// mocha test/requestRoute.js --grep 'getallSimple'
|
467
447
|
|
448
|
+
it('getallFilter-snap_department_routing', function (done) {
|
449
|
+
// this.timeout(10000);
|
468
450
|
|
469
|
-
|
470
|
-
|
471
|
-
id_project:savedProject._id, first_text: "first_text",
|
472
|
-
lead:createdLead, requester: savedProjectAndPU.project_user
|
473
|
-
};
|
451
|
+
var email = "test-getallfilter-" + Date.now() + "@email.com";
|
452
|
+
var pwd = "pwd";
|
474
453
|
|
454
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
475
455
|
|
476
|
-
|
477
|
-
requestService.create(new_request).then(function(savedRequest) {
|
456
|
+
console.log("savedUser", savedUser);
|
478
457
|
|
479
|
-
|
458
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
480
459
|
|
481
|
-
|
482
|
-
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
483
|
-
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
460
|
+
var savedProject = savedProjectAndPU.project;
|
484
461
|
|
485
|
-
|
486
|
-
|
462
|
+
console.log("savedProjectAndPU", savedProjectAndPU);
|
487
463
|
|
488
|
-
|
489
|
-
.get('/'+ savedProject._id + '/requests/?snap_department_routing=assigned')
|
490
|
-
.auth(email, pwd)
|
491
|
-
.end(function(err, res) {
|
492
|
-
//console.log("res", res);
|
493
|
-
console.log("res.body", res.body);
|
494
|
-
res.should.have.status(200);
|
495
|
-
res.body.should.be.a('object');
|
464
|
+
leadService.createIfNotExists("leadfullname", "email-getallfilter@email.com", savedProject._id).then(function (createdLead) {
|
496
465
|
|
497
|
-
|
498
|
-
|
499
|
-
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
500
|
-
|
501
|
-
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
502
|
-
|
503
|
-
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
504
|
-
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
505
|
-
expect(res.body.requests[0].hasBot).to.equal(false);
|
506
|
-
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
507
|
-
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
508
|
-
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
509
|
-
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
510
|
-
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
511
|
-
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
512
|
-
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
513
|
-
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
514
|
-
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
515
|
-
done();
|
516
|
-
});
|
517
|
-
// .catch(function(err) {
|
518
|
-
// console.log("test reject", err);
|
519
|
-
// assert.isNotOk(err,'Promise error');
|
520
|
-
// done();
|
521
|
-
// });
|
522
|
-
});
|
523
|
-
});
|
524
|
-
});
|
525
|
-
});
|
526
|
-
});
|
466
|
+
console.log("createdLead", createdLead);
|
467
|
+
var now = Date.now();
|
527
468
|
|
528
469
|
|
470
|
+
var new_request = {
|
471
|
+
request_id: "request_id-getallFilter-snap_department_routing-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
472
|
+
id_project: savedProject._id, first_text: "first_text",
|
473
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
474
|
+
};
|
529
475
|
|
530
476
|
|
531
|
-
// mocha test/requestRoute.js --grep 'getallFilter-snap_department_default'
|
532
477
|
|
533
|
-
|
534
|
-
// this.timeout(10000);
|
478
|
+
requestService.create(new_request).then(function (savedRequest) {
|
535
479
|
|
536
|
-
|
537
|
-
var pwd = "pwd";
|
480
|
+
console.log("savedRequest", savedRequest);
|
538
481
|
|
539
|
-
|
482
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
483
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
484
|
+
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
540
485
|
|
541
|
-
|
486
|
+
winston.debug("resolve", savedRequest.toObject());
|
542
487
|
|
543
|
-
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function(savedProjectAndPU) {
|
544
488
|
|
545
|
-
|
489
|
+
chai.request(server)
|
490
|
+
.get('/' + savedProject._id + '/requests/?snap_department_routing=assigned')
|
491
|
+
.auth(email, pwd)
|
492
|
+
.end(function (err, res) {
|
493
|
+
//console.log("res", res);
|
494
|
+
console.log("res.body", res.body);
|
495
|
+
res.should.have.status(200);
|
496
|
+
res.body.should.be.a('object');
|
546
497
|
|
547
|
-
|
498
|
+
expect(res.body.requests[0].department).to.not.equal(null);
|
499
|
+
expect(res.body.requests[0].requester).to.not.equal(null);
|
500
|
+
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
548
501
|
|
549
|
-
|
502
|
+
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
550
503
|
|
551
|
-
|
504
|
+
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
505
|
+
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
506
|
+
expect(res.body.requests[0].hasBot).to.equal(false);
|
507
|
+
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
508
|
+
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
509
|
+
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
510
|
+
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
511
|
+
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
512
|
+
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
513
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
514
|
+
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
515
|
+
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
516
|
+
done();
|
517
|
+
});
|
518
|
+
// .catch(function(err) {
|
519
|
+
// console.log("test reject", err);
|
520
|
+
// assert.isNotOk(err,'Promise error');
|
521
|
+
// done();
|
522
|
+
// });
|
523
|
+
});
|
524
|
+
});
|
525
|
+
});
|
526
|
+
});
|
527
|
+
});
|
552
528
|
|
553
|
-
var now = Date.now();
|
554
529
|
|
555
|
-
var new_request = {
|
556
|
-
request_id: "request_id-getallFilter-snap_department_routing-"+now, project_user_id:savedProjectAndPU.project_user._id, lead_id:createdLead._id,
|
557
|
-
id_project:savedProject._id, first_text: "first_text",
|
558
|
-
lead:createdLead, requester: savedProjectAndPU.project_user
|
559
|
-
};
|
560
530
|
|
561
531
|
|
562
|
-
|
563
|
-
requestService.create(new_request).then(function(savedRequest) {
|
532
|
+
// mocha test/requestRoute.js --grep 'getallFilter-snap_department_default'
|
564
533
|
|
565
|
-
|
534
|
+
it('getallFilter-snap_department_default', function (done) {
|
535
|
+
// this.timeout(10000);
|
566
536
|
|
567
|
-
|
568
|
-
|
569
|
-
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
537
|
+
var email = "test-getallfilter-" + Date.now() + "@email.com";
|
538
|
+
var pwd = "pwd";
|
570
539
|
|
571
|
-
|
572
|
-
|
540
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
573
541
|
|
574
|
-
|
575
|
-
.get('/'+ savedProject._id + '/requests/?snap_department_default=true')
|
576
|
-
.auth(email, pwd)
|
577
|
-
.end(function(err, res) {
|
578
|
-
//console.log("res", res);
|
579
|
-
console.log("res.body", res.body);
|
580
|
-
res.should.have.status(200);
|
581
|
-
res.body.should.be.a('object');
|
542
|
+
console.log("savedUser", savedUser);
|
582
543
|
|
583
|
-
|
584
|
-
expect(res.body.requests[0].requester).to.not.equal(null);
|
585
|
-
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
586
|
-
|
587
|
-
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
588
|
-
|
589
|
-
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
590
|
-
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
591
|
-
expect(res.body.requests[0].hasBot).to.equal(false);
|
592
|
-
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
593
|
-
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
594
|
-
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
595
|
-
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
596
|
-
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
597
|
-
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
598
|
-
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
599
|
-
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
600
|
-
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
601
|
-
done();
|
602
|
-
});
|
603
|
-
// .catch(function(err) {
|
604
|
-
// console.log("test reject", err);
|
605
|
-
// assert.isNotOk(err,'Promise error');
|
606
|
-
// done();
|
607
|
-
// });
|
608
|
-
});
|
609
|
-
});
|
610
|
-
});
|
611
|
-
});
|
612
|
-
});
|
544
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
613
545
|
|
546
|
+
var savedProject = savedProjectAndPU.project;
|
614
547
|
|
548
|
+
console.log("savedProjectAndPU", savedProjectAndPU);
|
615
549
|
|
550
|
+
leadService.createIfNotExists("leadfullname", "email-getallfilter@email.com", savedProject._id).then(function (createdLead) {
|
616
551
|
|
617
|
-
|
552
|
+
console.log("createdLead", createdLead);
|
618
553
|
|
619
|
-
|
620
|
-
// this.timeout(10000);
|
554
|
+
var now = Date.now();
|
621
555
|
|
622
|
-
|
623
|
-
|
556
|
+
var new_request = {
|
557
|
+
request_id: "request_id-getallFilter-snap_department_routing-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
558
|
+
id_project: savedProject._id, first_text: "first_text",
|
559
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
560
|
+
};
|
624
561
|
|
625
|
-
userService.signup( email, pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
626
562
|
|
627
|
-
console.log("savedUser", savedUser);
|
628
563
|
|
629
|
-
|
564
|
+
requestService.create(new_request).then(function (savedRequest) {
|
630
565
|
|
631
|
-
|
566
|
+
console.log("savedRequest", savedRequest);
|
632
567
|
|
633
|
-
|
568
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
569
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
570
|
+
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
634
571
|
|
635
|
-
|
572
|
+
winston.debug("resolve", savedRequest.toObject());
|
636
573
|
|
637
|
-
console.log("createdLead", createdLead);
|
638
574
|
|
639
|
-
|
575
|
+
chai.request(server)
|
576
|
+
.get('/' + savedProject._id + '/requests/?snap_department_default=true')
|
577
|
+
.auth(email, pwd)
|
578
|
+
.end(function (err, res) {
|
579
|
+
//console.log("res", res);
|
580
|
+
console.log("res.body", res.body);
|
581
|
+
res.should.have.status(200);
|
582
|
+
res.body.should.be.a('object');
|
640
583
|
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
lead:createdLead, requester: savedProjectAndPU.project_user
|
645
|
-
};
|
584
|
+
expect(res.body.requests[0].department).to.not.equal(null);
|
585
|
+
expect(res.body.requests[0].requester).to.not.equal(null);
|
586
|
+
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
646
587
|
|
588
|
+
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
647
589
|
|
648
|
-
|
649
|
-
|
590
|
+
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
591
|
+
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
592
|
+
expect(res.body.requests[0].hasBot).to.equal(false);
|
593
|
+
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
594
|
+
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
595
|
+
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
596
|
+
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
597
|
+
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
598
|
+
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
599
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
600
|
+
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
601
|
+
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
602
|
+
done();
|
603
|
+
});
|
604
|
+
// .catch(function(err) {
|
605
|
+
// console.log("test reject", err);
|
606
|
+
// assert.isNotOk(err,'Promise error');
|
607
|
+
// done();
|
608
|
+
// });
|
609
|
+
});
|
610
|
+
});
|
611
|
+
});
|
612
|
+
});
|
613
|
+
});
|
650
614
|
|
651
|
-
console.log("savedRequest", savedRequest);
|
652
615
|
|
653
|
-
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
654
|
-
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
655
|
-
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
656
616
|
|
657
|
-
winston.debug("resolve", savedRequest.toObject());
|
658
|
-
|
659
617
|
|
660
|
-
|
661
|
-
.get('/'+ savedProject._id + '/requests/?snap_department_id_bot_exists=false')
|
662
|
-
.auth(email, pwd)
|
663
|
-
.end(function(err, res) {
|
664
|
-
//console.log("res", res);
|
665
|
-
console.log("res.body", res.body);
|
666
|
-
res.should.have.status(200);
|
667
|
-
res.body.should.be.a('object');
|
618
|
+
// mocha test/requestRoute.js --grep 'snap_department_id_bot_exists'
|
668
619
|
|
669
|
-
|
670
|
-
|
671
|
-
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
672
|
-
|
673
|
-
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
674
|
-
|
675
|
-
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
676
|
-
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
677
|
-
expect(res.body.requests[0].hasBot).to.equal(false);
|
678
|
-
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
679
|
-
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
680
|
-
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
681
|
-
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
682
|
-
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
683
|
-
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
684
|
-
|
685
|
-
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
686
|
-
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
687
|
-
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
688
|
-
done();
|
689
|
-
});
|
690
|
-
// .catch(function(err) {
|
691
|
-
// console.log("test reject", err);
|
692
|
-
// assert.isNotOk(err,'Promise error');
|
693
|
-
// done();
|
694
|
-
// });
|
695
|
-
});
|
696
|
-
});
|
697
|
-
});
|
698
|
-
});
|
699
|
-
});
|
620
|
+
it('getallFilter-snap_department_id_bot_exists', function (done) {
|
621
|
+
// this.timeout(10000);
|
700
622
|
|
623
|
+
var email = "test-getallfilter-" + Date.now() + "@email.com";
|
624
|
+
var pwd = "pwd";
|
701
625
|
|
702
|
-
|
703
|
-
it('getallcsv', function (done) {
|
704
|
-
// this.timeout(10000);
|
626
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
705
627
|
|
706
|
-
|
707
|
-
var pwd = "pwd";
|
628
|
+
console.log("savedUser", savedUser);
|
708
629
|
|
709
|
-
|
710
|
-
projectService.createAndReturnProjectAndProjectUser("getallcsv", savedUser._id).then(function(savedProjectAndPU) {
|
630
|
+
projectService.createAndReturnProjectAndProjectUser("createWithId", savedUser._id).then(function (savedProjectAndPU) {
|
711
631
|
|
712
|
-
|
713
|
-
leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function(createdLead) {
|
632
|
+
var savedProject = savedProjectAndPU.project;
|
714
633
|
|
715
|
-
|
716
|
-
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
717
|
-
var now = Date.now();
|
634
|
+
console.log("savedProjectAndPU", savedProjectAndPU);
|
718
635
|
|
719
|
-
|
720
|
-
first_text: "first_text", tags: [{tag: "tag1"},{tag: "tag2"}]}).then(function(savedRequest) {
|
721
|
-
winston.info("resolve", savedRequest.toObject());
|
722
|
-
|
636
|
+
leadService.createIfNotExists("leadfullname", "email-getallfilter@email.com", savedProject._id).then(function (createdLead) {
|
723
637
|
|
724
|
-
|
725
|
-
.get('/'+ savedProject._id + '/requests/csv/')
|
726
|
-
.auth(email, pwd)
|
727
|
-
.end(function(err, res) {
|
728
|
-
//console.log("res", res);
|
729
|
-
console.log("res.text", res.text);
|
730
|
-
// console.log("res", res);
|
731
|
-
res.should.have.status(200);
|
732
|
-
res.body.should.be.a('object');
|
733
|
-
|
734
|
-
|
735
|
-
done();
|
736
|
-
});
|
737
|
-
// .catch(function(err) {
|
738
|
-
// console.log("test reject", err);
|
739
|
-
// assert.isNotOk(err,'Promise error');
|
740
|
-
// done();
|
741
|
-
// });
|
742
|
-
});
|
743
|
-
});
|
744
|
-
});
|
745
|
-
});
|
746
|
-
});
|
638
|
+
console.log("createdLead", createdLead);
|
747
639
|
|
640
|
+
var now = Date.now();
|
748
641
|
|
642
|
+
var new_request = {
|
643
|
+
request_id: "request_id-getallFilter-snap_department_id_bot_exists-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
644
|
+
id_project: savedProject._id, first_text: "first_text",
|
645
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
646
|
+
};
|
749
647
|
|
750
648
|
|
751
649
|
|
752
|
-
|
753
|
-
// this.timeout(10000);
|
650
|
+
requestService.create(new_request).then(function (savedRequest) {
|
754
651
|
|
755
|
-
|
756
|
-
var pwd = "pwd";
|
652
|
+
console.log("savedRequest", savedRequest);
|
757
653
|
|
758
|
-
|
654
|
+
// createWithId(request_id, requester_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status) {
|
655
|
+
// requestService.createWithId("request_id1", createdLead._id, savedProject._id, "first_text").then(function(savedRequest) {
|
656
|
+
// requestService.createWithIdAndRequester("request_id1", savedProjectAndPU.project_user._id, null,savedProject._id, "first_text").then(function(savedRequest) {
|
759
657
|
|
760
|
-
|
658
|
+
winston.debug("resolve", savedRequest.toObject());
|
761
659
|
|
762
|
-
var savedProject = savedProjectAndPU.project;
|
763
|
-
leadService.createIfNotExists("request_id1-getallWithLoLead", "email@getallWithLoLead.com", savedProject._id).then(function(createdLead) {
|
764
|
-
|
765
|
-
winston.info("createdLead", createdLead.toObject());
|
766
|
-
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
767
|
-
var now = Date.now();
|
768
660
|
|
769
|
-
|
661
|
+
chai.request(server)
|
662
|
+
.get('/' + savedProject._id + '/requests/?snap_department_id_bot_exists=false')
|
663
|
+
.auth(email, pwd)
|
664
|
+
.end(function (err, res) {
|
665
|
+
//console.log("res", res);
|
666
|
+
console.log("res.body", res.body);
|
667
|
+
res.should.have.status(200);
|
668
|
+
res.body.should.be.a('object');
|
770
669
|
|
771
|
-
|
772
|
-
|
670
|
+
expect(res.body.requests[0].department).to.not.equal(null);
|
671
|
+
expect(res.body.requests[0].requester).to.not.equal(null);
|
672
|
+
console.log("res.body.requests[0].requester", res.body.requests[0].requester);
|
773
673
|
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
674
|
+
expect(res.body.requests[0].requester.id_user.firstname).to.equal("Test Firstname");
|
675
|
+
|
676
|
+
expect(res.body.requests[0].participantsAgents.length).to.equal(1);
|
677
|
+
expect(res.body.requests[0].participantsBots).to.have.lengthOf(0);
|
678
|
+
expect(res.body.requests[0].hasBot).to.equal(false);
|
679
|
+
expect(res.body.requests[0].snapshot).to.not.equal(undefined);
|
680
|
+
expect(res.body.requests[0].snapshot.department.name).to.not.equal(null);
|
681
|
+
// expect(res.body.requests[0].snapshot.agents.length).to.equal(1);
|
682
|
+
expect(res.body.requests[0].snapshot.availableAgentsCount).to.equal(1);
|
683
|
+
expect(res.body.requests[0].snapshot.lead.fullname).to.equal("leadfullname");
|
684
|
+
expect(res.body.requests[0].snapshot.requester.role).to.equal("owner");
|
784
685
|
|
785
|
-
|
786
|
-
|
787
|
-
|
686
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
687
|
+
// expect(res.body.requests[0].participatingAgents.length).to.equal(1);
|
688
|
+
// expect(res.body.requests[0].participatingBots.length).to.equal(0);
|
689
|
+
done();
|
690
|
+
});
|
691
|
+
// .catch(function(err) {
|
692
|
+
// console.log("test reject", err);
|
693
|
+
// assert.isNotOk(err,'Promise error');
|
694
|
+
// done();
|
695
|
+
// });
|
788
696
|
});
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
// done();
|
793
|
-
// });
|
794
|
-
});
|
795
|
-
});
|
697
|
+
});
|
698
|
+
});
|
699
|
+
});
|
796
700
|
});
|
797
|
-
});
|
798
|
-
});
|
799
701
|
|
800
702
|
|
801
|
-
|
802
|
-
|
803
|
-
|
703
|
+
// mocha test/requestRoute.js --grep 'getallcsv'
|
704
|
+
it('getallcsv', function (done) {
|
705
|
+
// this.timeout(10000);
|
804
706
|
|
707
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
708
|
+
var pwd = "pwd";
|
805
709
|
|
806
|
-
|
710
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
711
|
+
projectService.createAndReturnProjectAndProjectUser("getallcsv", savedUser._id).then(function (savedProjectAndPU) {
|
807
712
|
|
808
|
-
|
809
|
-
|
713
|
+
var savedProject = savedProjectAndPU.project;
|
714
|
+
leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function (createdLead) {
|
810
715
|
|
811
|
-
|
812
|
-
|
716
|
+
winston.info("createdLead", createdLead.toObject());
|
717
|
+
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
718
|
+
var now = Date.now();
|
813
719
|
|
814
|
-
|
815
|
-
|
816
|
-
|
720
|
+
requestService.create({
|
721
|
+
request_id: "request_id-getallcsv-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id, id_project: savedProject._id,
|
722
|
+
first_text: "first_text", tags: [{ tag: "tag1" }, { tag: "tag2" }]
|
723
|
+
}).then(function (savedRequest) {
|
724
|
+
winston.info("resolve", savedRequest.toObject());
|
817
725
|
|
818
|
-
|
819
|
-
.
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
.end(function(err, res) {
|
726
|
+
|
727
|
+
chai.request(server)
|
728
|
+
.get('/' + savedProject._id + '/requests/csv/')
|
729
|
+
.auth(email, pwd)
|
730
|
+
.end(function (err, res) {
|
824
731
|
//console.log("res", res);
|
825
|
-
console.log("res.
|
732
|
+
console.log("res.text", res.text);
|
733
|
+
// console.log("res", res);
|
826
734
|
res.should.have.status(200);
|
827
735
|
res.body.should.be.a('object');
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
// res.body.should.have.property('agents').eql(savedUser._id);
|
841
|
-
expect(res.body.snapshot.agents.length).to.equal(1);
|
842
|
-
expect(res.body.participants.length).to.equal(1);
|
843
|
-
|
844
|
-
expect(res.body.participantsAgents.length).to.equal(1);
|
845
|
-
expect(res.body.participantsBots).to.have.lengthOf(0);
|
846
|
-
expect(res.body.hasBot).to.equal(false);
|
847
|
-
|
848
|
-
res.body.should.have.property('department').not.eql(null);
|
849
|
-
// res.body.should.have.property('lead').eql(undefined);
|
850
|
-
|
851
|
-
console.log("res.body.request_id: "+ res.body.request_id);
|
852
|
-
|
853
|
-
chai.request(server)
|
854
|
-
.put('/'+ savedProject._id + '/requests/'+res.body.request_id+"/departments")
|
855
|
-
.auth(email, pwd)
|
856
|
-
.set('content-type', 'application/json')
|
857
|
-
.send({})
|
858
|
-
.end(function(err, res2) {
|
859
|
-
//console.log("res", res);
|
860
|
-
console.log("res.body", res2.body);
|
861
|
-
res2.should.have.status(200);
|
862
|
-
res2.body.should.be.a('object');
|
863
|
-
expect(res.body.participants.length).to.equal(1);
|
864
|
-
expect(res.body.participantsAgents.length).to.equal(1);
|
865
|
-
expect(res.body.participantsBots.length).to.equal(0);
|
866
|
-
|
867
|
-
|
868
|
-
// expect(res.body.snapshot.agents).to.equal(undefined);
|
869
|
-
|
870
|
-
res2.body.requester.should.be.a('object');
|
871
|
-
res2.body.lead.should.be.a('object');
|
872
|
-
// expect(res.body.requester).to.equal(undefined);
|
873
|
-
// expect(res.body.lead).to.equal(undefined);
|
874
|
-
|
875
|
-
done();
|
876
|
-
});
|
877
|
-
|
878
|
-
});
|
736
|
+
|
737
|
+
|
738
|
+
done();
|
739
|
+
});
|
740
|
+
// .catch(function(err) {
|
741
|
+
// console.log("test reject", err);
|
742
|
+
// assert.isNotOk(err,'Promise error');
|
743
|
+
// done();
|
744
|
+
// });
|
745
|
+
});
|
746
|
+
});
|
747
|
+
});
|
879
748
|
});
|
880
749
|
});
|
881
|
-
});
|
882
750
|
|
883
751
|
|
884
752
|
|
885
|
-
// mocha test/requestRoute.js --grep 'createAndReassignAndNoPopulate'
|
886
753
|
|
887
|
-
|
754
|
+
|
755
|
+
it('getallWithLoLead', function (done) {
|
888
756
|
// this.timeout(10000);
|
889
757
|
|
890
|
-
var email = "test-
|
758
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
891
759
|
var pwd = "pwd";
|
892
760
|
|
893
|
-
userService.signup(
|
894
|
-
|
895
|
-
|
761
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
762
|
+
|
763
|
+
projectService.createAndReturnProjectAndProjectUser("getallcsv", savedUser._id).then(function (savedProjectAndPU) {
|
764
|
+
|
765
|
+
var savedProject = savedProjectAndPU.project;
|
766
|
+
leadService.createIfNotExists("request_id1-getallWithLoLead", "email@getallWithLoLead.com", savedProject._id).then(function (createdLead) {
|
767
|
+
|
768
|
+
winston.info("createdLead", createdLead.toObject());
|
769
|
+
// createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight, channel, location) {
|
770
|
+
var now = Date.now();
|
771
|
+
|
772
|
+
requestService.createWithIdAndRequester("request_id-getallWithLoLead-" + now, savedProjectAndPU.project_user._id, createdLead._id, savedProject._id, "first_text").then(function (savedRequest) {
|
773
|
+
|
774
|
+
winston.debug("resolve", savedRequest.toObject());
|
775
|
+
|
776
|
+
|
777
|
+
chai.request(server)
|
778
|
+
.get('/' + savedProject._id + '/requests/')
|
779
|
+
.auth(email, pwd)
|
780
|
+
.end(function (err, res) {
|
781
|
+
// console.log("res", res);
|
782
|
+
// console.log("res.body", res.body);
|
783
|
+
res.should.have.status(200);
|
784
|
+
res.body.should.be.a('object');
|
785
|
+
expect(res.body.requests[0].department).to.not.equal(null);
|
786
|
+
expect(res.body.requests[0].lead).to.not.equal(null);
|
787
|
+
|
788
|
+
expect(res.body.requests[0].snapshot.agents).to.equal(undefined);
|
789
|
+
|
790
|
+
done();
|
791
|
+
});
|
792
|
+
// .catch(function(err) {
|
793
|
+
// console.log("test reject", err);
|
794
|
+
// assert.isNotOk(err,'Promise error');
|
795
|
+
// done();
|
796
|
+
// });
|
797
|
+
});
|
798
|
+
});
|
799
|
+
});
|
800
|
+
});
|
801
|
+
});
|
802
|
+
|
803
|
+
|
804
|
+
describe('/assign', () => {
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
|
809
|
+
// mocha test/requestRoute.js --grep 'createAndReassign'
|
810
|
+
|
811
|
+
it('createAndReassign', function (done) {
|
812
|
+
// this.timeout(10000);
|
813
|
+
|
814
|
+
var email = "test-request-create-" + Date.now() + "@email.com";
|
815
|
+
var pwd = "pwd";
|
816
|
+
|
817
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
818
|
+
projectService.create("request-create", savedUser._id).then(function (savedProject) {
|
819
|
+
|
896
820
|
|
897
821
|
chai.request(server)
|
898
|
-
.post('/'+ savedProject._id + '/requests/')
|
822
|
+
.post('/' + savedProject._id + '/requests/')
|
899
823
|
.auth(email, pwd)
|
900
824
|
.set('content-type', 'application/json')
|
901
|
-
.send({"first_text":"first_text"})
|
902
|
-
.end(function(err, res) {
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
.put('/'+ savedProject._id + '/requests/'+res.body.request_id+"/departments")
|
825
|
+
.send({ "first_text": "first_text" })
|
826
|
+
.end(function (err, res) {
|
827
|
+
//console.log("res", res);
|
828
|
+
console.log("res.body", res.body);
|
829
|
+
res.should.have.status(200);
|
830
|
+
res.body.should.be.a('object');
|
831
|
+
|
832
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
833
|
+
// res.body.should.have.property('request_id').eql('request_id');
|
834
|
+
// res.body.should.have.property('requester_id').eql('requester_id');
|
835
|
+
res.body.should.have.property('first_text').eql('first_text');
|
836
|
+
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
837
|
+
res.body.should.have.property('createdBy').eql(savedUser._id.toString());
|
838
|
+
|
839
|
+
// res.body.should.have.property('messages_count').gt(0);
|
840
|
+
|
841
|
+
res.body.should.have.property('status').eql(200);
|
842
|
+
|
843
|
+
// res.body.should.have.property('agents').eql(savedUser._id);
|
844
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
845
|
+
expect(res.body.participants.length).to.equal(1);
|
846
|
+
|
847
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
848
|
+
expect(res.body.participantsBots).to.have.lengthOf(0);
|
849
|
+
expect(res.body.hasBot).to.equal(false);
|
850
|
+
|
851
|
+
res.body.should.have.property('department').not.eql(null);
|
852
|
+
// res.body.should.have.property('lead').eql(undefined);
|
853
|
+
|
854
|
+
console.log("res.body.request_id: " + res.body.request_id);
|
855
|
+
|
856
|
+
chai.request(server)
|
857
|
+
.put('/' + savedProject._id + '/requests/' + res.body.request_id + "/departments")
|
934
858
|
.auth(email, pwd)
|
935
859
|
.set('content-type', 'application/json')
|
936
|
-
.send({
|
937
|
-
.end(function(err, res2) {
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
860
|
+
.send({})
|
861
|
+
.end(function (err, res2) {
|
862
|
+
//console.log("res", res);
|
863
|
+
console.log("res.body", res2.body);
|
864
|
+
res2.should.have.status(200);
|
865
|
+
res2.body.should.be.a('object');
|
866
|
+
expect(res.body.participants.length).to.equal(1);
|
867
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
868
|
+
expect(res.body.participantsBots.length).to.equal(0);
|
869
|
+
|
870
|
+
|
871
|
+
// expect(res.body.snapshot.agents).to.equal(undefined);
|
872
|
+
|
873
|
+
res2.body.requester.should.be.a('object');
|
874
|
+
res2.body.lead.should.be.a('object');
|
875
|
+
// expect(res.body.requester).to.equal(undefined);
|
876
|
+
// expect(res.body.lead).to.equal(undefined);
|
877
|
+
|
878
|
+
done();
|
954
879
|
});
|
955
|
-
|
880
|
+
|
956
881
|
});
|
882
|
+
});
|
883
|
+
});
|
957
884
|
});
|
958
|
-
});
|
959
|
-
});
|
960
885
|
|
961
886
|
|
962
887
|
|
963
|
-
// mocha test/requestRoute.js --grep '
|
888
|
+
// mocha test/requestRoute.js --grep 'createAndReassignAndNoPopulate'
|
964
889
|
|
965
|
-
it('
|
966
|
-
|
890
|
+
it('createAndReassignAndNoPopulate', function (done) {
|
891
|
+
// this.timeout(10000);
|
967
892
|
|
968
|
-
|
969
|
-
|
893
|
+
var email = "test-request-create-" + Date.now() + "@email.com";
|
894
|
+
var pwd = "pwd";
|
970
895
|
|
971
|
-
|
972
|
-
|
973
|
-
|
896
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
897
|
+
projectService.create("request-create", savedUser._id).then(function (savedProject) {
|
974
898
|
|
975
|
-
|
976
|
-
.
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
899
|
+
|
900
|
+
chai.request(server)
|
901
|
+
.post('/' + savedProject._id + '/requests/')
|
902
|
+
.auth(email, pwd)
|
903
|
+
.set('content-type', 'application/json')
|
904
|
+
.send({ "first_text": "first_text" })
|
905
|
+
.end(function (err, res) {
|
981
906
|
//console.log("res", res);
|
982
|
-
console.log("res.body",
|
907
|
+
console.log("res.body", res.body);
|
983
908
|
res.should.have.status(200);
|
984
909
|
res.body.should.be.a('object');
|
985
|
-
|
910
|
+
|
986
911
|
expect(res.body.snapshot.agents.length).to.equal(1);
|
987
912
|
// res.body.should.have.property('request_id').eql('request_id');
|
988
913
|
// res.body.should.have.property('requester_id').eql('requester_id');
|
@@ -993,28 +918,28 @@ it('createAndAssign2', function (done) {
|
|
993
918
|
// res.body.should.have.property('messages_count').gt(0);
|
994
919
|
|
995
920
|
res.body.should.have.property('status').eql(200);
|
996
|
-
|
921
|
+
|
997
922
|
// res.body.should.have.property('agents').eql(savedUser._id);
|
998
923
|
expect(res.body.snapshot.agents.length).to.equal(1);
|
999
924
|
expect(res.body.participants.length).to.equal(1);
|
1000
925
|
|
1001
|
-
expect(res.body.participantsAgents.length).to.equal(1);
|
926
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
1002
927
|
expect(res.body.participantsBots).to.have.lengthOf(0);
|
1003
|
-
expect(res.body.hasBot).to.equal(false);
|
928
|
+
expect(res.body.hasBot).to.equal(false);
|
1004
929
|
|
1005
930
|
res.body.should.have.property('department').not.eql(null);
|
1006
931
|
// res.body.should.have.property('lead').eql(undefined);
|
1007
|
-
|
1008
|
-
console.log("res.body.request_id: "+ res.body.request_id);
|
932
|
+
|
933
|
+
console.log("res.body.request_id: " + res.body.request_id);
|
1009
934
|
|
1010
935
|
chai.request(server)
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
936
|
+
.put('/' + savedProject._id + '/requests/' + res.body.request_id + "/departments")
|
937
|
+
.auth(email, pwd)
|
938
|
+
.set('content-type', 'application/json')
|
939
|
+
.send({ "no_populate": "true" })
|
940
|
+
.end(function (err, res2) {
|
1016
941
|
//console.log("res", res);
|
1017
|
-
console.log("res.body",
|
942
|
+
console.log("res.body", res2.body);
|
1018
943
|
res2.should.have.status(200);
|
1019
944
|
res2.body.should.be.a('object');
|
1020
945
|
expect(res.body.participants.length).to.equal(1);
|
@@ -1022,97 +947,176 @@ it('createAndAssign2', function (done) {
|
|
1022
947
|
expect(res.body.participantsBots.length).to.equal(0);
|
1023
948
|
|
1024
949
|
// expect(res.body.snapshot.agents).to.equal(undefined);
|
1025
|
-
|
950
|
+
|
1026
951
|
res2.body.requester.should.be.a('string');
|
1027
952
|
res2.body.lead.should.be.a('string');
|
1028
953
|
// expect(res.body.requester).to.equal(undefined);
|
1029
954
|
// expect(res.body.lead).to.equal(undefined);
|
1030
955
|
|
1031
|
-
done();
|
1032
|
-
|
1033
|
-
|
1034
|
-
});
|
1035
|
-
});
|
1036
|
-
});
|
1037
|
-
});
|
956
|
+
done();
|
957
|
+
});
|
1038
958
|
|
959
|
+
});
|
960
|
+
});
|
961
|
+
});
|
962
|
+
});
|
1039
963
|
|
1040
964
|
|
1041
|
-
// mocha test/requestRoute.js --grep 'removeParticipant'
|
1042
|
-
it('removeParticipant', function (done) {
|
1043
|
-
// this.timeout(10000);
|
1044
965
|
|
1045
|
-
|
1046
|
-
var pwd = "pwd";
|
966
|
+
// mocha test/requestRoute.js --grep 'createAndAssign2'
|
1047
967
|
|
1048
|
-
|
1049
|
-
|
1050
|
-
var savedProject = savedProjectAndPU.project;
|
968
|
+
it('createAndAssign2', function (done) {
|
969
|
+
// this.timeout(10000);
|
1051
970
|
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
var now = Date.now();
|
971
|
+
var email = "test-request-create-" + Date.now() + "@email.com";
|
972
|
+
var pwd = "pwd";
|
1056
973
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
var request = {
|
1060
|
-
request_id:"request_id1-removeParticipant-"+now, project_user_id:savedProjectAndPU.project_user._id, lead_id:createdLead._id,
|
1061
|
-
id_project:savedProject._id, first_text: "first_text",
|
1062
|
-
lead:createdLead, requester: savedProjectAndPU.project_user };
|
974
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
975
|
+
projectService.create("request-create", savedUser._id).then(function (savedProject) {
|
1063
976
|
|
1064
|
-
requestService.create(request).then(function(savedRequest) {
|
1065
|
-
winston.info("savedRequest", savedRequest.toObject());
|
1066
|
-
expect(savedRequest.request_id).to.equal("request_id1-removeParticipant-"+now);
|
1067
977
|
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
978
|
+
chai.request(server)
|
979
|
+
.post('/' + savedProject._id + '/requests/')
|
980
|
+
.auth(email, pwd)
|
981
|
+
.set('content-type', 'application/json')
|
982
|
+
.send({ "first_text": "first_text" })
|
983
|
+
.end(function (err, res) {
|
1074
984
|
//console.log("res", res);
|
1075
|
-
console.log("res.body",
|
985
|
+
console.log("res.body", res.body);
|
1076
986
|
res.should.have.status(200);
|
1077
987
|
res.body.should.be.a('object');
|
1078
|
-
|
1079
|
-
|
988
|
+
|
989
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
1080
990
|
// res.body.should.have.property('request_id').eql('request_id');
|
1081
991
|
// res.body.should.have.property('requester_id').eql('requester_id');
|
1082
992
|
res.body.should.have.property('first_text').eql('first_text');
|
1083
993
|
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
1084
|
-
|
994
|
+
res.body.should.have.property('createdBy').eql(savedUser._id.toString());
|
1085
995
|
|
1086
996
|
// res.body.should.have.property('messages_count').gt(0);
|
1087
997
|
|
1088
|
-
res.body.should.have.property('status').eql(
|
1089
|
-
|
998
|
+
res.body.should.have.property('status').eql(200);
|
999
|
+
|
1090
1000
|
// res.body.should.have.property('agents').eql(savedUser._id);
|
1091
|
-
|
1092
|
-
expect(res.body.participants.length).to.equal(
|
1001
|
+
expect(res.body.snapshot.agents.length).to.equal(1);
|
1002
|
+
expect(res.body.participants.length).to.equal(1);
|
1093
1003
|
|
1094
|
-
expect(res.body.participantsAgents.length).to.equal(
|
1004
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
1095
1005
|
expect(res.body.participantsBots).to.have.lengthOf(0);
|
1096
|
-
expect(res.body.hasBot).to.equal(false);
|
1097
|
-
winston.info("res.body.attributes.abandoned_by_project_users", res.body.attributes.abandoned_by_project_users);
|
1098
|
-
expect(res.body.attributes.abandoned_by_project_users[savedProjectAndPU.project_user._id]).to.not.equal(undefined);
|
1099
|
-
expect(res.body.snapshot.agents).to.equal(undefined);
|
1006
|
+
expect(res.body.hasBot).to.equal(false);
|
1100
1007
|
|
1101
1008
|
res.body.should.have.property('department').not.eql(null);
|
1102
1009
|
// res.body.should.have.property('lead').eql(undefined);
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1010
|
+
|
1011
|
+
console.log("res.body.request_id: " + res.body.request_id);
|
1012
|
+
|
1013
|
+
chai.request(server)
|
1014
|
+
.put('/' + savedProject._id + '/requests/' + res.body.request_id + "/assign")
|
1015
|
+
.auth(email, pwd)
|
1016
|
+
.set('content-type', 'application/json')
|
1017
|
+
.send({})
|
1018
|
+
.end(function (err, res2) {
|
1019
|
+
//console.log("res", res);
|
1020
|
+
console.log("res.body", res2.body);
|
1021
|
+
res2.should.have.status(200);
|
1022
|
+
res2.body.should.be.a('object');
|
1023
|
+
expect(res.body.participants.length).to.equal(1);
|
1024
|
+
expect(res.body.participantsAgents.length).to.equal(1);
|
1025
|
+
expect(res.body.participantsBots.length).to.equal(0);
|
1026
|
+
|
1027
|
+
// expect(res.body.snapshot.agents).to.equal(undefined);
|
1028
|
+
|
1029
|
+
res2.body.requester.should.be.a('string');
|
1030
|
+
res2.body.lead.should.be.a('string');
|
1031
|
+
// expect(res.body.requester).to.equal(undefined);
|
1032
|
+
// expect(res.body.lead).to.equal(undefined);
|
1033
|
+
|
1034
|
+
done();
|
1035
|
+
});
|
1036
|
+
|
1037
|
+
});
|
1038
|
+
});
|
1039
|
+
});
|
1040
|
+
});
|
1041
|
+
|
1042
|
+
|
1043
|
+
|
1044
|
+
// mocha test/requestRoute.js --grep 'removeParticipant'
|
1045
|
+
it('removeParticipant', function (done) {
|
1046
|
+
// this.timeout(10000);
|
1047
|
+
|
1048
|
+
var email = "test-request-create-" + Date.now() + "@email.com";
|
1049
|
+
var pwd = "pwd";
|
1050
|
+
|
1051
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
1052
|
+
projectService.createAndReturnProjectAndProjectUser("request-removeParticipant", savedUser._id).then(function (savedProjectAndPU) {
|
1053
|
+
var savedProject = savedProjectAndPU.project;
|
1054
|
+
|
1055
|
+
leadService.createIfNotExists("leadfullname", "email@email.com", savedProject._id).then(function (createdLead) {
|
1056
|
+
winston.info("savedProjectAndPU.project_user._id:" + savedProjectAndPU.project_user._id);
|
1057
|
+
|
1058
|
+
var now = Date.now();
|
1059
|
+
|
1060
|
+
// projectService.create("request-removeParticipant", savedUser._id).then(function(savedProject) {
|
1061
|
+
// requestService.removeParticipantByRequestId(savedRequest.request_id, savedProject._id, userid).then(function(savedRequestParticipant) {
|
1062
|
+
var request = {
|
1063
|
+
request_id: "request_id1-removeParticipant-" + now, project_user_id: savedProjectAndPU.project_user._id, lead_id: createdLead._id,
|
1064
|
+
id_project: savedProject._id, first_text: "first_text",
|
1065
|
+
lead: createdLead, requester: savedProjectAndPU.project_user
|
1066
|
+
};
|
1067
|
+
|
1068
|
+
requestService.create(request).then(function (savedRequest) {
|
1069
|
+
winston.info("savedRequest", savedRequest.toObject());
|
1070
|
+
expect(savedRequest.request_id).to.equal("request_id1-removeParticipant-" + now);
|
1071
|
+
|
1072
|
+
chai.request(server)
|
1073
|
+
.delete('/' + savedProject._id + '/requests/' + 'request_id1-removeParticipant-' + now + "/participants/" + savedUser._id)
|
1074
|
+
.auth(email, pwd)
|
1075
|
+
.set('content-type', 'application/json')
|
1076
|
+
.send({ "text": "first_text" })
|
1077
|
+
.end(function (err, res) {
|
1078
|
+
//console.log("res", res);
|
1079
|
+
console.log("res.body", res.body);
|
1080
|
+
res.should.have.status(200);
|
1081
|
+
res.body.should.be.a('object');
|
1082
|
+
|
1083
|
+
// expect(res.body.snapshot.agents.length).to.equal(1);
|
1084
|
+
// res.body.should.have.property('request_id').eql('request_id');
|
1085
|
+
// res.body.should.have.property('requester_id').eql('requester_id');
|
1086
|
+
res.body.should.have.property('first_text').eql('first_text');
|
1087
|
+
res.body.should.have.property('id_project').eql(savedProject._id.toString());
|
1088
|
+
// res.body.should.have.property('createdBy').eql(savedUser._id.toString()); ?? expected '607ef36a2d060d79dc83ac9f' to deeply equal '607ef3692d060d79dc83ac9d'
|
1089
|
+
|
1090
|
+
// res.body.should.have.property('messages_count').gt(0);
|
1091
|
+
|
1092
|
+
res.body.should.have.property('status').eql(100);
|
1093
|
+
|
1094
|
+
// res.body.should.have.property('agents').eql(savedUser._id);
|
1095
|
+
// expect(res.body.snapshot.agents.length).to.equal(1);
|
1096
|
+
expect(res.body.participants.length).to.equal(0);
|
1097
|
+
|
1098
|
+
expect(res.body.participantsAgents.length).to.equal(0);
|
1099
|
+
expect(res.body.participantsBots).to.have.lengthOf(0);
|
1100
|
+
expect(res.body.hasBot).to.equal(false);
|
1101
|
+
winston.info("res.body.attributes.abandoned_by_project_users", res.body.attributes.abandoned_by_project_users);
|
1102
|
+
expect(res.body.attributes.abandoned_by_project_users[savedProjectAndPU.project_user._id]).to.not.equal(undefined);
|
1103
|
+
expect(res.body.snapshot.agents).to.equal(undefined);
|
1104
|
+
|
1105
|
+
res.body.should.have.property('department').not.eql(null);
|
1106
|
+
// res.body.should.have.property('lead').eql(undefined);
|
1107
|
+
|
1108
|
+
|
1109
|
+
done();
|
1110
|
+
});
|
1111
|
+
});
|
1106
1112
|
});
|
1113
|
+
});
|
1107
1114
|
});
|
1108
1115
|
});
|
1109
|
-
});
|
1110
|
-
});
|
1111
|
-
});
|
1112
1116
|
|
1113
1117
|
// it('assign', (done) => {
|
1114
1118
|
|
1115
|
-
|
1119
|
+
|
1116
1120
|
// // this.timeout();
|
1117
1121
|
|
1118
1122
|
// var email = "test-signup-" + Date.now() + "@email.com";
|
@@ -1123,8 +1127,8 @@ it('removeParticipant', function (done) {
|
|
1123
1127
|
// requestService.createWithId("join-member", "requester_id1", savedProject._id, "first_text").then(function(savedRequest) {
|
1124
1128
|
|
1125
1129
|
// var webhookContent = { "assignee": 'assignee-member'}
|
1126
|
-
|
1127
|
-
|
1130
|
+
|
1131
|
+
|
1128
1132
|
// chai.request(server)
|
1129
1133
|
// .post('/'+ savedProject._id + '/requests/' + savedRequest.request_id + '/assign')
|
1130
1134
|
// .auth(email, pwd)
|
@@ -1135,29 +1139,68 @@ it('removeParticipant', function (done) {
|
|
1135
1139
|
// res.should.have.status(200);
|
1136
1140
|
// res.body.should.be.a('object');
|
1137
1141
|
// // res.body.should.have.property('status').eql(200);
|
1138
|
-
|
1142
|
+
|
1139
1143
|
|
1140
1144
|
// // res.body.should.have.property('participants').to.have.lengthOf(2);
|
1141
1145
|
// // res.body.should.have.property('participants').contains("agentid1");
|
1142
1146
|
// // res.body.should.have.property('participants').contains(savedUser._id);
|
1143
|
-
|
1147
|
+
|
1144
1148
|
// done();
|
1145
1149
|
// });
|
1146
1150
|
|
1147
|
-
|
1151
|
+
|
1148
1152
|
// });
|
1149
1153
|
// });
|
1150
1154
|
// });
|
1151
1155
|
// }).timeout(20000);
|
1152
1156
|
|
1153
1157
|
|
1158
|
+
/*
|
1159
|
+
it('requestParameterFromChatbot', function (done) {
|
1160
|
+
// this.timeout(10000);
|
1161
|
+
|
1162
|
+
var email = "test-request-create-" + Date.now() + "@email.com";
|
1163
|
+
var pwd = "pwd";
|
1164
|
+
|
1165
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
1166
|
+
projectService.create("request-create", savedUser._id, { email: { template: { assignedRequest: "123" } } }).then(function (savedProject) {
|
1167
|
+
|
1168
|
+
chai.request(server)
|
1169
|
+
.post('/' + savedProject._id + '/requests/')
|
1170
|
+
.auth(email, pwd)
|
1171
|
+
.set('content-type', 'application/json')
|
1172
|
+
.send({ "first_text": "first_text" })
|
1173
|
+
.end(function (err, res) {
|
1174
|
+
//console.log("res", res);
|
1175
|
+
//console.log("res.body", res.body);
|
1176
|
+
res.should.have.status(200);
|
1177
|
+
res.body.should.be.a('object');
|
1178
|
+
|
1179
|
+
console.log("body: ", res.body);
|
1180
|
+
let request_id = res.body.request_id;
|
1154
1181
|
|
1182
|
+
console.log("request_id: ", request_id);
|
1155
1183
|
|
1184
|
+
chai.request(server)
|
1185
|
+
.get('/' + savedProject._id + '/requests/' + request_id + "/chatbot/parameters")
|
1186
|
+
.auth(email, pwd)
|
1187
|
+
.end((err, res) => {
|
1188
|
+
|
1189
|
+
console.log("err: ", err);
|
1190
|
+
console.log("res.body: ", res.body);
|
1191
|
+
done();
|
1192
|
+
})
|
1193
|
+
|
1194
|
+
});
|
1195
|
+
});
|
1196
|
+
});
|
1197
|
+
});
|
1156
1198
|
|
1199
|
+
*/
|
1157
1200
|
|
1158
1201
|
|
1159
1202
|
|
1160
|
-
});
|
1203
|
+
});
|
1161
1204
|
|
1162
1205
|
});
|
1163
1206
|
|