From af971e06c620bd46a5aa64c8833364e7022b5e3d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:22:51 +0200 Subject: Introduce search command --- server/tests/api/search/search-videos.ts | 211 +++++++++++++++++-------------- 1 file changed, 118 insertions(+), 93 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 5b8907961..f0482c7e0 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -4,12 +4,11 @@ import 'mocha' import * as chai from 'chai' import { VideoPrivacy } from '@shared/models' import { - advancedVideosSearch, cleanupTests, createLive, flushAndRunServer, immutableAssign, - searchVideo, + SearchCommand, sendRTMPStreamInVideo, ServerInfo, setAccessTokensToServers, @@ -29,6 +28,8 @@ describe('Test videos search', function () { let startDate: string let videoUUID: string + let command: SearchCommand + before(async function () { this.timeout(60000) @@ -144,21 +145,23 @@ describe('Test videos search', function () { await uploadVideo(server.url, server.accessToken, attributes1) await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) } + + command = server.searchCommand }) it('Should make a simple search and not have results', async function () { - const res = await searchVideo(server.url, 'abc') + const body = await command.searchVideos({ search: 'abc' }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) it('Should make a simple search and have results', async function () { - const res = await searchVideo(server.url, '4444 5555 duplicate') + const body = await command.searchVideos({ search: '4444 5555 duplicate' }) - expect(res.body.total).to.equal(2) + expect(body.total).to.equal(2) - const videos = res.body.data + const videos = body.data expect(videos).to.have.lengthOf(2) // bestmatch @@ -167,15 +170,15 @@ describe('Test videos search', function () { }) it('Should make a search on tags too, and have results', async function () { - const query = { + const search = { search: 'aaaa', categoryOneOf: [ 1 ] } - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search }) - expect(res.body.total).to.equal(2) + expect(body.total).to.equal(2) - const videos = res.body.data + const videos = body.data expect(videos).to.have.lengthOf(2) // bestmatch @@ -184,14 +187,14 @@ describe('Test videos search', function () { }) it('Should filter on tags without a search', async function () { - const query = { + const search = { tagsAllOf: [ 'bbbb' ] } - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search }) - expect(res.body.total).to.equal(2) + expect(body.total).to.equal(2) - const videos = res.body.data + const videos = body.data expect(videos).to.have.lengthOf(2) expect(videos[0].name).to.equal('9999') @@ -199,14 +202,14 @@ describe('Test videos search', function () { }) it('Should filter on category without a search', async function () { - const query = { + const search = { categoryOneOf: [ 3 ] } - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: search }) - expect(res.body.total).to.equal(1) + expect(body.total).to.equal(1) - const videos = res.body.data + const videos = body.data expect(videos).to.have.lengthOf(1) expect(videos[0].name).to.equal('6666 7777 8888') @@ -218,11 +221,16 @@ describe('Test videos search', function () { categoryOneOf: [ 1 ], tagsOneOf: [ 'aAaa', 'ffff' ] } - const res1 = await advancedVideosSearch(server.url, query) - expect(res1.body.total).to.equal(2) - const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsOneOf: [ 'blabla' ] })) - expect(res2.body.total).to.equal(0) + { + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(2) + } + + { + const body = await command.advancedVideoSearch({ search: { ...query, tagsOneOf: [ 'blabla' ] } }) + expect(body.total).to.equal(0) + } }) it('Should search by tags (all of)', async function () { @@ -231,14 +239,21 @@ describe('Test videos search', function () { categoryOneOf: [ 1 ], tagsAllOf: [ 'CCcc' ] } - const res1 = await advancedVideosSearch(server.url, query) - expect(res1.body.total).to.equal(2) - const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blAbla' ] })) - expect(res2.body.total).to.equal(0) + { + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(2) + } - const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'CCCC' ] })) - expect(res3.body.total).to.equal(1) + { + const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'blAbla' ] } }) + expect(body.total).to.equal(0) + } + + { + const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'bbbb', 'CCCC' ] } }) + expect(body.total).to.equal(1) + } }) it('Should search by category', async function () { @@ -246,12 +261,17 @@ describe('Test videos search', function () { search: '6666', categoryOneOf: [ 3 ] } - const res1 = await advancedVideosSearch(server.url, query) - expect(res1.body.total).to.equal(1) - expect(res1.body.data[0].name).to.equal('6666 7777 8888') - const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { categoryOneOf: [ 2 ] })) - expect(res2.body.total).to.equal(0) + { + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('6666 7777 8888') + } + + { + const body = await command.advancedVideoSearch({ search: { ...query, categoryOneOf: [ 2 ] } }) + expect(body.total).to.equal(0) + } }) it('Should search by licence', async function () { @@ -259,13 +279,18 @@ describe('Test videos search', function () { search: '4444 5555', licenceOneOf: [ 2 ] } - const res1 = await advancedVideosSearch(server.url, query) - expect(res1.body.total).to.equal(2) - expect(res1.body.data[0].name).to.equal('3333 4444 5555') - expect(res1.body.data[1].name).to.equal('3333 4444 5555 duplicate') - const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { licenceOneOf: [ 3 ] })) - expect(res2.body.total).to.equal(0) + { + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(2) + expect(body.data[0].name).to.equal('3333 4444 5555') + expect(body.data[1].name).to.equal('3333 4444 5555 duplicate') + } + + { + const body = await command.advancedVideoSearch({ search: { ...query, licenceOneOf: [ 3 ] } }) + expect(body.total).to.equal(0) + } }) it('Should search by languages', async function () { @@ -275,23 +300,23 @@ describe('Test videos search', function () { } { - 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 body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(2) + expect(body.data[0].name).to.equal('1111 2222 3333 - 3') + expect(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 body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'pl', 'en', '_unknown' ] } }) + expect(body.total).to.equal(3) + expect(body.data[0].name).to.equal('1111 2222 3333 - 3') + expect(body.data[1].name).to.equal('1111 2222 3333 - 4') + expect(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) + const body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'eo' ] } }) + expect(body.total).to.equal(0) } }) @@ -301,10 +326,10 @@ describe('Test videos search', function () { startDate } - const res = await advancedVideosSearch(server.url, query) - expect(res.body.total).to.equal(4) + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(4) - const videos = res.body.data + const videos = body.data expect(videos[0].name).to.equal('1111 2222 3333 - 5') expect(videos[1].name).to.equal('1111 2222 3333 - 6') expect(videos[2].name).to.equal('1111 2222 3333 - 7') @@ -320,10 +345,10 @@ describe('Test videos search', function () { licenceOneOf: [ 1, 4 ] } - const res = await advancedVideosSearch(server.url, query) - expect(res.body.total).to.equal(4) + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(4) - const videos = res.body.data + const videos = body.data expect(videos[0].name).to.equal('1111 2222 3333') expect(videos[1].name).to.equal('1111 2222 3333 - 6') expect(videos[2].name).to.equal('1111 2222 3333 - 7') @@ -340,10 +365,10 @@ describe('Test videos search', function () { sort: '-name' } - const res = await advancedVideosSearch(server.url, query) - expect(res.body.total).to.equal(4) + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(4) - const videos = res.body.data + const videos = body.data expect(videos[0].name).to.equal('1111 2222 3333 - 8') expect(videos[1].name).to.equal('1111 2222 3333 - 7') expect(videos[2].name).to.equal('1111 2222 3333 - 6') @@ -362,10 +387,10 @@ describe('Test videos search', function () { count: 1 } - const res = await advancedVideosSearch(server.url, query) - expect(res.body.total).to.equal(4) + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(4) - const videos = res.body.data + const videos = body.data expect(videos[0].name).to.equal('1111 2222 3333 - 8') }) @@ -381,10 +406,10 @@ describe('Test videos search', function () { count: 1 } - const res = await advancedVideosSearch(server.url, query) - expect(res.body.total).to.equal(4) + const body = await command.advancedVideoSearch({ search: query }) + expect(body.total).to.equal(4) - const videos = res.body.data + const videos = body.data expect(videos[0].name).to.equal('1111 2222 3333') }) @@ -399,32 +424,32 @@ describe('Test videos search', function () { { const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('1111 2222 3333 - 7') } { const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('1111 2222 3333 - 7') } { const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(0) + expect(body.total).to.equal(0) } { const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(0) + expect(body.total).to.equal(0) } { @@ -432,9 +457,9 @@ describe('Test videos search', function () { originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(0) + expect(body.total).to.equal(0) } { @@ -442,19 +467,19 @@ describe('Test videos search', function () { originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' }) - const res = await advancedVideosSearch(server.url, query) + const body = await command.advancedVideoSearch({ search: query }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('1111 2222 3333 - 7') } }) it('Should search by UUID', async function () { const search = videoUUID - const res = await advancedVideosSearch(server.url, { search }) + const body = await command.advancedVideoSearch({ search: { search } }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('1111 2222 3333 - 3') }) it('Should search by live', async function () { @@ -471,10 +496,10 @@ describe('Test videos search', function () { } { - const res = await advancedVideosSearch(server.url, { isLive: true }) + const body = await command.advancedVideoSearch({ search: { isLive: true } }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) } { @@ -482,15 +507,15 @@ describe('Test videos search', function () { const resLive = await createLive(server.url, server.accessToken, liveOptions) const liveVideoId = resLive.body.video.uuid - const command = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) + const ffmpegCommand = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) await waitUntilLivePublished(server.url, server.accessToken, liveVideoId) - const res = await advancedVideosSearch(server.url, { isLive: true }) + const body = await command.advancedVideoSearch({ search: { isLive: true } }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('live') + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('live') - await stopFfmpeg(command) + await stopFfmpeg(ffmpegCommand) } }) -- cgit v1.2.3 From 65e6e2602c0d5521f3a6740f7469bb92830ecb53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:51:09 +0200 Subject: Introduce config command --- server/tests/api/search/search-videos.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index f0482c7e0..7dc89c447 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -14,7 +14,6 @@ import { setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, - updateCustomSubConfig, uploadVideo, wait, waitUntilLivePublished @@ -486,13 +485,13 @@ describe('Test videos search', function () { this.timeout(30000) { - const options = { + const newConfig = { search: { searchIndex: { enabled: false } }, live: { enabled: true } } - await updateCustomSubConfig(server.url, server.accessToken, options) + await server.configCommand.updateCustomSubConfig({ newConfig }) } { -- cgit v1.2.3 From 4f2199144e428c16460750305f737b890c1ac322 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 10:18:40 +0200 Subject: Introduce live command --- server/tests/api/search/search-videos.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 7dc89c447..af74b26a7 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -2,23 +2,20 @@ import 'mocha' import * as chai from 'chai' -import { VideoPrivacy } from '@shared/models' import { cleanupTests, - createLive, + createVideoCaption, flushAndRunServer, immutableAssign, SearchCommand, - sendRTMPStreamInVideo, ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, uploadVideo, - wait, - waitUntilLivePublished -} from '../../../../shared/extra-utils' -import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' + wait +} from '@shared/extra-utils' +import { VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -502,12 +499,13 @@ describe('Test videos search', function () { } { - const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } - const resLive = await createLive(server.url, server.accessToken, liveOptions) - const liveVideoId = resLive.body.video.uuid + const liveCommand = server.liveCommand + + const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } + const live = await liveCommand.createLive({ fields: liveAttributes }) - const ffmpegCommand = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) - await waitUntilLivePublished(server.url, server.accessToken, liveVideoId) + const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id }) + await liveCommand.waitUntilLivePublished({ videoId: live.id }) const body = await command.advancedVideoSearch({ search: { isLive: true } }) -- cgit v1.2.3 From 04aed76711909507e74905bde3a7fa024d3585c9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 10:25:50 +0200 Subject: Shorter live methods --- server/tests/api/search/search-videos.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index af74b26a7..a0375fbf0 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -502,10 +502,10 @@ describe('Test videos search', function () { const liveCommand = server.liveCommand const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } - const live = await liveCommand.createLive({ fields: liveAttributes }) + const live = await liveCommand.create({ fields: liveAttributes }) const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id }) - await liveCommand.waitUntilLivePublished({ videoId: live.id }) + await liveCommand.waitUntilPublished({ videoId: live.id }) const body = await command.advancedVideoSearch({ search: { isLive: true } }) -- cgit v1.2.3 From a2470c9f4bfc7f49f4b94de935bacdd53fd54f29 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 11:49:38 +0200 Subject: Introduce captions command --- server/tests/api/search/search-videos.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index a0375fbf0..513538917 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -4,7 +4,6 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - createVideoCaption, flushAndRunServer, immutableAssign, SearchCommand, @@ -54,18 +53,14 @@ describe('Test videos search', function () { const videoId = res.body.video.id videoUUID = res.body.video.uuid - await createVideoCaption({ - url: server.url, - accessToken: server.accessToken, + await server.captionsCommand.createVideoCaption({ language: 'en', videoId, fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }) - await createVideoCaption({ - url: server.url, - accessToken: server.accessToken, + await server.captionsCommand.createVideoCaption({ language: 'aa', videoId, fixture: 'subtitle-good2.vtt', -- cgit v1.2.3 From 6c5065a011b099618681a37bd77eaa7bd3db752e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 09:43:59 +0200 Subject: Introduce server commands --- server/tests/api/search/search-videos.ts | 46 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 513538917..66f5f3182 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -5,7 +5,6 @@ import * as chai from 'chai' import { cleanupTests, flushAndRunServer, - immutableAssign, SearchCommand, ServerInfo, setAccessTokensToServers, @@ -44,11 +43,11 @@ describe('Test videos search', function () { } await uploadVideo(server.url, server.accessToken, attributes1) - const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) + const attributes2 = { ...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: undefined }) + const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } const res = await uploadVideo(server.url, server.accessToken, attributes3) const videoId = res.body.video.id videoUUID = res.body.video.uuid @@ -68,26 +67,23 @@ describe('Test videos search', function () { }) } - const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) + const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } await uploadVideo(server.url, server.accessToken, attributes4) await wait(1000) startDate = new Date().toISOString() - const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) + const attributes5 = { ...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' ] }) + const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } await uploadVideo(server.url, server.accessToken, attributes6) - const attributes7 = immutableAssign(attributes1, { - name: attributes1.name + ' - 7', - originallyPublishedAt: '2019-02-12T09:58:08.286Z' - }) + const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } await uploadVideo(server.url, server.accessToken, attributes7) - const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) + const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } await uploadVideo(server.url, server.accessToken, attributes8) } @@ -101,7 +97,7 @@ describe('Test videos search', function () { } await uploadVideo(server.url, server.accessToken, attributes) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' })) + await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' }) } { @@ -122,10 +118,10 @@ describe('Test videos search', function () { category: 1 } await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] }) + await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] }) } { @@ -134,7 +130,7 @@ describe('Test videos search', function () { category: 1 } await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) } command = server.searchCommand @@ -414,7 +410,7 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) @@ -422,7 +418,7 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) @@ -430,34 +426,36 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { + const query = { + ...baseQuery, originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' - }) + } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { + const query = { + ...baseQuery, originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' - }) + } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/api/search/search-videos.ts | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 66f5f3182..148499d5f 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -10,7 +10,6 @@ import { setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, - uploadVideo, wait } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' @@ -41,50 +40,49 @@ describe('Test videos search', function () { nsfw: false, language: 'fr' } - await uploadVideo(server.url, server.accessToken, attributes1) + await server.videosCommand.upload({ attributes: attributes1 }) const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } - await uploadVideo(server.url, server.accessToken, attributes2) + await server.videosCommand.upload({ attributes: attributes2 }) { const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } - const res = await uploadVideo(server.url, server.accessToken, attributes3) - const videoId = res.body.video.id - videoUUID = res.body.video.uuid + const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 }) + videoUUID = uuid await server.captionsCommand.createVideoCaption({ language: 'en', - videoId, + videoId: id, fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }) await server.captionsCommand.createVideoCaption({ language: 'aa', - videoId, + videoId: id, fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }) } const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } - await uploadVideo(server.url, server.accessToken, attributes4) + await server.videosCommand.upload({ attributes: attributes4 }) await wait(1000) startDate = new Date().toISOString() const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } - await uploadVideo(server.url, server.accessToken, attributes5) + await server.videosCommand.upload({ attributes: attributes5 }) const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } - await uploadVideo(server.url, server.accessToken, attributes6) + await server.videosCommand.upload({ attributes: attributes6 }) const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } - await uploadVideo(server.url, server.accessToken, attributes7) + await server.videosCommand.upload({ attributes: attributes7 }) const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } - await uploadVideo(server.url, server.accessToken, attributes8) + await server.videosCommand.upload({ attributes: attributes8 }) } { @@ -95,9 +93,9 @@ describe('Test videos search', function () { licence: 2, language: 'en' } - await uploadVideo(server.url, server.accessToken, attributes) + await server.videosCommand.upload({ attributes: attributes }) - await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' }) + await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } }) } { @@ -108,7 +106,7 @@ describe('Test videos search', function () { licence: 3, language: 'pl' } - await uploadVideo(server.url, server.accessToken, attributes) + await server.videosCommand.upload({ attributes: attributes }) } { @@ -117,11 +115,11 @@ describe('Test videos search', function () { tags: [ 'aaaa', 'bbbb', 'cccc' ], category: 1 } - await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) + await server.videosCommand.upload({ attributes: attributes1 }) + await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) - await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] }) - await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] }) + await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } }) + await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } }) } { @@ -129,8 +127,8 @@ describe('Test videos search', function () { name: 'aaaa 2', category: 1 } - await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) + await server.videosCommand.upload({ attributes: attributes1 }) + await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) } command = server.searchCommand -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/search/search-videos.ts | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 148499d5f..478ebafc9 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -40,24 +40,24 @@ describe('Test videos search', function () { nsfw: false, language: 'fr' } - await server.videosCommand.upload({ attributes: attributes1 }) + await server.videos.upload({ attributes: attributes1 }) const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } - await server.videosCommand.upload({ attributes: attributes2 }) + await server.videos.upload({ attributes: attributes2 }) { const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } - const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 }) + const { id, uuid } = await server.videos.upload({ attributes: attributes3 }) videoUUID = uuid - await server.captionsCommand.createVideoCaption({ + await server.captions.createVideoCaption({ language: 'en', videoId: id, fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }) - await server.captionsCommand.createVideoCaption({ + await server.captions.createVideoCaption({ language: 'aa', videoId: id, fixture: 'subtitle-good2.vtt', @@ -66,23 +66,23 @@ describe('Test videos search', function () { } const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } - await server.videosCommand.upload({ attributes: attributes4 }) + await server.videos.upload({ attributes: attributes4 }) await wait(1000) startDate = new Date().toISOString() const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } - await server.videosCommand.upload({ attributes: attributes5 }) + await server.videos.upload({ attributes: attributes5 }) const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } - await server.videosCommand.upload({ attributes: attributes6 }) + await server.videos.upload({ attributes: attributes6 }) const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } - await server.videosCommand.upload({ attributes: attributes7 }) + await server.videos.upload({ attributes: attributes7 }) const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } - await server.videosCommand.upload({ attributes: attributes8 }) + await server.videos.upload({ attributes: attributes8 }) } { @@ -93,9 +93,9 @@ describe('Test videos search', function () { licence: 2, language: 'en' } - await server.videosCommand.upload({ attributes: attributes }) + await server.videos.upload({ attributes: attributes }) - await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } }) + await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } }) } { @@ -106,7 +106,7 @@ describe('Test videos search', function () { licence: 3, language: 'pl' } - await server.videosCommand.upload({ attributes: attributes }) + await server.videos.upload({ attributes: attributes }) } { @@ -115,11 +115,11 @@ describe('Test videos search', function () { tags: [ 'aaaa', 'bbbb', 'cccc' ], category: 1 } - await server.videosCommand.upload({ attributes: attributes1 }) - await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) + await server.videos.upload({ attributes: attributes1 }) + await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) - await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } }) - await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } }) + await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } }) + await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } }) } { @@ -127,11 +127,11 @@ describe('Test videos search', function () { name: 'aaaa 2', category: 1 } - await server.videosCommand.upload({ attributes: attributes1 }) - await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) + await server.videos.upload({ attributes: attributes1 }) + await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) } - command = server.searchCommand + command = server.search }) it('Should make a simple search and not have results', async function () { @@ -479,7 +479,7 @@ describe('Test videos search', function () { }, live: { enabled: true } } - await server.configCommand.updateCustomSubConfig({ newConfig }) + await server.config.updateCustomSubConfig({ newConfig }) } { @@ -490,9 +490,9 @@ describe('Test videos search', function () { } { - const liveCommand = server.liveCommand + const liveCommand = server.live - const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } + const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id } const live = await liveCommand.create({ fields: liveAttributes }) const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id }) -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/search/search-videos.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 478ebafc9..a9b0a4fcd 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -4,9 +4,9 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, SearchCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, @@ -17,7 +17,7 @@ import { VideoPrivacy } from '@shared/models' const expect = chai.expect describe('Test videos search', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null let startDate: string let videoUUID: string @@ -26,7 +26,7 @@ describe('Test videos search', function () { before(async function () { this.timeout(60000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/search/search-videos.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index a9b0a4fcd..f834c7f36 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, createSingleServer, - SearchCommand, PeerTubeServer, + SearchCommand, setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, -- cgit v1.2.3 From c63830f15403ac4e750829f27d8bbbdc9a59282c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Jul 2021 13:58:35 +0200 Subject: Rename captions commands --- server/tests/api/search/search-videos.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/search/search-videos.ts') diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index f834c7f36..965766742 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -50,14 +50,14 @@ describe('Test videos search', function () { const { id, uuid } = await server.videos.upload({ attributes: attributes3 }) videoUUID = uuid - await server.captions.createVideoCaption({ + await server.captions.add({ language: 'en', videoId: id, fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }) - await server.captions.createVideoCaption({ + await server.captions.add({ language: 'aa', videoId: id, fixture: 'subtitle-good2.vtt', -- cgit v1.2.3