@tiledesk/tiledesk-server 2.10.14 → 2.10.16
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -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/request.js +10 -0
- package/routes/users.js +2 -2
- package/services/fileGridFsService.js +12 -10
- package/services/requestService.js +2 -1
- package/test/app-test.js +36 -1
- package/test/authentication.js +662 -796
- package/test/authenticationJwt.js +213 -315
- package/test/authorization.js +53 -72
- package/test/campaignsRoute.js +42 -47
- package/test/cannedRoute.js +30 -16
- package/test/departmentService.js +222 -274
- package/test/example.json +31 -1
- package/test/faqRoute.js +713 -622
- package/test/faqService.js +124 -159
- package/test/faqkbRoute.js +128 -100
- package/test/fileRoute.js +50 -46
- package/test/imageRoute.js +263 -254
- package/test/jwtRoute.js +128 -153
- package/test/kbRoute.js +40 -17
- package/test/kbsettingsRoute.js +78 -54
- package/test/keysRoute.js +6 -7
- package/test/labelRoute.js +591 -696
- package/test/labelService.js +40 -47
- package/test/leadService.js +100 -115
- package/test/logsRoute.js +13 -7
- package/test/messageRootRoute.js +112 -102
- package/test/messageRoute.js +1171 -1419
- package/test/messageService.js +41 -43
- package/test/openaiRoute.js +5 -1
- package/test/projectRoute.js +23 -4
- package/test/projectService.js +3 -1
- package/test/quoteManager.js +36 -13
- package/test/requestRoute.js +103 -72
- package/test/requestService.js +51 -51
- package/test/userRoute.js +37 -8
- package/test/userService.js +34 -31
- package/utils/promiseUtil.js +1 -1
package/test/imageRoute.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
//During the test the env variable is set to test
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
|
-
|
3
|
+
process.env.LOG_LEVEL = 'critical';
|
4
4
|
|
5
5
|
//Require the dev-dependencies
|
6
6
|
let chai = require('chai');
|
@@ -10,6 +10,9 @@ let server = require('../app');
|
|
10
10
|
let should = chai.should();
|
11
11
|
var fs = require('fs');
|
12
12
|
var userService = require('../services/userService');
|
13
|
+
const projectService = require('../services/projectService');
|
14
|
+
|
15
|
+
let log = false;
|
13
16
|
|
14
17
|
// chai.config.includeStack = true;
|
15
18
|
|
@@ -20,303 +23,309 @@ chai.use(chaiHttp);
|
|
20
23
|
|
21
24
|
describe('ImagesRoute', () => {
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
describe('/upload', () => {
|
26
27
|
|
27
|
-
|
28
|
+
it('upload-user', (done) => {
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
30
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
31
|
+
var pwd = "pwd";
|
32
|
+
|
33
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
34
|
+
|
35
|
+
chai.request(server)
|
36
|
+
.post('/images/users/')
|
37
|
+
.auth(email, pwd)
|
38
|
+
.set('Content-Type', 'image/jpeg')
|
39
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
|
40
|
+
// .field('delimiter', ';')
|
41
|
+
.end((err, res) => {
|
42
|
+
|
43
|
+
if (err) { console.error("err: ", err); }
|
44
|
+
if (log) { console.log("res.body", res.body); }
|
45
|
+
|
46
|
+
res.should.have.status(201);
|
47
|
+
res.body.should.be.a('object');
|
48
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
49
|
+
expect(res.body.filename).to.not.equal(null);
|
50
|
+
expect(res.body.filename).to.containIgnoreSpaces('test-image.png');
|
51
|
+
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
52
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
53
|
+
done();
|
54
|
+
});
|
55
|
+
|
56
|
+
});
|
53
57
|
});
|
54
|
-
});
|
55
58
|
|
56
59
|
|
57
|
-
// mocha test/imageRoute.js --grep 'upload-user-folder'
|
58
|
-
|
60
|
+
// mocha test/imageRoute.js --grep 'upload-user-folder'
|
61
|
+
it('upload-user-folder', (done) => {
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
64
|
-
|
65
|
-
chai.request(server)
|
66
|
-
.put('/images/users')
|
67
|
-
.auth(email, pwd)
|
68
|
-
.set('Content-Type','image/jpeg')
|
69
|
-
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
70
|
-
// .field('folder', 'myfolder')
|
71
|
-
.end((err, res) => {
|
72
|
-
//console.log("res", res);
|
73
|
-
console.log("res.body", res.body);
|
74
|
-
res.should.have.status(201);
|
75
|
-
res.body.should.be.a('object');
|
76
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
77
|
-
expect(res.body.filename).to.not.equal(null);
|
78
|
-
expect(res.body.filename).to.containIgnoreSpaces('profile.png');
|
79
|
-
expect(res.body.filename).to.containIgnoreSpaces('users','images');
|
80
|
-
// assert(res.body.filename.indexOf()).to.have.string('');
|
81
|
-
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
82
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
83
|
-
|
63
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
64
|
+
var pwd = "pwd";
|
84
65
|
|
66
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
85
67
|
|
86
|
-
|
87
|
-
chai.request(server)
|
68
|
+
chai.request(server)
|
88
69
|
.put('/images/users')
|
89
70
|
.auth(email, pwd)
|
90
|
-
.set('Content-Type','image/jpeg')
|
91
|
-
.attach('file',
|
71
|
+
.set('Content-Type', 'image/jpeg')
|
72
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
92
73
|
// .field('folder', 'myfolder')
|
93
|
-
.end((err, res) => {
|
94
|
-
|
95
|
-
|
74
|
+
.end((err, res) => {
|
75
|
+
|
76
|
+
if (err) { console.error("err: ", err); }
|
77
|
+
if (log) { console.log("res.body", res.body); }
|
78
|
+
|
79
|
+
res.should.have.status(201);
|
80
|
+
res.body.should.be.a('object');
|
81
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
82
|
+
expect(res.body.filename).to.not.equal(null);
|
83
|
+
expect(res.body.filename).to.containIgnoreSpaces('profile.png');
|
84
|
+
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
85
|
+
// assert(res.body.filename.indexOf()).to.have.string('');
|
86
|
+
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
87
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
88
|
+
|
89
|
+
//check duplicate
|
90
|
+
chai.request(server)
|
91
|
+
.put('/images/users')
|
92
|
+
.auth(email, pwd)
|
93
|
+
.set('Content-Type', 'image/jpeg')
|
94
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
95
|
+
// .field('folder', 'myfolder')
|
96
|
+
.end((err, res) => {
|
97
|
+
res.should.have.status(409);
|
98
|
+
done();
|
99
|
+
});
|
96
100
|
});
|
97
|
-
});
|
98
|
-
|
101
|
+
});
|
99
102
|
});
|
100
|
-
});
|
101
|
-
|
102
103
|
|
103
104
|
|
105
|
+
// mocha test/imageRoute.js --grep 'upload-avatar'
|
106
|
+
it('upload-avatar', (done) => {
|
104
107
|
|
105
|
-
|
106
|
-
|
108
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
109
|
+
var pwd = "pwd";
|
107
110
|
|
108
|
-
|
109
|
-
var pwd = "pwd";
|
111
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
110
112
|
|
111
|
-
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
112
|
-
|
113
|
-
chai.request(server)
|
114
|
-
.put('/images/users/photo')
|
115
|
-
.auth(email, pwd)
|
116
|
-
.set('Content-Type','image/jpeg')
|
117
|
-
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
118
|
-
// .field('folder', 'myfolder')
|
119
|
-
.end((err, res) => {
|
120
|
-
//console.log("res", res);
|
121
|
-
console.log("res.body", res.body);
|
122
|
-
console.log("res.status", res.status);
|
123
|
-
res.should.have.status(201);
|
124
|
-
res.body.should.be.a('object');
|
125
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
126
|
-
// expect(res.body.filename).to.not.equal("photo.jpg");
|
127
|
-
expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
|
128
|
-
expect(res.body.filename).to.containIgnoreSpaces('users','images');
|
129
|
-
// assert(res.body.filename.indexOf()).to.have.string('');
|
130
|
-
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
131
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
//check duplicate
|
136
113
|
chai.request(server)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
//
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
res.should.have.status(201);
|
173
|
-
res.body.should.be.a('object');
|
174
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
175
|
-
// expect(res.body.filename).to.not.equal("photo.jpg");
|
176
|
-
expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
|
177
|
-
expect(res.body.filename).to.containIgnoreSpaces('users','images');
|
178
|
-
// assert(res.body.filename.indexOf()).to.have.string('');
|
179
|
-
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
180
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
//check duplicate
|
185
|
-
chai.request(server)
|
186
|
-
.put('/images/users/photo?force=true')
|
187
|
-
.auth(email, pwd)
|
188
|
-
.set('Content-Type','image/jpeg')
|
189
|
-
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
190
|
-
// .field('folder', 'myfolder')
|
191
|
-
.end((err, res) => {
|
192
|
-
res.should.have.status(201);
|
193
|
-
done();
|
194
|
-
});
|
195
|
-
});
|
196
|
-
|
197
|
-
});
|
198
|
-
});
|
114
|
+
.put('/images/users/photo')
|
115
|
+
.auth(email, pwd)
|
116
|
+
.set('Content-Type', 'image/jpeg')
|
117
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
118
|
+
// .field('folder', 'myfolder')
|
119
|
+
.end((err, res) => {
|
120
|
+
|
121
|
+
if (err) { console.error("err: ", err); }
|
122
|
+
if (log) { console.log("res.body", res.body); }
|
123
|
+
|
124
|
+
res.should.have.status(201);
|
125
|
+
res.body.should.be.a('object');
|
126
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
127
|
+
// expect(res.body.filename).to.not.equal("photo.jpg");
|
128
|
+
expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
|
129
|
+
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
130
|
+
// assert(res.body.filename.indexOf()).to.have.string('');
|
131
|
+
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
132
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
133
|
+
|
134
|
+
//check duplicate
|
135
|
+
chai.request(server)
|
136
|
+
.put('/images/users/photo')
|
137
|
+
.auth(email, pwd)
|
138
|
+
.set('Content-Type', 'image/jpeg')
|
139
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
140
|
+
// .field('folder', 'myfolder')
|
141
|
+
.end((err, res) => {
|
142
|
+
|
143
|
+
res.should.have.status(409);
|
144
|
+
done();
|
145
|
+
});
|
146
|
+
});
|
147
|
+
});
|
148
|
+
}).timeout(5000);
|
199
149
|
|
200
150
|
|
151
|
+
// mocha test/imageRoute.js --grep 'upload-avatar-force'
|
152
|
+
it('upload-avatar-force', (done) => {
|
201
153
|
|
202
|
-
|
203
|
-
|
154
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
155
|
+
var pwd = "pwd";
|
204
156
|
|
205
|
-
|
206
|
-
var pwd = "pwd";
|
157
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
207
158
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
159
|
+
chai.request(server)
|
160
|
+
.put('/images/users/photo?force=true')
|
161
|
+
.auth(email, pwd)
|
162
|
+
.set('Content-Type', 'image/jpeg')
|
163
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
164
|
+
// .field('folder', 'myfolder')
|
165
|
+
.end((err, res) => {
|
166
|
+
|
167
|
+
if (err) { console.error("err: ", err); }
|
168
|
+
if (log) { console.log("res.body", res.body); }
|
169
|
+
|
170
|
+
res.should.have.status(201);
|
171
|
+
res.body.should.be.a('object');
|
172
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
173
|
+
// expect(res.body.filename).to.not.equal("photo.jpg");
|
174
|
+
expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
|
175
|
+
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
176
|
+
// assert(res.body.filename.indexOf()).to.have.string('');
|
177
|
+
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
178
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
179
|
+
|
180
|
+
//check duplicate
|
181
|
+
chai.request(server)
|
182
|
+
.put('/images/users/photo?force=true')
|
183
|
+
.auth(email, pwd)
|
184
|
+
.set('Content-Type', 'image/jpeg')
|
185
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
186
|
+
// .field('folder', 'myfolder')
|
187
|
+
.end((err, res) => {
|
188
|
+
res.should.have.status(201);
|
189
|
+
done();
|
190
|
+
});
|
191
|
+
});
|
192
|
+
});
|
193
|
+
});
|
229
194
|
|
230
195
|
|
196
|
+
// mocha test/imageRoute.js --grep 'upload-avatar-another-user'
|
197
|
+
it('upload-avatar-another-user', (done) => {
|
231
198
|
|
232
|
-
|
233
|
-
|
234
|
-
.put('/images/users/photo?user_id='+bot)
|
235
|
-
.auth(email, pwd)
|
236
|
-
.set('Content-Type','image/jpeg')
|
237
|
-
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
238
|
-
// .field('folder', 'myfolder')
|
239
|
-
.end((err, res) => {
|
240
|
-
res.should.have.status(409);
|
241
|
-
done();
|
242
|
-
});
|
243
|
-
});
|
244
|
-
|
245
|
-
});
|
246
|
-
});
|
199
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
200
|
+
var pwd = "pwd";
|
247
201
|
|
202
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
203
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
248
204
|
|
205
|
+
chai.request(server)
|
206
|
+
.post('/' + savedProject._id + '/faq_kb')
|
207
|
+
.auth(email, pwd)
|
208
|
+
.send({ "name": "testbot", type: "internal", template: "example", language: 'en' })
|
209
|
+
.end((err, res) => {
|
210
|
+
if (err) { console.error("err: ", err); }
|
211
|
+
if (log) { console.log("res.body: ", res.body); }
|
212
|
+
|
213
|
+
//var bot = "bot_" + Date.now();
|
214
|
+
let bot_id = res.body._id;
|
215
|
+
|
216
|
+
chai.request(server)
|
217
|
+
.put('/images/users/photo?bot_id=' + bot_id)
|
218
|
+
.auth(email, pwd)
|
219
|
+
.set('Content-Type', 'image/jpeg')
|
220
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
221
|
+
// .field('folder', 'myfolder')
|
222
|
+
.end((err, res) => {
|
223
|
+
|
224
|
+
if (err) { console.error("err: ", err); }
|
225
|
+
if (log) { console.log("res.body", res.body); }
|
226
|
+
|
227
|
+
res.should.have.status(201);
|
228
|
+
res.body.should.be.a('object');
|
229
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
230
|
+
expect(res.body.filename).to.not.equal("photo.jpg");
|
231
|
+
// assert(res.body.filename.indexOf()).to.have.string('');
|
232
|
+
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
233
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
234
|
+
// expect(res.body.filename).to.include.keys(bot);
|
235
|
+
expect(res.body.filename).to.containIgnoreSpaces(bot_id);
|
236
|
+
|
237
|
+
//check duplicate
|
238
|
+
chai.request(server)
|
239
|
+
.put('/images/users/photo?bot_id=' + bot_id)
|
240
|
+
.auth(email, pwd)
|
241
|
+
.set('Content-Type', 'image/jpeg')
|
242
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
243
|
+
// .field('folder', 'myfolder')
|
244
|
+
.end((err, res) => {
|
245
|
+
|
246
|
+
if (err) { console.error("err: ", err); }
|
247
|
+
if (log) { console.log("res.body: ", res.body); }
|
248
|
+
|
249
|
+
res.should.have.status(409);
|
250
|
+
|
251
|
+
done();
|
252
|
+
});
|
253
|
+
});
|
254
|
+
|
255
|
+
})
|
256
|
+
});
|
257
|
+
})
|
258
|
+
});
|
249
259
|
|
250
260
|
|
251
|
-
// mocha test/imageRoute.js --grep 'delete-user-folder'
|
252
|
-
it('delete-user-folder', (done) => {
|
261
|
+
// mocha test/imageRoute.js --grep 'delete-user-folder'
|
262
|
+
it('delete-user-folder', (done) => {
|
253
263
|
|
254
|
-
|
255
|
-
|
264
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
265
|
+
var pwd = "pwd";
|
256
266
|
|
257
|
-
|
258
|
-
|
259
|
-
chai.request(server)
|
260
|
-
.put('/images/users')
|
261
|
-
.auth(email, pwd)
|
262
|
-
.set('Content-Type','image/jpeg')
|
263
|
-
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
264
|
-
// .field('folder', 'myfolder')
|
265
|
-
.end((err, res) => {
|
266
|
-
//console.log("res", res);
|
267
|
-
console.log("res.body", res.body);
|
268
|
-
res.should.have.status(201);
|
269
|
-
res.body.should.be.a('object');
|
270
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
271
|
-
expect(res.body.filename).to.not.equal(null);
|
272
|
-
// assert(res.body.filename.indexOf()).to.have.string('');
|
273
|
-
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
274
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
275
|
-
|
267
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
276
268
|
|
277
269
|
chai.request(server)
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
270
|
+
.put('/images/users')
|
271
|
+
.auth(email, pwd)
|
272
|
+
.set('Content-Type', 'image/jpeg')
|
273
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
|
274
|
+
// .field('folder', 'myfolder')
|
275
|
+
.end((err, res) => {
|
276
|
+
|
277
|
+
if (err) { console.error("err: ", err); }
|
278
|
+
if (log) { console.log("res.body", res.body); }
|
279
|
+
|
280
|
+
res.should.have.status(201);
|
281
|
+
res.body.should.be.a('object');
|
282
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
283
|
+
expect(res.body.filename).to.not.equal(null);
|
284
|
+
// assert(res.body.filename.indexOf()).to.have.string('');
|
285
|
+
// assert.equal(res.body.filename.indexOf('myfilder'), 1);
|
286
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
287
|
+
|
288
|
+
chai.request(server)
|
289
|
+
.delete('/images/users?path=' + res.body.filename)
|
290
|
+
.auth(email, pwd)
|
291
|
+
.end((err, res) => {
|
292
|
+
|
293
|
+
if (err) { console.error("err: ", err); }
|
294
|
+
if (log) { console.log("res.body", res.body); }
|
295
|
+
|
296
|
+
res.should.have.status(200);
|
297
|
+
expect(res.body.message).to.equal('Image deleted successfully');
|
298
|
+
done();
|
299
|
+
});
|
300
|
+
});
|
301
|
+
});
|
302
|
+
});
|
291
303
|
|
292
304
|
|
293
|
-
// mocha test/imageRoute.js --grep 'upload-public'
|
294
|
-
|
305
|
+
// mocha test/imageRoute.js --grep 'upload-public'
|
306
|
+
it('upload-public', (done) => {
|
295
307
|
|
296
|
-
|
297
308
|
chai.request(server)
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
console.
|
309
|
+
.post('/images/public/')
|
310
|
+
.set('Content-Type', 'image/jpeg')
|
311
|
+
.attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
|
312
|
+
// .field('delimiter', ';')
|
313
|
+
.end((err, res) => {
|
314
|
+
|
315
|
+
if (err) { console.error("err: ", err); }
|
316
|
+
if (log) { console.log("res.body", res.body); }
|
317
|
+
|
305
318
|
res.should.have.status(201);
|
306
319
|
res.body.should.be.a('object');
|
307
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
308
|
-
expect(res.body.filename).to.not.equal(null);
|
309
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
320
|
+
expect(res.body.message).to.equal('Image uploded successfully');
|
321
|
+
expect(res.body.filename).to.not.equal(null);
|
322
|
+
expect(res.body.thumbnail).to.not.equal(null);
|
323
|
+
|
310
324
|
done();
|
311
|
-
|
312
|
-
|
313
|
-
|
325
|
+
});
|
326
|
+
});
|
314
327
|
});
|
315
328
|
|
316
|
-
|
317
|
-
|
318
|
-
});
|
319
|
-
|
320
329
|
});
|
321
330
|
|
322
331
|
|