]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import * as request from 'supertest' | |
4 | import { join } from 'path' | |
5 | import 'mocha' | |
6 | import * as chai from 'chai' | |
7 | const expect = chai.expect | |
8 | ||
9 | import { | |
10 | ServerInfo, | |
11 | flushTests, | |
12 | runServer, | |
13 | getVideosList, | |
14 | makePutBodyRequest, | |
15 | setAccessTokensToServers, | |
16 | killallServers, | |
5f04dd2f C |
17 | makePostUploadRequest, |
18 | getMyUserInformation, | |
19 | createUser, | |
20 | getUserAccessToken | |
0e1dc3e7 | 21 | } from '../../utils' |
11474c3c | 22 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
0e1dc3e7 C |
23 | |
24 | describe('Test videos API validator', function () { | |
25 | const path = '/api/v1/videos/' | |
26 | let server: ServerInfo | |
5f04dd2f | 27 | let channelId: number |
0e1dc3e7 | 28 | |
11474c3c C |
29 | function getCompleteVideoUploadAttributes () { |
30 | return { | |
31 | name: 'my super name', | |
32 | category: 5, | |
33 | licence: 1, | |
34 | language: 6, | |
35 | nsfw: false, | |
36 | description: 'my super description', | |
37 | tags: [ 'tag1', 'tag2' ], | |
38 | privacy: VideoPrivacy.PUBLIC, | |
39 | channelId | |
40 | } | |
41 | } | |
42 | ||
43 | function getCompleteVideoUpdateAttributes () { | |
44 | return { | |
45 | name: 'my super name', | |
46 | category: 5, | |
47 | licence: 2, | |
48 | language: 6, | |
49 | nsfw: false, | |
50 | description: 'my super description', | |
51 | privacy: VideoPrivacy.PUBLIC, | |
52 | tags: [ 'tag1', 'tag2' ] | |
53 | } | |
54 | } | |
55 | ||
56 | function getVideoUploadAttaches () { | |
57 | return { | |
58 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | |
59 | } | |
60 | } | |
61 | ||
0e1dc3e7 C |
62 | // --------------------------------------------------------------- |
63 | ||
64 | before(async function () { | |
65 | this.timeout(20000) | |
66 | ||
67 | await flushTests() | |
68 | ||
69 | server = await runServer(1) | |
70 | ||
71 | await setAccessTokensToServers([ server ]) | |
5f04dd2f C |
72 | |
73 | const res = await getMyUserInformation(server.url, server.accessToken) | |
74 | channelId = res.body.videoChannels[0].id | |
0e1dc3e7 C |
75 | }) |
76 | ||
77 | describe('When listing a video', function () { | |
78 | it('Should fail with a bad start pagination', async function () { | |
79 | await request(server.url) | |
80 | .get(path) | |
81 | .query({ start: 'hello' }) | |
82 | .set('Accept', 'application/json') | |
83 | .expect(400) | |
84 | }) | |
85 | ||
86 | it('Should fail with a bad count pagination', async function () { | |
87 | await request(server.url) | |
88 | .get(path) | |
89 | .query({ count: 'hello' }) | |
90 | .set('Accept', 'application/json') | |
91 | .expect(400) | |
92 | }) | |
93 | ||
94 | it('Should fail with an incorrect sort', async function () { | |
95 | await request(server.url) | |
96 | .get(path) | |
97 | .query({ sort: 'hello' }) | |
98 | .set('Accept', 'application/json') | |
99 | .expect(400) | |
100 | }) | |
101 | }) | |
102 | ||
103 | describe('When searching a video', function () { | |
104 | it('Should fail with nothing', async function () { | |
105 | await request(server.url) | |
106 | .get(join(path, 'search')) | |
107 | .set('Accept', 'application/json') | |
108 | .expect(400) | |
109 | }) | |
110 | ||
111 | it('Should fail with a bad start pagination', async function () { | |
112 | await request(server.url) | |
113 | .get(join(path, 'search', 'test')) | |
114 | .query({ start: 'hello' }) | |
115 | .set('Accept', 'application/json') | |
116 | .expect(400) | |
117 | }) | |
118 | ||
119 | it('Should fail with a bad count pagination', async function () { | |
120 | await request(server.url) | |
121 | .get(join(path, 'search', 'test')) | |
122 | .query({ count: 'hello' }) | |
123 | .set('Accept', 'application/json') | |
124 | .expect(400) | |
125 | }) | |
126 | ||
127 | it('Should fail with an incorrect sort', async function () { | |
128 | await request(server.url) | |
129 | .get(join(path, 'search', 'test')) | |
130 | .query({ sort: 'hello' }) | |
131 | .set('Accept', 'application/json') | |
132 | .expect(400) | |
133 | }) | |
134 | }) | |
135 | ||
11474c3c C |
136 | describe('When listing my videos', function () { |
137 | const path = '/api/v1/users/me/videos' | |
138 | ||
139 | it('Should fail with a bad start pagination', async function () { | |
140 | await request(server.url) | |
141 | .get(path) | |
142 | .set('Authorization', 'Bearer ' + server.accessToken) | |
143 | .query({ start: 'hello' }) | |
144 | .set('Accept', 'application/json') | |
145 | .expect(400) | |
146 | }) | |
147 | ||
148 | it('Should fail with a bad count pagination', async function () { | |
149 | await request(server.url) | |
150 | .get(path) | |
151 | .set('Authorization', 'Bearer ' + server.accessToken) | |
152 | .query({ count: 'hello' }) | |
153 | .set('Accept', 'application/json') | |
154 | .expect(400) | |
155 | }) | |
156 | ||
157 | it('Should fail with an incorrect sort', async function () { | |
158 | await request(server.url) | |
159 | .get(path) | |
160 | .set('Authorization', 'Bearer ' + server.accessToken) | |
161 | .query({ sort: 'hello' }) | |
162 | .set('Accept', 'application/json') | |
163 | .expect(400) | |
164 | }) | |
165 | }) | |
166 | ||
0e1dc3e7 C |
167 | describe('When adding a video', function () { |
168 | it('Should fail with nothing', async function () { | |
169 | const fields = {} | |
170 | const attaches = {} | |
e95561cd | 171 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
172 | }) |
173 | ||
174 | it('Should fail without name', async function () { | |
11474c3c C |
175 | const fields = getCompleteVideoUploadAttributes() |
176 | delete fields.name | |
177 | ||
178 | const attaches = getVideoUploadAttaches() | |
e95561cd | 179 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
180 | }) |
181 | ||
182 | it('Should fail with a long name', async function () { | |
11474c3c C |
183 | const fields = getCompleteVideoUploadAttributes() |
184 | fields.name = 'My very very very very very very very very very very very very very very very very very ' + | |
185 | 'very very very very very very very very very very very very very very very very long long' + | |
186 | 'very very very very very very very very very very very very very very very very long name' | |
187 | ||
188 | const attaches = getVideoUploadAttaches | |
e95561cd | 189 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
190 | }) |
191 | ||
192 | it('Should fail without a category', async function () { | |
11474c3c C |
193 | const fields = getCompleteVideoUploadAttributes() |
194 | delete fields.category | |
195 | ||
196 | const attaches = getVideoUploadAttaches | |
e95561cd | 197 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
198 | }) |
199 | ||
200 | it('Should fail with a bad category', async function () { | |
11474c3c C |
201 | const fields = getCompleteVideoUploadAttributes() |
202 | fields.category = 125 | |
203 | ||
204 | const attaches = getVideoUploadAttaches | |
e95561cd | 205 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
206 | }) |
207 | ||
208 | it('Should fail without a licence', async function () { | |
11474c3c C |
209 | const fields = getCompleteVideoUploadAttributes() |
210 | delete fields.licence | |
211 | ||
212 | const attaches = getVideoUploadAttaches() | |
e95561cd | 213 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
214 | }) |
215 | ||
216 | it('Should fail with a bad licence', async function () { | |
11474c3c C |
217 | const fields = getCompleteVideoUploadAttributes() |
218 | fields.licence = 125 | |
219 | ||
220 | const attaches = getVideoUploadAttaches() | |
e95561cd | 221 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
222 | }) |
223 | ||
224 | it('Should fail with a bad language', async function () { | |
11474c3c C |
225 | const fields = getCompleteVideoUploadAttributes() |
226 | fields.language = 563 | |
227 | ||
228 | const attaches = getVideoUploadAttaches() | |
e95561cd | 229 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
230 | }) |
231 | ||
232 | it('Should fail without nsfw attribute', async function () { | |
11474c3c C |
233 | const fields = getCompleteVideoUploadAttributes() |
234 | delete fields.nsfw | |
235 | ||
236 | const attaches = getVideoUploadAttaches() | |
e95561cd | 237 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
238 | }) |
239 | ||
5f04dd2f | 240 | it('Should fail with a bad nsfw attribute', async function () { |
11474c3c C |
241 | const fields = getCompleteVideoUploadAttributes() |
242 | fields.nsfw = 2 as any | |
243 | ||
244 | const attaches = getVideoUploadAttaches() | |
e95561cd | 245 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
246 | }) |
247 | ||
248 | it('Should fail without description', async function () { | |
11474c3c C |
249 | const fields = getCompleteVideoUploadAttributes() |
250 | delete fields.description | |
251 | ||
252 | const attaches = getVideoUploadAttaches() | |
e95561cd | 253 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
254 | }) |
255 | ||
256 | it('Should fail with a long description', async function () { | |
11474c3c C |
257 | const fields = getCompleteVideoUploadAttributes() |
258 | fields.description = 'my super description which is very very very very very very very very very very very very long'.repeat(35) | |
259 | ||
260 | const attaches = getVideoUploadAttaches() | |
5f04dd2f C |
261 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
262 | }) | |
263 | ||
264 | it('Should fail without a channel', async function () { | |
11474c3c C |
265 | const fields = getCompleteVideoUploadAttributes() |
266 | delete fields.channelId | |
267 | ||
268 | const attaches = getVideoUploadAttaches() | |
e95561cd | 269 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
270 | }) |
271 | ||
5f04dd2f | 272 | it('Should fail with a bad channel', async function () { |
11474c3c C |
273 | const fields = getCompleteVideoUploadAttributes() |
274 | fields.channelId = 545454 | |
275 | ||
276 | const attaches = getVideoUploadAttaches() | |
5f04dd2f C |
277 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
278 | }) | |
279 | ||
280 | it('Should fail with another user channel', async function () { | |
281 | const user = { | |
282 | username: 'fake', | |
283 | password: 'fake_password' | |
284 | } | |
285 | await createUser(server.url, server.accessToken, user.username, user.password) | |
286 | ||
287 | const accessTokenUser = await getUserAccessToken(server, user) | |
288 | const res = await getMyUserInformation(server.url, accessTokenUser) | |
11474c3c C |
289 | const customChannelId = res.body.videoChannels[0].id |
290 | ||
291 | const fields = getCompleteVideoUploadAttributes() | |
292 | fields.channelId = customChannelId | |
293 | ||
294 | const attaches = getVideoUploadAttaches() | |
5f04dd2f C |
295 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
296 | }) | |
297 | ||
0e1dc3e7 | 298 | it('Should fail with too many tags', async function () { |
11474c3c C |
299 | const fields = getCompleteVideoUploadAttributes() |
300 | fields.tags = [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] | |
301 | ||
302 | const attaches = getVideoUploadAttaches() | |
e95561cd | 303 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
304 | }) |
305 | ||
306 | it('Should fail with a tag length too low', async function () { | |
11474c3c C |
307 | const fields = getCompleteVideoUploadAttributes() |
308 | fields.tags = [ 'tag1', 't' ] | |
309 | ||
310 | const attaches = getVideoUploadAttaches() | |
e95561cd | 311 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
312 | }) |
313 | ||
314 | it('Should fail with a tag length too big', async function () { | |
11474c3c C |
315 | const fields = getCompleteVideoUploadAttributes() |
316 | fields.tags = [ 'my_super_tag_too_long_long_long_long_long_long', 'tag1' ] | |
317 | ||
318 | const attaches = getVideoUploadAttaches() | |
e95561cd | 319 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
320 | }) |
321 | ||
322 | it('Should fail without an input file', async function () { | |
11474c3c | 323 | const fields = getCompleteVideoUploadAttributes() |
0e1dc3e7 | 324 | const attaches = {} |
e95561cd | 325 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
326 | }) |
327 | ||
328 | it('Should fail without an incorrect input file', async function () { | |
11474c3c | 329 | const fields = getCompleteVideoUploadAttributes() |
0e1dc3e7 C |
330 | const attaches = { |
331 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | |
332 | } | |
e95561cd | 333 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
334 | }) |
335 | ||
336 | it('Should fail with a too big duration', async function () { | |
11474c3c | 337 | const fields = getCompleteVideoUploadAttributes() |
0e1dc3e7 C |
338 | const attaches = { |
339 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') | |
340 | } | |
e95561cd | 341 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
0e1dc3e7 C |
342 | }) |
343 | ||
344 | it('Should succeed with the correct parameters', async function () { | |
345 | this.timeout(10000) | |
346 | ||
11474c3c C |
347 | const fields = getCompleteVideoUploadAttributes() |
348 | const attaches = getVideoUploadAttaches() | |
0e1dc3e7 | 349 | |
e95561cd C |
350 | await makePostUploadRequest({ |
351 | url: server.url, | |
352 | path: path + '/upload', | |
353 | token: server.accessToken, | |
354 | fields, | |
355 | attaches, | |
356 | statusCodeExpected: 204 | |
357 | }) | |
0e1dc3e7 C |
358 | |
359 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4') | |
e95561cd C |
360 | await makePostUploadRequest({ |
361 | url: server.url, | |
362 | path: path + '/upload', | |
363 | token: server.accessToken, | |
364 | fields, | |
365 | attaches, | |
366 | statusCodeExpected: 204 | |
367 | }) | |
0e1dc3e7 C |
368 | |
369 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv') | |
e95561cd C |
370 | await makePostUploadRequest({ |
371 | url: server.url, | |
372 | path: path + '/upload', | |
373 | token: server.accessToken, | |
374 | fields, | |
375 | attaches, | |
376 | statusCodeExpected: 204 | |
377 | }) | |
0e1dc3e7 C |
378 | }) |
379 | }) | |
380 | ||
381 | describe('When updating a video', function () { | |
382 | let videoId | |
383 | ||
384 | before(async function () { | |
385 | const res = await getVideosList(server.url) | |
386 | videoId = res.body.data[0].id | |
387 | }) | |
388 | ||
389 | it('Should fail with nothing', async function () { | |
390 | const fields = {} | |
391 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | |
392 | }) | |
393 | ||
394 | it('Should fail without a valid uuid', async function () { | |
11474c3c | 395 | const fields = getCompleteVideoUpdateAttributes() |
0e1dc3e7 C |
396 | await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields }) |
397 | }) | |
398 | ||
399 | it('Should fail with an unknown id', async function () { | |
11474c3c C |
400 | const fields = getCompleteVideoUpdateAttributes() |
401 | ||
0e1dc3e7 C |
402 | await makePutBodyRequest({ |
403 | url: server.url, | |
404 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', | |
405 | token: server.accessToken, | |
406 | fields, | |
407 | statusCodeExpected: 404 | |
408 | }) | |
409 | }) | |
410 | ||
411 | it('Should fail with a long name', async function () { | |
11474c3c C |
412 | const fields = getCompleteVideoUpdateAttributes() |
413 | fields.name = 'My very very very very very very very very very very very very very very very very long'.repeat(3) | |
414 | ||
0e1dc3e7 C |
415 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
416 | }) | |
417 | ||
418 | it('Should fail with a bad category', async function () { | |
11474c3c C |
419 | const fields = getCompleteVideoUpdateAttributes() |
420 | fields.category = 128 | |
421 | ||
0e1dc3e7 C |
422 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
423 | }) | |
424 | ||
425 | it('Should fail with a bad licence', async function () { | |
11474c3c C |
426 | const fields = getCompleteVideoUpdateAttributes() |
427 | fields.licence = 128 | |
428 | ||
0e1dc3e7 C |
429 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
430 | }) | |
431 | ||
432 | it('Should fail with a bad language', async function () { | |
11474c3c C |
433 | const fields = getCompleteVideoUpdateAttributes() |
434 | fields.language = 896 | |
435 | ||
0e1dc3e7 C |
436 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
437 | }) | |
438 | ||
439 | it('Should fail with a bad nsfw attribute', async function () { | |
11474c3c C |
440 | const fields = getCompleteVideoUpdateAttributes() |
441 | fields.nsfw = (-4 as any) | |
442 | ||
0e1dc3e7 C |
443 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
444 | }) | |
445 | ||
446 | it('Should fail with a long description', async function () { | |
11474c3c C |
447 | const fields = getCompleteVideoUpdateAttributes() |
448 | fields.description = 'my super description which is very very very very very very very very very very very very very long'.repeat(35) | |
449 | ||
0e1dc3e7 C |
450 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
451 | }) | |
452 | ||
453 | it('Should fail with too many tags', async function () { | |
11474c3c C |
454 | const fields = getCompleteVideoUpdateAttributes() |
455 | fields.tags = [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] | |
456 | ||
0e1dc3e7 C |
457 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
458 | }) | |
459 | ||
460 | it('Should fail with a tag length too low', async function () { | |
11474c3c C |
461 | const fields = getCompleteVideoUpdateAttributes() |
462 | fields.tags = [ 'tag1', 't' ] | |
463 | ||
0e1dc3e7 C |
464 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
465 | }) | |
466 | ||
467 | it('Should fail with a tag length too big', async function () { | |
11474c3c C |
468 | const fields = getCompleteVideoUpdateAttributes() |
469 | fields.tags = [ 'my_super_tag_too_long_long_long_long', 'tag1' ] | |
470 | ||
0e1dc3e7 C |
471 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
472 | }) | |
473 | ||
474 | it('Should fail with a video of another user') | |
475 | ||
476 | it('Should fail with a video of another pod') | |
11474c3c C |
477 | |
478 | it('Should succeed with the correct parameters', async function () { | |
479 | const fields = getCompleteVideoUpdateAttributes() | |
480 | ||
481 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 }) | |
482 | }) | |
0e1dc3e7 C |
483 | }) |
484 | ||
485 | describe('When getting a video', function () { | |
486 | it('Should return the list of the videos with nothing', async function () { | |
487 | const res = await request(server.url) | |
488 | .get(path) | |
489 | .set('Accept', 'application/json') | |
490 | .expect(200) | |
491 | .expect('Content-Type', /json/) | |
492 | ||
493 | expect(res.body.data).to.be.an('array') | |
494 | expect(res.body.data.length).to.equal(3) | |
495 | }) | |
496 | ||
497 | it('Should fail without a correct uuid', async function () { | |
498 | await request(server.url) | |
499 | .get(path + 'coucou') | |
500 | .set('Accept', 'application/json') | |
501 | .expect(400) | |
502 | }) | |
503 | ||
504 | it('Should return 404 with an incorrect video', async function () { | |
505 | await request(server.url) | |
506 | .get(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
507 | .set('Accept', 'application/json') | |
508 | .expect(404) | |
509 | }) | |
510 | ||
511 | it('Should succeed with the correct parameters') | |
512 | }) | |
513 | ||
514 | describe('When rating a video', function () { | |
515 | let videoId | |
516 | ||
517 | before(async function () { | |
518 | const res = await getVideosList(server.url) | |
519 | videoId = res.body.data[0].id | |
520 | }) | |
521 | ||
522 | it('Should fail without a valid uuid', async function () { | |
523 | const fields = { | |
524 | rating: 'like' | |
525 | } | |
526 | await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields }) | |
527 | }) | |
528 | ||
529 | it('Should fail with an unknown id', async function () { | |
530 | const fields = { | |
531 | rating: 'like' | |
532 | } | |
533 | await makePutBodyRequest({ | |
534 | url: server.url, | |
535 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', | |
536 | token: server.accessToken, | |
537 | fields, | |
538 | statusCodeExpected: 404 | |
539 | }) | |
540 | }) | |
541 | ||
542 | it('Should fail with a wrong rating', async function () { | |
543 | const fields = { | |
544 | rating: 'likes' | |
545 | } | |
546 | await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields }) | |
547 | }) | |
548 | ||
549 | it('Should succeed with the correct parameters', async function () { | |
550 | const fields = { | |
551 | rating: 'like' | |
552 | } | |
553 | await makePutBodyRequest({ | |
554 | url: server.url, | |
555 | path: path + videoId + '/rate', | |
556 | token: server.accessToken, | |
557 | fields, | |
558 | statusCodeExpected: 204 | |
559 | }) | |
560 | }) | |
561 | }) | |
562 | ||
563 | describe('When removing a video', function () { | |
564 | it('Should have 404 with nothing', async function () { | |
565 | await request(server.url) | |
566 | .delete(path) | |
567 | .set('Authorization', 'Bearer ' + server.accessToken) | |
568 | .expect(400) | |
569 | }) | |
570 | ||
571 | it('Should fail without a correct uuid', async function () { | |
572 | await request(server.url) | |
573 | .delete(path + 'hello') | |
574 | .set('Authorization', 'Bearer ' + server.accessToken) | |
575 | .expect(400) | |
576 | }) | |
577 | ||
578 | it('Should fail with a video which does not exist', async function () { | |
579 | await request(server.url) | |
580 | .delete(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
581 | .set('Authorization', 'Bearer ' + server.accessToken) | |
582 | .expect(404) | |
583 | }) | |
584 | ||
585 | it('Should fail with a video of another user') | |
586 | ||
587 | it('Should fail with a video of another pod') | |
588 | ||
589 | it('Should succeed with the correct parameters') | |
590 | }) | |
591 | ||
592 | after(async function () { | |
593 | killallServers([ server ]) | |
594 | ||
595 | // Keep the logs if the test failed | |
596 | if (this['ok']) { | |
597 | await flushTests() | |
598 | } | |
599 | }) | |
600 | }) |