diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/users.ts | 23 | ||||
-rw-r--r-- | server/tests/api/search/search-videos.ts | 53 |
2 files changed, 67 insertions, 9 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 2316033a1..5d62fe2b3 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -364,6 +364,29 @@ describe('Test users API validators', function () { | |||
364 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | 364 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) |
365 | }) | 365 | }) |
366 | 366 | ||
367 | it('Should fail with an invalid videoLanguages attribute', async function () { | ||
368 | { | ||
369 | const fields = { | ||
370 | videoLanguages: 'toto' | ||
371 | } | ||
372 | |||
373 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | ||
374 | } | ||
375 | |||
376 | { | ||
377 | const languages = [] | ||
378 | for (let i = 0; i < 1000; i++) { | ||
379 | languages.push('fr') | ||
380 | } | ||
381 | |||
382 | const fields = { | ||
383 | videoLanguages: languages | ||
384 | } | ||
385 | |||
386 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | ||
387 | } | ||
388 | }) | ||
389 | |||
367 | it('Should succeed to change password with the correct params', async function () { | 390 | it('Should succeed to change password with the correct params', async function () { |
368 | const fields = { | 391 | const fields = { |
369 | currentPassword: 'my super password', | 392 | currentPassword: 'my super password', |
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 92cc0dc71..c06200ffe 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -13,6 +13,7 @@ import { | |||
13 | uploadVideo, | 13 | uploadVideo, |
14 | wait | 14 | wait |
15 | } from '../../../../shared/extra-utils' | 15 | } from '../../../../shared/extra-utils' |
16 | import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' | ||
16 | 17 | ||
17 | const expect = chai.expect | 18 | const expect = chai.expect |
18 | 19 | ||
@@ -41,8 +42,29 @@ describe('Test videos search', function () { | |||
41 | const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) | 42 | const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) |
42 | await uploadVideo(server.url, server.accessToken, attributes2) | 43 | await uploadVideo(server.url, server.accessToken, attributes2) |
43 | 44 | ||
44 | const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: 'en' }) | 45 | { |
45 | await uploadVideo(server.url, server.accessToken, attributes3) | 46 | const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) |
47 | const res = await uploadVideo(server.url, server.accessToken, attributes3) | ||
48 | const videoId = res.body.video.id | ||
49 | |||
50 | await createVideoCaption({ | ||
51 | url: server.url, | ||
52 | accessToken: server.accessToken, | ||
53 | language: 'en', | ||
54 | videoId, | ||
55 | fixture: 'subtitle-good2.vtt', | ||
56 | mimeType: 'application/octet-stream' | ||
57 | }) | ||
58 | |||
59 | await createVideoCaption({ | ||
60 | url: server.url, | ||
61 | accessToken: server.accessToken, | ||
62 | language: 'aa', | ||
63 | videoId, | ||
64 | fixture: 'subtitle-good2.vtt', | ||
65 | mimeType: 'application/octet-stream' | ||
66 | }) | ||
67 | } | ||
46 | 68 | ||
47 | const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) | 69 | const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) |
48 | await uploadVideo(server.url, server.accessToken, attributes4) | 70 | await uploadVideo(server.url, server.accessToken, attributes4) |
@@ -51,7 +73,7 @@ describe('Test videos search', function () { | |||
51 | 73 | ||
52 | startDate = new Date().toISOString() | 74 | startDate = new Date().toISOString() |
53 | 75 | ||
54 | const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2 }) | 76 | const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) |
55 | await uploadVideo(server.url, server.accessToken, attributes5) | 77 | await uploadVideo(server.url, server.accessToken, attributes5) |
56 | 78 | ||
57 | const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] }) | 79 | const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] }) |
@@ -241,13 +263,26 @@ describe('Test videos search', function () { | |||
241 | search: '1111 2222 3333', | 263 | search: '1111 2222 3333', |
242 | languageOneOf: [ 'pl', 'en' ] | 264 | languageOneOf: [ 'pl', 'en' ] |
243 | } | 265 | } |
244 | const res1 = await advancedVideosSearch(server.url, query) | ||
245 | expect(res1.body.total).to.equal(2) | ||
246 | expect(res1.body.data[0].name).to.equal('1111 2222 3333 - 3') | ||
247 | expect(res1.body.data[1].name).to.equal('1111 2222 3333 - 4') | ||
248 | 266 | ||
249 | const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'eo' ] })) | 267 | { |
250 | expect(res2.body.total).to.equal(0) | 268 | const res = await advancedVideosSearch(server.url, query) |
269 | expect(res.body.total).to.equal(2) | ||
270 | expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3') | ||
271 | expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4') | ||
272 | } | ||
273 | |||
274 | { | ||
275 | const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'pl', 'en', '_unknown' ] })) | ||
276 | expect(res.body.total).to.equal(3) | ||
277 | expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3') | ||
278 | expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4') | ||
279 | expect(res.body.data[ 2 ].name).to.equal('1111 2222 3333 - 5') | ||
280 | } | ||
281 | |||
282 | { | ||
283 | const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'eo' ] })) | ||
284 | expect(res.body.total).to.equal(0) | ||
285 | } | ||
251 | }) | 286 | }) |
252 | 287 | ||
253 | it('Should search by start date', async function () { | 288 | it('Should search by start date', async function () { |