From 3caf77d3b11f2dbc12e52d665183d36604c1dab9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Jun 2019 14:55:58 +0200 Subject: Add language filters in user preferences --- server/tests/api/check-params/users.ts | 23 ++++++++++++++ server/tests/api/search/search-videos.ts | 53 ++++++++++++++++++++++++++------ 2 files changed, 67 insertions(+), 9 deletions(-) (limited to 'server/tests') 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 () { await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) }) + it('Should fail with an invalid videoLanguages attribute', async function () { + { + const fields = { + videoLanguages: 'toto' + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + } + + { + const languages = [] + for (let i = 0; i < 1000; i++) { + languages.push('fr') + } + + const fields = { + videoLanguages: languages + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + } + }) + it('Should succeed to change password with the correct params', async function () { const fields = { 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 { uploadVideo, wait } from '../../../../shared/extra-utils' +import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' const expect = chai.expect @@ -41,8 +42,29 @@ describe('Test videos search', function () { const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) await uploadVideo(server.url, server.accessToken, attributes2) - const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: 'en' }) - await uploadVideo(server.url, server.accessToken, attributes3) + { + const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) + const res = await uploadVideo(server.url, server.accessToken, attributes3) + const videoId = res.body.video.id + + await createVideoCaption({ + url: server.url, + accessToken: server.accessToken, + language: 'en', + videoId, + fixture: 'subtitle-good2.vtt', + mimeType: 'application/octet-stream' + }) + + await createVideoCaption({ + url: server.url, + accessToken: server.accessToken, + language: 'aa', + videoId, + fixture: 'subtitle-good2.vtt', + mimeType: 'application/octet-stream' + }) + } const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) await uploadVideo(server.url, server.accessToken, attributes4) @@ -51,7 +73,7 @@ describe('Test videos search', function () { startDate = new Date().toISOString() - const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2 }) + const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) await uploadVideo(server.url, server.accessToken, attributes5) const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] }) @@ -241,13 +263,26 @@ describe('Test videos search', function () { search: '1111 2222 3333', languageOneOf: [ 'pl', 'en' ] } - const res1 = await advancedVideosSearch(server.url, query) - expect(res1.body.total).to.equal(2) - expect(res1.body.data[0].name).to.equal('1111 2222 3333 - 3') - expect(res1.body.data[1].name).to.equal('1111 2222 3333 - 4') - const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'eo' ] })) - expect(res2.body.total).to.equal(0) + { + const res = await advancedVideosSearch(server.url, query) + expect(res.body.total).to.equal(2) + expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3') + expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4') + } + + { + const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'pl', 'en', '_unknown' ] })) + expect(res.body.total).to.equal(3) + expect(res.body.data[ 0 ].name).to.equal('1111 2222 3333 - 3') + expect(res.body.data[ 1 ].name).to.equal('1111 2222 3333 - 4') + expect(res.body.data[ 2 ].name).to.equal('1111 2222 3333 - 5') + } + + { + const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'eo' ] })) + expect(res.body.total).to.equal(0) + } }) it('Should search by start date', async function () { -- cgit v1.2.3