From af971e06c620bd46a5aa64c8833364e7022b5e3d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:22:51 +0200 Subject: Introduce search command --- .../search/search-activitypub-video-channels.ts | 83 ++++---- .../search/search-activitypub-video-playlists.ts | 84 ++++---- .../tests/api/search/search-activitypub-videos.ts | 81 ++++---- server/tests/api/search/search-channels.ts | 29 +-- server/tests/api/search/search-index.ts | 129 +++++++------ server/tests/api/search/search-playlists.ts | 36 ++-- server/tests/api/search/search-videos.ts | 211 ++++++++++++--------- 7 files changed, 345 insertions(+), 308 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index e83eb7171..cf5158b66 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' import { addVideoChannel, cleanupTests, @@ -10,6 +10,7 @@ import { flushAndRunMultipleServers, getVideoChannelsList, getVideoChannelVideos, + SearchCommand, ServerInfo, setAccessTokensToServers, updateMyUser, @@ -17,11 +18,10 @@ import { updateVideoChannel, uploadVideo, userLogin, - wait -} from '../../../../shared/extra-utils' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { VideoChannel } from '../../../../shared/models/videos' -import { searchVideoChannel } from '../../../../shared/extra-utils/search/video-channels' + wait, + waitJobs +} from '@shared/extra-utils' +import { VideoChannel } from '@shared/models' const expect = chai.expect @@ -30,6 +30,7 @@ describe('Test ActivityPub video channels search', function () { let userServer2Token: string let videoServer2UUID: string let channelIdServer2: number + let command: SearchCommand before(async function () { this.timeout(120000) @@ -64,6 +65,8 @@ describe('Test ActivityPub video channels search', function () { } await waitJobs(servers) + + command = servers[0].searchCommand }) it('Should not find a remote video channel', async function () { @@ -71,21 +74,21 @@ describe('Test ActivityPub video channels search', function () { { const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3' - const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) + const body = await command.searchChannels({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { // Without token const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' - const res = await searchVideoChannel(servers[0].url, search) + const body = await command.searchChannels({ search }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } }) @@ -96,13 +99,13 @@ describe('Test ActivityPub video channels search', function () { ] for (const search of searches) { - const res = await searchVideoChannel(servers[0].url, search) + const body = await command.searchChannels({ search }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('channel1_server1') - expect(res.body.data[0].displayName).to.equal('Channel 1 server 1') + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('channel1_server1') + expect(body.data[0].displayName).to.equal('Channel 1 server 1') } }) @@ -110,13 +113,13 @@ describe('Test ActivityPub video channels search', function () { const search = 'http://localhost:' + servers[0].port + '/c/channel1_server1' for (const token of [ undefined, servers[0].accessToken ]) { - const res = await searchVideoChannel(servers[0].url, search, token) + const body = await command.searchChannels({ search, token }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('channel1_server1') - expect(res.body.data[0].displayName).to.equal('Channel 1 server 1') + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('channel1_server1') + expect(body.data[0].displayName).to.equal('Channel 1 server 1') } }) @@ -129,13 +132,13 @@ describe('Test ActivityPub video channels search', function () { ] for (const search of searches) { - const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) + const body = await command.searchChannels({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('channel1_server2') - expect(res.body.data[0].displayName).to.equal('Channel 1 server 2') + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('channel1_server2') + expect(body.data[0].displayName).to.equal('Channel 1 server 2') } }) @@ -176,11 +179,11 @@ describe('Test ActivityPub video channels search', function () { await wait(10000) const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' - const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.searchChannels({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const videoChannel: VideoChannel = res.body.data[0] + const videoChannel: VideoChannel = body.data[0] expect(videoChannel.displayName).to.equal('channel updated') // We don't return the owner account for now @@ -199,7 +202,7 @@ describe('Test ActivityPub video channels search', function () { await wait(10000) const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' - await searchVideoChannel(servers[0].url, search, servers[0].accessToken) + await command.searchChannels({ search, token: servers[0].accessToken }) await waitJobs(servers) @@ -221,9 +224,9 @@ describe('Test ActivityPub video channels search', function () { await wait(10000) const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' - const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const body = await command.searchChannels({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) after(async function () { diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 4c08e9548..1df18173a 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -9,15 +9,15 @@ import { deleteVideoPlaylist, flushAndRunMultipleServers, getVideoPlaylistsList, - searchVideoPlaylists, + SearchCommand, ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, uploadVideoAndGetId, - wait -} from '../../../../shared/extra-utils' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { VideoPlaylist, VideoPlaylistPrivacy } from '../../../../shared/models/videos' + wait, + waitJobs +} from '@shared/extra-utils' +import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect @@ -27,6 +27,8 @@ describe('Test ActivityPub playlists search', function () { let playlistServer2UUID: string let video2Server2: string + let command: SearchCommand + before(async function () { this.timeout(120000) @@ -78,38 +80,40 @@ describe('Test ActivityPub playlists search', function () { } await waitJobs(servers) + + command = servers[0].searchCommand }) it('Should not find a remote playlist', async function () { { const search = 'http://localhost:' + servers[1].port + '/video-playlists/43' - const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) + const body = await command.searchPlaylists({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { // Without token const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID - const res = await searchVideoPlaylists(servers[0].url, search) + const body = await command.searchPlaylists({ search }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } }) it('Should search a local playlist', async function () { const search = 'http://localhost:' + servers[0].port + '/video-playlists/' + playlistServer1UUID - const res = await searchVideoPlaylists(servers[0].url, search) + const body = await command.searchPlaylists({ search }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') - expect(res.body.data[0].videosLength).to.equal(2) + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].displayName).to.equal('playlist 1 on server 1') + expect(body.data[0].videosLength).to.equal(2) }) it('Should search a local playlist with an alternative URL', async function () { @@ -120,13 +124,13 @@ describe('Test ActivityPub playlists search', function () { for (const search of searches) { for (const token of [ undefined, servers[0].accessToken ]) { - const res = await searchVideoPlaylists(servers[0].url, search, token) + const body = await command.searchPlaylists({ search, token }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') - expect(res.body.data[0].videosLength).to.equal(2) + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].displayName).to.equal('playlist 1 on server 1') + expect(body.data[0].videosLength).to.equal(2) } } }) @@ -139,13 +143,13 @@ describe('Test ActivityPub playlists search', function () { ] for (const search of searches) { - const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) + const body = await command.searchPlaylists({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].displayName).to.equal('playlist 1 on server 2') - expect(res.body.data[0].videosLength).to.equal(1) + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].displayName).to.equal('playlist 1 on server 2') + expect(body.data[0].videosLength).to.equal(1) } }) @@ -172,16 +176,16 @@ describe('Test ActivityPub playlists search', function () { // Will run refresh async const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID - await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) + await command.searchPlaylists({ search, token: servers[0].accessToken }) // Wait refresh await wait(5000) - const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.searchPlaylists({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const playlist: VideoPlaylist = res.body.data[0] + const playlist = body.data[0] expect(playlist.videosLength).to.equal(2) }) @@ -196,14 +200,14 @@ describe('Test ActivityPub playlists search', function () { // Will run refresh async const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID - await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) + await command.searchPlaylists({ search, token: servers[0].accessToken }) // Wait refresh await wait(5000) - const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const body = await command.searchPlaylists({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) after(async function () { diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index e9b4978da..1a5130ce9 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -1,15 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' import { addVideoChannel, cleanupTests, flushAndRunMultipleServers, getVideosList, removeVideo, - searchVideo, - searchVideoWithToken, + SearchCommand, ServerInfo, setAccessTokensToServers, updateVideo, @@ -17,7 +16,7 @@ import { wait } from '../../../../shared/extra-utils' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { Video, VideoPrivacy } from '../../../../shared/models/videos' +import { VideoPrivacy } from '../../../../shared/models/videos' const expect = chai.expect @@ -26,6 +25,8 @@ describe('Test ActivityPub videos search', function () { let videoServer1UUID: string let videoServer2UUID: string + let command: SearchCommand + before(async function () { this.timeout(120000) @@ -44,49 +45,51 @@ describe('Test ActivityPub videos search', function () { } await waitJobs(servers) + + command = servers[0].searchCommand }) it('Should not find a remote video', async function () { { const search = 'http://localhost:' + servers[1].port + '/videos/watch/43' - const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) + const body = await command.searchVideos({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } { // Without token const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID - const res = await searchVideo(servers[0].url, search) + const body = await command.searchVideos({ search }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(0) } }) it('Should search a local video', async function () { const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID - const res = await searchVideo(servers[0].url, search) + const body = await command.searchVideos({ search }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('video 1 on server 1') + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('video 1 on server 1') }) it('Should search a local video with an alternative URL', async function () { const search = 'http://localhost:' + servers[0].port + '/w/' + videoServer1UUID - const res1 = await searchVideo(servers[0].url, search) - const res2 = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) - - for (const res of [ res1, res2 ]) { - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('video 1 on server 1') + const body1 = await command.searchVideos({ search }) + const body2 = await command.searchVideos({ search, token: servers[0].accessToken }) + + for (const body of [ body1, body2 ]) { + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('video 1 on server 1') } }) @@ -97,12 +100,12 @@ describe('Test ActivityPub videos search', function () { ] for (const search of searches) { - const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) + const body = await command.searchVideos({ search, token: servers[0].accessToken }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('video 1 on server 2') + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].name).to.equal('video 1 on server 2') } }) @@ -137,16 +140,16 @@ describe('Test ActivityPub videos search', function () { // Will run refresh async const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID - await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) + await command.searchVideos({ search, token: servers[0].accessToken }) // Wait refresh await wait(5000) - const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.searchVideos({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const video: Video = res.body.data[0] + const video = body.data[0] expect(video.name).to.equal('updated') expect(video.channel.name).to.equal('super_channel') expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) @@ -163,14 +166,14 @@ describe('Test ActivityPub videos search', function () { // Will run refresh async const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID - await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) + await command.searchVideos({ search, token: servers[0].accessToken }) // Wait refresh await wait(5000) - const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const body = await command.searchVideos({ search, token: servers[0].accessToken }) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) after(async function () { diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index daca2aebe..307bc063d 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -2,21 +2,22 @@ import 'mocha' import * as chai from 'chai' -import { searchVideoChannel, advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels' import { addVideoChannel, cleanupTests, createUser, flushAndRunServer, + SearchCommand, ServerInfo, setAccessTokensToServers -} from '../../../../shared/extra-utils' +} from '@shared/extra-utils' import { VideoChannel } from '@shared/models' const expect = chai.expect describe('Test channels search', function () { let server: ServerInfo = null + let command: SearchCommand before(async function () { this.timeout(30000) @@ -33,13 +34,15 @@ describe('Test channels search', function () { } await addVideoChannel(server.url, server.accessToken, channel) } + + command = server.searchCommand }) it('Should make a simple search and not have results', async function () { - const res = await searchVideoChannel(server.url, 'abc') + const body = await command.searchChannels({ 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 search and have results', async function () { @@ -49,11 +52,11 @@ describe('Test channels search', function () { start: 0, count: 1 } - const res = await advancedVideoChannelSearch(server.url, search) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.advancedChannelSearch({ search }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const channel: VideoChannel = res.body.data[0] + const channel: VideoChannel = body.data[0] expect(channel.name).to.equal('squall_channel') expect(channel.displayName).to.equal('Squall channel') } @@ -65,11 +68,9 @@ describe('Test channels search', function () { count: 1 } - const res = await advancedVideoChannelSearch(server.url, search) - - expect(res.body.total).to.equal(1) - - expect(res.body.data).to.have.lengthOf(0) + const body = await command.advancedChannelSearch({ search }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(0) } }) diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index 00f79232a..b2c0857a7 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,28 +2,26 @@ import 'mocha' import * as chai from 'chai' -import { advancedVideoChannelSearch, searchVideoChannel } from '@shared/extra-utils/search/video-channels' -import { Video, VideoChannel, VideoPlaylist, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' import { - advancedVideoPlaylistSearch, - advancedVideosSearch, cleanupTests, flushAndRunServer, immutableAssign, - searchVideo, - searchVideoPlaylists, + SearchCommand, ServerInfo, setAccessTokensToServers, updateCustomSubConfig, uploadVideo -} from '../../../../shared/extra-utils' +} from '@shared/extra-utils' +import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect describe('Test videos search', function () { - let server: ServerInfo = null const localVideoName = 'local video' + new Date().toISOString() + let server: ServerInfo = null + let command: SearchCommand + before(async function () { this.timeout(30000) @@ -32,6 +30,8 @@ describe('Test videos search', function () { await setAccessTokensToServers([ server ]) await uploadVideo(server.url, server.accessToken, { name: localVideoName }) + + command = server.searchCommand }) describe('Default search', async function () { @@ -49,18 +49,18 @@ describe('Test videos search', function () { } }) - const res = await searchVideo(server.url, 'local video') + const body = await command.searchVideos({ search: 'local video' }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal(localVideoName) + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal(localVideoName) }) it('Should make a local channels search by default', async function () { - const res = await searchVideoChannel(server.url, 'root') + const body = await command.searchChannels({ search: 'root' }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('root_channel') - expect(res.body.data[0].host).to.equal('localhost:' + server.port) + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('root_channel') + expect(body.data[0].host).to.equal('localhost:' + server.port) }) it('Should make an index videos search by default', async function () { @@ -74,13 +74,13 @@ describe('Test videos search', function () { } }) - const res = await searchVideo(server.url, 'local video') - expect(res.body.total).to.be.greaterThan(2) + const body = await command.searchVideos({ search: 'local video' }) + expect(body.total).to.be.greaterThan(2) }) it('Should make an index channels search by default', async function () { - const res = await searchVideoChannel(server.url, 'root') - expect(res.body.total).to.be.greaterThan(2) + const body = await command.searchChannels({ search: 'root' }) + expect(body.total).to.be.greaterThan(2) }) it('Should make an index videos search if local search is disabled', async function () { @@ -94,46 +94,46 @@ describe('Test videos search', function () { } }) - const res = await searchVideo(server.url, 'local video') - expect(res.body.total).to.be.greaterThan(2) + const body = await command.searchVideos({ search: 'local video' }) + expect(body.total).to.be.greaterThan(2) }) it('Should make an index channels search if local search is disabled', async function () { - const res = await searchVideoChannel(server.url, 'root') - expect(res.body.total).to.be.greaterThan(2) + const body = await command.searchChannels({ search: 'root' }) + expect(body.total).to.be.greaterThan(2) }) }) describe('Videos search', async function () { it('Should make a simple search and not have results', async function () { - const res = await searchVideo(server.url, 'djidane'.repeat(50)) + const body = await command.searchVideos({ search: 'djidane'.repeat(50) }) - 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, 'What is PeerTube') + const body = await command.searchVideos({ search: 'What is PeerTube' }) - expect(res.body.total).to.be.greaterThan(1) + expect(body.total).to.be.greaterThan(1) }) it('Should make a complex search', async function () { async function check (search: VideosSearchQuery, exists = true) { - const res = await advancedVideosSearch(server.url, search) + const body = await command.advancedVideoSearch({ search }) if (exists === false) { - 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) return } - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const video: Video = res.body.data[0] + const video = body.data[0] expect(video.name).to.equal('What is PeerTube?') expect(video.category.label).to.equal('Science & Technology') @@ -206,10 +206,10 @@ describe('Test videos search', function () { count: 5 } - const res = await advancedVideosSearch(server.url, search) + const body = await command.advancedVideoSearch({ search }) - expect(res.body.total).to.be.greaterThan(5) - expect(res.body.data).to.have.lengthOf(5) + expect(body.total).to.be.greaterThan(5) + expect(body.data).to.have.lengthOf(5) }) it('Should use the nsfw instance policy as default', async function () { @@ -218,10 +218,10 @@ describe('Test videos search', function () { { await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'display' } }) - const res = await searchVideo(server.url, 'NSFW search index', '-match') - const video = res.body.data[0] as Video + const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' }) + expect(body.data).to.have.length.greaterThan(0) - expect(res.body.data).to.have.length.greaterThan(0) + const video = body.data[0] expect(video.nsfw).to.be.true nsfwUUID = video.uuid @@ -230,13 +230,12 @@ describe('Test videos search', function () { { await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'do_not_list' } }) - const res = await searchVideo(server.url, 'NSFW search index', '-match') + const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' }) try { - expect(res.body.data).to.have.lengthOf(0) - } catch (err) { - // - const video = res.body.data[0] as Video + expect(body.data).to.have.lengthOf(0) + } catch { + const video = body.data[0] expect(video.uuid).not.equal(nsfwUUID) } @@ -247,19 +246,19 @@ describe('Test videos search', function () { describe('Channels search', async function () { it('Should make a simple search and not have results', async function () { - const res = await searchVideoChannel(server.url, 'a'.repeat(500)) + const body = await command.searchChannels({ search: 'a'.repeat(500) }) - 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 search and have results', async function () { - const res = await advancedVideoChannelSearch(server.url, { search: 'Framasoft', sort: 'createdAt' }) + const body = await command.advancedChannelSearch({ search: { search: 'Framasoft', sort: 'createdAt' } }) - expect(res.body.total).to.be.greaterThan(0) - expect(res.body.data).to.have.length.greaterThan(0) + expect(body.total).to.be.greaterThan(0) + expect(body.data).to.have.length.greaterThan(0) - const videoChannel: VideoChannel = res.body.data[0] + const videoChannel = body.data[0] expect(videoChannel.url).to.equal('https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8') expect(videoChannel.host).to.equal('framatube.org') expect(videoChannel.avatar).to.exist @@ -272,29 +271,29 @@ describe('Test videos search', function () { }) it('Should have a correct pagination', async function () { - const res = await advancedVideoChannelSearch(server.url, { search: 'root', start: 0, count: 2 }) + const body = await command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } }) - expect(res.body.total).to.be.greaterThan(2) - expect(res.body.data).to.have.lengthOf(2) + expect(body.total).to.be.greaterThan(2) + expect(body.data).to.have.lengthOf(2) }) }) describe('Playlists search', async function () { it('Should make a simple search and not have results', async function () { - const res = await searchVideoPlaylists(server.url, 'a'.repeat(500)) + const body = await command.searchPlaylists({ search: 'a'.repeat(500) }) - 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 search and have results', async function () { - const res = await advancedVideoPlaylistSearch(server.url, { search: 'E2E playlist', sort: '-match' }) + const body = await command.advancedPlaylistSearch({ search: { search: 'E2E playlist', sort: '-match' } }) - expect(res.body.total).to.be.greaterThan(0) - expect(res.body.data).to.have.length.greaterThan(0) + expect(body.total).to.be.greaterThan(0) + expect(body.data).to.have.length.greaterThan(0) - const videoPlaylist: VideoPlaylist = res.body.data[0] + const videoPlaylist = body.data[0] expect(videoPlaylist.url).to.equal('https://peertube2.cpy.re/videos/watch/playlist/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a') expect(videoPlaylist.thumbnailUrl).to.exist @@ -322,10 +321,10 @@ describe('Test videos search', function () { }) it('Should have a correct pagination', async function () { - const res = await advancedVideoChannelSearch(server.url, { search: 'root', start: 0, count: 2 }) + const body = await command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } }) - expect(res.body.total).to.be.greaterThan(2) - expect(res.body.data).to.have.lengthOf(2) + expect(body.total).to.be.greaterThan(2) + expect(body.data).to.have.lengthOf(2) }) }) diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index ab17d55e9..1862ecd31 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -2,14 +2,13 @@ import 'mocha' import * as chai from 'chai' -import { VideoPlaylist, VideoPlaylistPrivacy } from '@shared/models' +import { VideoPlaylistPrivacy } from '@shared/models' import { addVideoInPlaylist, - advancedVideoPlaylistSearch, cleanupTests, createVideoPlaylist, flushAndRunServer, - searchVideoPlaylists, + SearchCommand, ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, @@ -20,6 +19,7 @@ const expect = chai.expect describe('Test playlists search', function () { let server: ServerInfo = null + let command: SearchCommand before(async function () { this.timeout(30000) @@ -71,13 +71,15 @@ describe('Test playlists search', function () { } await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) } + + command = server.searchCommand }) it('Should make a simple search and not have results', async function () { - const res = await searchVideoPlaylists(server.url, 'abc') + const body = await command.searchPlaylists({ 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 search and have results', async function () { @@ -87,11 +89,11 @@ describe('Test playlists search', function () { start: 0, count: 1 } - const res = await advancedVideoPlaylistSearch(server.url, search) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.advancedPlaylistSearch({ search }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const playlist: VideoPlaylist = res.body.data[0] + const playlist = body.data[0] expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) } @@ -102,11 +104,11 @@ describe('Test playlists search', function () { start: 0, count: 1 } - const res = await advancedVideoPlaylistSearch(server.url, search) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + const body = await command.advancedPlaylistSearch({ search }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) - const playlist: VideoPlaylist = res.body.data[0] + const playlist = body.data[0] expect(playlist.displayName).to.equal('Johan & Anna Libert musics') } }) @@ -117,9 +119,9 @@ describe('Test playlists search', function () { start: 0, count: 1 } - const res = await advancedVideoPlaylistSearch(server.url, search) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const body = await command.advancedPlaylistSearch({ search }) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) after(async function () { 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 2d1ad5b96063d1e430ca99128a15e2e56cb614e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:33:39 +0200 Subject: Move AP request in requests file --- server/tests/api/search/search-activitypub-videos.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 1a5130ce9..7c6455258 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -72,7 +72,7 @@ describe('Test ActivityPub videos search', function () { it('Should search a local video', async function () { const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID - const body = await command.searchVideos({ search }) + const body = await command.searchVideos({ search }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') -- 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-index.ts | 55 ++++++++++++++++++++------------ server/tests/api/search/search-videos.ts | 5 ++- 2 files changed, 36 insertions(+), 24 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index b2c0857a7..e4c5f5796 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -9,7 +9,6 @@ import { SearchCommand, ServerInfo, setAccessTokensToServers, - updateCustomSubConfig, uploadVideo } from '@shared/extra-utils' import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' @@ -39,12 +38,14 @@ describe('Test videos search', function () { it('Should make a local videos search by default', async function () { this.timeout(10000) - await updateCustomSubConfig(server.url, server.accessToken, { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: false, - disableLocalSearch: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled: true, + isDefaultSearch: false, + disableLocalSearch: false + } } } }) @@ -64,12 +65,14 @@ describe('Test videos search', function () { }) it('Should make an index videos search by default', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: true, - disableLocalSearch: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled: true, + isDefaultSearch: true, + disableLocalSearch: false + } } } }) @@ -84,12 +87,14 @@ describe('Test videos search', function () { }) it('Should make an index videos search if local search is disabled', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: false, - disableLocalSearch: true + await server.configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled: true, + isDefaultSearch: false, + disableLocalSearch: true + } } } }) @@ -216,7 +221,11 @@ describe('Test videos search', function () { let nsfwUUID: string { - await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'display' } }) + await server.configCommand.updateCustomSubConfig({ + newConfig: { + instance: { defaultNSFWPolicy: 'display' } + } + }) const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' }) expect(body.data).to.have.length.greaterThan(0) @@ -228,7 +237,11 @@ describe('Test videos search', function () { } { - await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'do_not_list' } }) + await server.configCommand.updateCustomSubConfig({ + newConfig: { + instance: { defaultNSFWPolicy: 'do_not_list' } + } + }) const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' }) 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') 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') 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') 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 e6346d59e63135cf012ed18c102d3b0179ef565f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 15:54:39 +0200 Subject: Introduce playlist command --- .../search/search-activitypub-video-playlists.ts | 45 +++++++--------------- server/tests/api/search/search-playlists.ts | 26 ++++--------- 2 files changed, 20 insertions(+), 51 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 1df18173a..cb7582d29 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -3,12 +3,8 @@ import 'mocha' import * as chai from 'chai' import { - addVideoInPlaylist, cleanupTests, - createVideoPlaylist, - deleteVideoPlaylist, flushAndRunMultipleServers, - getVideoPlaylistsList, SearchCommand, ServerInfo, setAccessTokensToServers, @@ -46,16 +42,11 @@ describe('Test ActivityPub playlists search', function () { privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id } - const res = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs: attributes }) - playlistServer1UUID = res.body.videoPlaylist.uuid + const created = await servers[0].playlistsCommand.create({ attributes }) + playlistServer1UUID = created.uuid for (const videoId of [ video1, video2 ]) { - await addVideoInPlaylist({ - url: servers[0].url, - token: servers[0].accessToken, - playlistId: playlistServer1UUID, - elementAttrs: { videoId } - }) + await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } }) } } @@ -68,15 +59,10 @@ describe('Test ActivityPub playlists search', function () { privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } - const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs: attributes }) - playlistServer2UUID = res.body.videoPlaylist.uuid - - await addVideoInPlaylist({ - url: servers[1].url, - token: servers[1].accessToken, - playlistId: playlistServer2UUID, - elementAttrs: { videoId } - }) + const created = await servers[1].playlistsCommand.create({ attributes }) + playlistServer2UUID = created.uuid + + await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }) } await waitJobs(servers) @@ -154,21 +140,16 @@ describe('Test ActivityPub playlists search', function () { }) it('Should not list this remote playlist', async function () { - const res = await getVideoPlaylistsList(servers[0].url, 0, 10) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') + const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].displayName).to.equal('playlist 1 on server 1') }) it('Should update the playlist of server 2, and refresh it on server 1', async function () { this.timeout(60000) - await addVideoInPlaylist({ - url: servers[1].url, - token: servers[1].accessToken, - playlistId: playlistServer2UUID, - elementAttrs: { videoId: video2Server2 } - }) + await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }) await waitJobs(servers) // Expire playlist @@ -192,7 +173,7 @@ describe('Test ActivityPub playlists search', function () { it('Should delete playlist of server 2, and delete it on server 1', async function () { this.timeout(60000) - await deleteVideoPlaylist(servers[1].url, servers[1].accessToken, playlistServer2UUID) + await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID }) await waitJobs(servers) // Expiration diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 1862ecd31..517884503 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -4,9 +4,7 @@ import 'mocha' import * as chai from 'chai' import { VideoPlaylistPrivacy } from '@shared/models' import { - addVideoInPlaylist, cleanupTests, - createVideoPlaylist, flushAndRunServer, SearchCommand, ServerInfo, @@ -37,14 +35,9 @@ describe('Test playlists search', function () { privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: server.videoChannel.id } - const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) - - await addVideoInPlaylist({ - url: server.url, - token: server.accessToken, - playlistId: res.body.videoPlaylist.id, - elementAttrs: { videoId } - }) + const created = await server.playlistsCommand.create({ attributes }) + + await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) } { @@ -53,14 +46,9 @@ describe('Test playlists search', function () { privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: server.videoChannel.id } - const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) - - await addVideoInPlaylist({ - url: server.url, - token: server.accessToken, - playlistId: res.body.videoPlaylist.id, - elementAttrs: { videoId } - }) + const created = await server.playlistsCommand.create({ attributes }) + + await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) } { @@ -69,7 +57,7 @@ describe('Test playlists search', function () { privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: server.videoChannel.id } - await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) + await server.playlistsCommand.create({ attributes }) } command = server.searchCommand -- cgit v1.2.3 From a54618880c394ad7571f3f3222dc96ec2dd10d9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 11:21:30 +0200 Subject: Introduce channels command --- .../search/search-activitypub-video-channels.ts | 30 +++++++++++----------- .../tests/api/search/search-activitypub-videos.ts | 5 ++-- server/tests/api/search/search-channels.ts | 12 ++------- 3 files changed, 19 insertions(+), 28 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index cf5158b66..83be9cd1e 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -3,19 +3,15 @@ import 'mocha' import * as chai from 'chai' import { - addVideoChannel, cleanupTests, createUser, - deleteVideoChannel, flushAndRunMultipleServers, - getVideoChannelsList, getVideoChannelVideos, SearchCommand, ServerInfo, setAccessTokensToServers, updateMyUser, updateVideo, - updateVideoChannel, uploadVideo, userLogin, wait, @@ -45,7 +41,7 @@ describe('Test ActivityPub video channels search', function () { name: 'channel1_server1', displayName: 'Channel 1 server 1' } - await addVideoChannel(servers[0].url, servers[0].accessToken, channel) + await servers[0].channelsCommand.create({ attributes: channel }) } { @@ -57,8 +53,8 @@ describe('Test ActivityPub video channels search', function () { name: 'channel1_server2', displayName: 'Channel 1 server 2' } - const resChannel = await addVideoChannel(servers[1].url, userServer2Token, channel) - channelIdServer2 = resChannel.body.videoChannel.id + const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) + channelIdServer2 = created.id const res = await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId: channelIdServer2 }) videoServer2UUID = res.body.video.uuid @@ -143,12 +139,12 @@ describe('Test ActivityPub video channels search', function () { }) it('Should not list this remote video channel', async function () { - const res = await getVideoChannelsList(servers[0].url, 0, 5) - expect(res.body.total).to.equal(3) - expect(res.body.data).to.have.lengthOf(3) - expect(res.body.data[0].name).to.equal('channel1_server1') - expect(res.body.data[1].name).to.equal('user1_server1_channel') - expect(res.body.data[2].name).to.equal('root_channel') + const body = await servers[0].channelsCommand.list() + expect(body.total).to.equal(3) + expect(body.data).to.have.lengthOf(3) + expect(body.data[0].name).to.equal('channel1_server1') + expect(body.data[1].name).to.equal('user1_server1_channel') + expect(body.data[2].name).to.equal('root_channel') }) it('Should list video channel videos of server 2 without token', async function () { @@ -171,7 +167,11 @@ describe('Test ActivityPub video channels search', function () { it('Should update video channel of server 2, and refresh it on server 1', async function () { this.timeout(60000) - await updateVideoChannel(servers[1].url, userServer2Token, 'channel1_server2', { displayName: 'channel updated' }) + await servers[1].channelsCommand.update({ + token: userServer2Token, + channelName: 'channel1_server2', + attributes: { displayName: 'channel updated' } + }) await updateMyUser({ url: servers[1].url, accessToken: userServer2Token, displayName: 'user updated' }) await waitJobs(servers) @@ -217,7 +217,7 @@ describe('Test ActivityPub video channels search', function () { it('Should delete video channel of server 2, and delete it on server 1', async function () { this.timeout(60000) - await deleteVideoChannel(servers[1].url, userServer2Token, 'channel1_server2') + await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' }) await waitJobs(servers) // Expire video diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 7c6455258..403c84010 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -3,7 +3,6 @@ import 'mocha' import * as chai from 'chai' import { - addVideoChannel, cleanupTests, flushAndRunMultipleServers, getVideosList, @@ -123,8 +122,8 @@ describe('Test ActivityPub videos search', function () { name: 'super_channel', displayName: 'super channel' } - const resChannel = await addVideoChannel(servers[1].url, servers[1].accessToken, channelAttributes) - const videoChannelId = resChannel.body.videoChannel.id + const created = await servers[1].channelsCommand.create({ attributes: channelAttributes }) + const videoChannelId = created.id const attributes = { name: 'updated', diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 307bc063d..6c9ee73ce 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -2,15 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { - addVideoChannel, - cleanupTests, - createUser, - flushAndRunServer, - SearchCommand, - ServerInfo, - setAccessTokensToServers -} from '@shared/extra-utils' +import { cleanupTests, createUser, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' import { VideoChannel } from '@shared/models' const expect = chai.expect @@ -32,7 +24,7 @@ describe('Test channels search', function () { name: 'squall_channel', displayName: 'Squall channel' } - await addVideoChannel(server.url, server.accessToken, channel) + await server.channelsCommand.create({ attributes: channel }) } command = server.searchCommand -- 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-index.ts | 24 ++++++----------- server/tests/api/search/search-videos.ts | 46 +++++++++++++++----------------- 2 files changed, 30 insertions(+), 40 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index e4c5f5796..306f84c3a 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,16 +2,8 @@ import 'mocha' import * as chai from 'chai' -import { - cleanupTests, - flushAndRunServer, - immutableAssign, - SearchCommand, - ServerInfo, - setAccessTokensToServers, - uploadVideo -} from '@shared/extra-utils' -import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' +import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' +import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect @@ -174,32 +166,32 @@ describe('Test videos search', function () { } { - const search = immutableAssign(baseSearch, { startDate: '2018-10-01T10:54:46.396Z' }) + const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' } await check(search, false) } { - const search = immutableAssign(baseSearch, { tagsAllOf: [ 'toto', 'framasoft' ] }) + const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] } await check(search, false) } { - const search = immutableAssign(baseSearch, { durationMin: 2000 }) + const search = { ...baseSearch, durationMin: 2000 } await check(search, false) } { - const search = immutableAssign(baseSearch, { nsfw: 'true' }) + const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery } await check(search, false) } { - const search = immutableAssign(baseSearch, { nsfw: 'false' }) + const search = { ...baseSearch, nsfw: 'false' as BooleanBothQuery } await check(search, true) } { - const search = immutableAssign(baseSearch, { nsfw: 'both' }) + const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery } await check(search, true) } }) 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 41d1d075011174e73dccb74006181a92a618d7b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:05:15 +0200 Subject: Introduce login command --- server/tests/api/search/search-activitypub-video-channels.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 83be9cd1e..3cba2b019 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -13,7 +13,6 @@ import { updateMyUser, updateVideo, uploadVideo, - userLogin, wait, waitJobs } from '@shared/extra-utils' @@ -47,7 +46,7 @@ describe('Test ActivityPub video channels search', function () { { const user = { username: 'user1_server2', password: 'password' } await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) - userServer2Token = await userLogin(servers[1], user) + userServer2Token = await servers[1].loginCommand.getAccessToken(user) const channel = { name: 'channel1_server2', -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/tests/api/search/search-activitypub-video-channels.ts | 8 +++----- server/tests/api/search/search-channels.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 3cba2b019..bcc21381c 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -4,13 +4,11 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - createUser, flushAndRunMultipleServers, getVideoChannelVideos, SearchCommand, ServerInfo, setAccessTokensToServers, - updateMyUser, updateVideo, uploadVideo, wait, @@ -35,7 +33,7 @@ describe('Test ActivityPub video channels search', function () { await setAccessTokensToServers(servers) { - await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'user1_server1', password: 'password' }) + await servers[0].usersCommand.create({ username: 'user1_server1', password: 'password' }) const channel = { name: 'channel1_server1', displayName: 'Channel 1 server 1' @@ -45,7 +43,7 @@ describe('Test ActivityPub video channels search', function () { { const user = { username: 'user1_server2', password: 'password' } - await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) + await servers[1].usersCommand.create({ username: user.username, password: user.password }) userServer2Token = await servers[1].loginCommand.getAccessToken(user) const channel = { @@ -171,7 +169,7 @@ describe('Test ActivityPub video channels search', function () { channelName: 'channel1_server2', attributes: { displayName: 'channel updated' } }) - await updateMyUser({ url: servers[1].url, accessToken: userServer2Token, displayName: 'user updated' }) + await servers[1].usersCommand.updateMe({ token: userServer2Token, displayName: 'user updated' }) await waitJobs(servers) // Expire video channel diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 6c9ee73ce..4d2104708 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, createUser, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' import { VideoChannel } from '@shared/models' const expect = chai.expect @@ -19,7 +19,7 @@ describe('Test channels search', function () { await setAccessTokensToServers([ server ]) { - await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' }) + await server.usersCommand.create({ username: 'user1', password: 'password' }) const channel = { name: 'squall_channel', displayName: 'Squall channel' -- 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 --- .../search/search-activitypub-video-channels.ts | 37 ++++++++++--------- .../search/search-activitypub-video-playlists.ts | 9 +++-- .../tests/api/search/search-activitypub-videos.ts | 32 ++++++++--------- server/tests/api/search/search-index.ts | 4 +-- server/tests/api/search/search-playlists.ts | 9 +++-- server/tests/api/search/search-videos.ts | 42 +++++++++++----------- 6 files changed, 64 insertions(+), 69 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index bcc21381c..75794402d 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -5,12 +5,9 @@ import * as chai from 'chai' import { cleanupTests, flushAndRunMultipleServers, - getVideoChannelVideos, SearchCommand, ServerInfo, setAccessTokensToServers, - updateVideo, - uploadVideo, wait, waitJobs } from '@shared/extra-utils' @@ -53,8 +50,9 @@ describe('Test ActivityPub video channels search', function () { const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) channelIdServer2 = created.id - const res = await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId: channelIdServer2 }) - videoServer2UUID = res.body.video.uuid + const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 } + const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes }) + videoServer2UUID = uuid } await waitJobs(servers) @@ -149,16 +147,21 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[1].port, 0, 5) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + const { total, data } = await servers[0].videosCommand.listByChannel({ + token: null, + videoChannelName: 'channel1_server2@localhost:' + servers[1].port + }) + expect(total).to.equal(0) + expect(data).to.have.lengthOf(0) }) it('Should list video channel videos of server 2 with token', async function () { - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[1].port, 0, 5) + const { total, data } = await servers[0].videosCommand.listByChannel({ + videoChannelName: 'channel1_server2@localhost:' + servers[1].port + }) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('video 1 server 2') + expect(total).to.equal(1) + expect(data[0].name).to.equal('video 1 server 2') }) it('Should update video channel of server 2, and refresh it on server 1', async function () { @@ -190,8 +193,8 @@ describe('Test ActivityPub video channels search', function () { it('Should update and add a video on server 2, and update it on server 1 after a search', async function () { this.timeout(60000) - await updateVideo(servers[1].url, userServer2Token, videoServer2UUID, { name: 'video 1 updated' }) - await uploadVideo(servers[1].url, userServer2Token, { name: 'video 2 server 2', channelId: channelIdServer2 }) + await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }) + await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }) await waitJobs(servers) @@ -204,11 +207,11 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) const videoChannelName = 'channel1_server2@localhost:' + servers[1].port - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt') + const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' }) - expect(res.body.total).to.equal(2) - expect(res.body.data[0].name).to.equal('video 2 server 2') - expect(res.body.data[1].name).to.equal('video 1 updated') + expect(total).to.equal(2) + expect(data[0].name).to.equal('video 2 server 2') + expect(data[1].name).to.equal('video 1 updated') }) it('Should delete video channel of server 2, and delete it on server 1', async function () { diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index cb7582d29..46105c12c 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -9,7 +9,6 @@ import { ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, - uploadVideoAndGetId, wait, waitJobs } from '@shared/extra-utils' @@ -34,8 +33,8 @@ describe('Test ActivityPub playlists search', function () { await setDefaultVideoChannel(servers) { - const video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid - const video2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid + const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid + const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid const attributes = { displayName: 'playlist 1 on server 1', @@ -51,8 +50,8 @@ describe('Test ActivityPub playlists search', function () { } { - const videoId = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 1' })).uuid - video2Server2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 2' })).uuid + const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid + video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid const attributes = { displayName: 'playlist 1 on server 2', diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 403c84010..19b4d5ed8 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -5,17 +5,13 @@ import * as chai from 'chai' import { cleanupTests, flushAndRunMultipleServers, - getVideosList, - removeVideo, SearchCommand, ServerInfo, setAccessTokensToServers, - updateVideo, - uploadVideo, - wait -} from '../../../../shared/extra-utils' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { VideoPrivacy } from '../../../../shared/models/videos' + wait, + waitJobs +} from '@shared/extra-utils' +import { VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -34,13 +30,13 @@ describe('Test ActivityPub videos search', function () { await setAccessTokensToServers(servers) { - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1 on server 1' }) - videoServer1UUID = res.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } }) + videoServer1UUID = uuid } { - const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 on server 2' }) - videoServer2UUID = res.body.video.uuid + const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } }) + videoServer2UUID = uuid } await waitJobs(servers) @@ -109,10 +105,10 @@ describe('Test ActivityPub videos search', function () { }) it('Should not list this remote video', async function () { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].name).to.equal('video 1 on server 1') + const { total, data } = await servers[0].videosCommand.list() + expect(total).to.equal(1) + expect(data).to.have.lengthOf(1) + expect(data[0].name).to.equal('video 1 on server 1') }) it('Should update video of server 2, and refresh it on server 1', async function () { @@ -131,7 +127,7 @@ describe('Test ActivityPub videos search', function () { privacy: VideoPrivacy.UNLISTED, channelId: videoChannelId } - await updateVideo(servers[1].url, servers[1].accessToken, videoServer2UUID, attributes) + await servers[1].videosCommand.update({ id: videoServer2UUID, attributes }) await waitJobs(servers) // Expire video @@ -157,7 +153,7 @@ describe('Test ActivityPub videos search', function () { it('Should delete video of server 2, and delete it on server 1', async function () { this.timeout(120000) - await removeVideo(servers[1].url, servers[1].accessToken, videoServer2UUID) + await servers[1].videosCommand.remove({ id: videoServer2UUID }) await waitJobs(servers) // Expire video diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index 306f84c3a..d5dc40f60 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' +import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect @@ -20,7 +20,7 @@ describe('Test videos search', function () { await setAccessTokensToServers([ server ]) - await uploadVideo(server.url, server.accessToken, { name: localVideoName }) + await server.videosCommand.upload({ attributes: { name: localVideoName } }) command = server.searchCommand }) diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 517884503..2e4773ed6 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -2,16 +2,15 @@ import 'mocha' import * as chai from 'chai' -import { VideoPlaylistPrivacy } from '@shared/models' import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, - setDefaultVideoChannel, - uploadVideoAndGetId -} from '../../../../shared/extra-utils' + setDefaultVideoChannel +} from '@shared/extra-utils' +import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect @@ -27,7 +26,7 @@ describe('Test playlists search', function () { await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) - const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid + const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid { const attributes = { 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 --- .../search/search-activitypub-video-channels.ts | 32 +++++++-------- .../search/search-activitypub-video-playlists.ts | 28 ++++++------- .../tests/api/search/search-activitypub-videos.ts | 14 +++---- server/tests/api/search/search-channels.ts | 6 +-- server/tests/api/search/search-index.ts | 14 +++---- server/tests/api/search/search-playlists.ts | 20 +++++----- server/tests/api/search/search-videos.ts | 46 +++++++++++----------- 7 files changed, 80 insertions(+), 80 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 75794402d..71e9367e5 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -30,34 +30,34 @@ describe('Test ActivityPub video channels search', function () { await setAccessTokensToServers(servers) { - await servers[0].usersCommand.create({ username: 'user1_server1', password: 'password' }) + await servers[0].users.create({ username: 'user1_server1', password: 'password' }) const channel = { name: 'channel1_server1', displayName: 'Channel 1 server 1' } - await servers[0].channelsCommand.create({ attributes: channel }) + await servers[0].channels.create({ attributes: channel }) } { const user = { username: 'user1_server2', password: 'password' } - await servers[1].usersCommand.create({ username: user.username, password: user.password }) - userServer2Token = await servers[1].loginCommand.getAccessToken(user) + await servers[1].users.create({ username: user.username, password: user.password }) + userServer2Token = await servers[1].login.getAccessToken(user) const channel = { name: 'channel1_server2', displayName: 'Channel 1 server 2' } - const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) + const created = await servers[1].channels.create({ token: userServer2Token, attributes: channel }) channelIdServer2 = created.id const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 } - const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes }) + const { uuid } = await servers[1].videos.upload({ token: userServer2Token, attributes }) videoServer2UUID = uuid } await waitJobs(servers) - command = servers[0].searchCommand + command = servers[0].search }) it('Should not find a remote video channel', async function () { @@ -134,7 +134,7 @@ describe('Test ActivityPub video channels search', function () { }) it('Should not list this remote video channel', async function () { - const body = await servers[0].channelsCommand.list() + const body = await servers[0].channels.list() expect(body.total).to.equal(3) expect(body.data).to.have.lengthOf(3) expect(body.data[0].name).to.equal('channel1_server1') @@ -147,7 +147,7 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const { total, data } = await servers[0].videosCommand.listByChannel({ + const { total, data } = await servers[0].videos.listByChannel({ token: null, videoChannelName: 'channel1_server2@localhost:' + servers[1].port }) @@ -156,7 +156,7 @@ describe('Test ActivityPub video channels search', function () { }) it('Should list video channel videos of server 2 with token', async function () { - const { total, data } = await servers[0].videosCommand.listByChannel({ + const { total, data } = await servers[0].videos.listByChannel({ videoChannelName: 'channel1_server2@localhost:' + servers[1].port }) @@ -167,12 +167,12 @@ describe('Test ActivityPub video channels search', function () { it('Should update video channel of server 2, and refresh it on server 1', async function () { this.timeout(60000) - await servers[1].channelsCommand.update({ + await servers[1].channels.update({ token: userServer2Token, channelName: 'channel1_server2', attributes: { displayName: 'channel updated' } }) - await servers[1].usersCommand.updateMe({ token: userServer2Token, displayName: 'user updated' }) + await servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' }) await waitJobs(servers) // Expire video channel @@ -193,8 +193,8 @@ describe('Test ActivityPub video channels search', function () { it('Should update and add a video on server 2, and update it on server 1 after a search', async function () { this.timeout(60000) - await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }) - await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }) + await servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }) + await servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }) await waitJobs(servers) @@ -207,7 +207,7 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) const videoChannelName = 'channel1_server2@localhost:' + servers[1].port - const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' }) + const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' }) expect(total).to.equal(2) expect(data[0].name).to.equal('video 2 server 2') @@ -217,7 +217,7 @@ describe('Test ActivityPub video channels search', function () { it('Should delete video channel of server 2, and delete it on server 1', async function () { this.timeout(60000) - await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' }) + await servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' }) await waitJobs(servers) // Expire video diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 46105c12c..7c99b954b 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -33,40 +33,40 @@ describe('Test ActivityPub playlists search', function () { await setDefaultVideoChannel(servers) { - const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid - const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid + const video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid + const video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid const attributes = { displayName: 'playlist 1 on server 1', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } - const created = await servers[0].playlistsCommand.create({ attributes }) + const created = await servers[0].playlists.create({ attributes }) playlistServer1UUID = created.uuid for (const videoId of [ video1, video2 ]) { - await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } }) + await servers[0].playlists.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } }) } } { - const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid - video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid + const videoId = (await servers[1].videos.quickUpload({ name: 'video 1' })).uuid + video2Server2 = (await servers[1].videos.quickUpload({ name: 'video 2' })).uuid const attributes = { displayName: 'playlist 1 on server 2', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } - const created = await servers[1].playlistsCommand.create({ attributes }) + const created = await servers[1].playlists.create({ attributes }) playlistServer2UUID = created.uuid - await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }) + await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }) } await waitJobs(servers) - command = servers[0].searchCommand + command = servers[0].search }) it('Should not find a remote playlist', async function () { @@ -139,7 +139,7 @@ describe('Test ActivityPub playlists search', function () { }) it('Should not list this remote playlist', async function () { - const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 }) + const body = await servers[0].playlists.list({ start: 0, count: 10 }) expect(body.total).to.equal(1) expect(body.data).to.have.lengthOf(1) expect(body.data[0].displayName).to.equal('playlist 1 on server 1') @@ -148,7 +148,7 @@ describe('Test ActivityPub playlists search', function () { it('Should update the playlist of server 2, and refresh it on server 1', async function () { this.timeout(60000) - await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }) + await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }) await waitJobs(servers) // Expire playlist @@ -172,7 +172,7 @@ describe('Test ActivityPub playlists search', function () { it('Should delete playlist of server 2, and delete it on server 1', async function () { this.timeout(60000) - await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID }) + await servers[1].playlists.delete({ playlistId: playlistServer2UUID }) await waitJobs(servers) // Expiration diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 19b4d5ed8..0dfc63446 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -30,18 +30,18 @@ describe('Test ActivityPub videos search', function () { await setAccessTokensToServers(servers) { - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1 on server 1' } }) videoServer1UUID = uuid } { - const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } }) + const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 on server 2' } }) videoServer2UUID = uuid } await waitJobs(servers) - command = servers[0].searchCommand + command = servers[0].search }) it('Should not find a remote video', async function () { @@ -105,7 +105,7 @@ describe('Test ActivityPub videos search', function () { }) it('Should not list this remote video', async function () { - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(1) expect(data).to.have.lengthOf(1) expect(data[0].name).to.equal('video 1 on server 1') @@ -118,7 +118,7 @@ describe('Test ActivityPub videos search', function () { name: 'super_channel', displayName: 'super channel' } - const created = await servers[1].channelsCommand.create({ attributes: channelAttributes }) + const created = await servers[1].channels.create({ attributes: channelAttributes }) const videoChannelId = created.id const attributes = { @@ -127,7 +127,7 @@ describe('Test ActivityPub videos search', function () { privacy: VideoPrivacy.UNLISTED, channelId: videoChannelId } - await servers[1].videosCommand.update({ id: videoServer2UUID, attributes }) + await servers[1].videos.update({ id: videoServer2UUID, attributes }) await waitJobs(servers) // Expire video @@ -153,7 +153,7 @@ describe('Test ActivityPub videos search', function () { it('Should delete video of server 2, and delete it on server 1', async function () { this.timeout(120000) - await servers[1].videosCommand.remove({ id: videoServer2UUID }) + await servers[1].videos.remove({ id: videoServer2UUID }) await waitJobs(servers) // Expire video diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 4d2104708..7035fbd62 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -19,15 +19,15 @@ describe('Test channels search', function () { await setAccessTokensToServers([ server ]) { - await server.usersCommand.create({ username: 'user1', password: 'password' }) + await server.users.create({ username: 'user1', password: 'password' }) const channel = { name: 'squall_channel', displayName: 'Squall channel' } - await server.channelsCommand.create({ attributes: channel }) + await server.channels.create({ attributes: channel }) } - command = server.searchCommand + command = server.search }) it('Should make a simple search and not have results', async function () { diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index d5dc40f60..b54c0da22 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -20,9 +20,9 @@ describe('Test videos search', function () { await setAccessTokensToServers([ server ]) - await server.videosCommand.upload({ attributes: { name: localVideoName } }) + await server.videos.upload({ attributes: { name: localVideoName } }) - command = server.searchCommand + command = server.search }) describe('Default search', async function () { @@ -30,7 +30,7 @@ describe('Test videos search', function () { it('Should make a local videos search by default', async function () { this.timeout(10000) - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { search: { searchIndex: { @@ -57,7 +57,7 @@ describe('Test videos search', function () { }) it('Should make an index videos search by default', async function () { - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { search: { searchIndex: { @@ -79,7 +79,7 @@ describe('Test videos search', function () { }) it('Should make an index videos search if local search is disabled', async function () { - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { search: { searchIndex: { @@ -213,7 +213,7 @@ describe('Test videos search', function () { let nsfwUUID: string { - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { instance: { defaultNSFWPolicy: 'display' } } @@ -229,7 +229,7 @@ describe('Test videos search', function () { } { - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { instance: { defaultNSFWPolicy: 'do_not_list' } } diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 2e4773ed6..e15128c8e 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -26,40 +26,40 @@ describe('Test playlists search', function () { await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) - const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid + const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid { const attributes = { displayName: 'Dr. Kenzo Tenma hospital videos', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id + videoChannelId: server.store.channel.id } - const created = await server.playlistsCommand.create({ attributes }) + const created = await server.playlists.create({ attributes }) - await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) + await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) } { const attributes = { displayName: 'Johan & Anna Libert musics', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id + videoChannelId: server.store.channel.id } - const created = await server.playlistsCommand.create({ attributes }) + const created = await server.playlists.create({ attributes }) - await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) + await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) } { const attributes = { displayName: 'Inspector Lunge playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id + videoChannelId: server.store.channel.id } - await server.playlistsCommand.create({ attributes }) + await server.playlists.create({ attributes }) } - command = server.searchCommand + command = server.search }) it('Should make a simple search and not have results', async function () { 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-activitypub-video-channels.ts | 8 ++++---- server/tests/api/search/search-activitypub-video-playlists.ts | 8 ++++---- server/tests/api/search/search-activitypub-videos.ts | 8 ++++---- server/tests/api/search/search-channels.ts | 6 +++--- server/tests/api/search/search-index.ts | 6 +++--- server/tests/api/search/search-playlists.ts | 8 ++++---- server/tests/api/search/search-videos.ts | 8 ++++---- 7 files changed, 26 insertions(+), 26 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 71e9367e5..f5896ec25 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -4,9 +4,9 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, SearchCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, wait, waitJobs @@ -16,7 +16,7 @@ import { VideoChannel } from '@shared/models' const expect = chai.expect describe('Test ActivityPub video channels search', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let userServer2Token: string let videoServer2UUID: string let channelIdServer2: number @@ -25,7 +25,7 @@ describe('Test ActivityPub video channels search', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 7c99b954b..ada2d3d6c 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -4,9 +4,9 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, SearchCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, wait, @@ -17,7 +17,7 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect describe('Test ActivityPub playlists search', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let playlistServer1UUID: string let playlistServer2UUID: string let video2Server2: string @@ -27,7 +27,7 @@ describe('Test ActivityPub playlists search', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 0dfc63446..a015b72a7 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -4,9 +4,9 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, SearchCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, wait, waitJobs @@ -16,7 +16,7 @@ import { VideoPrivacy } from '@shared/models' const expect = chai.expect describe('Test ActivityPub videos search', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let videoServer1UUID: string let videoServer2UUID: string @@ -25,7 +25,7 @@ describe('Test ActivityPub videos search', function () { before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 7035fbd62..07e00a214 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -2,19 +2,19 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, SearchCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' import { VideoChannel } from '@shared/models' const expect = chai.expect describe('Test channels search', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null let command: SearchCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index b54c0da22..38edcf7c6 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, SearchCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect @@ -10,13 +10,13 @@ const expect = chai.expect describe('Test videos search', function () { const localVideoName = 'local video' + new Date().toISOString() - let server: ServerInfo = null + let server: PeerTubeServer = null let command: SearchCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index e15128c8e..b29c2d127 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -4,9 +4,9 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, SearchCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils' @@ -15,13 +15,13 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect describe('Test playlists search', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null let command: SearchCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) 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 c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/api/search/search-activitypub-video-channels.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index f5896ec25..b33f28266 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -149,7 +149,7 @@ describe('Test ActivityPub video channels search', function () { const { total, data } = await servers[0].videos.listByChannel({ token: null, - videoChannelName: 'channel1_server2@localhost:' + servers[1].port + handle: 'channel1_server2@localhost:' + servers[1].port }) expect(total).to.equal(0) expect(data).to.have.lengthOf(0) @@ -157,7 +157,7 @@ describe('Test ActivityPub video channels search', function () { it('Should list video channel videos of server 2 with token', async function () { const { total, data } = await servers[0].videos.listByChannel({ - videoChannelName: 'channel1_server2@localhost:' + servers[1].port + handle: 'channel1_server2@localhost:' + servers[1].port }) expect(total).to.equal(1) @@ -206,8 +206,8 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const videoChannelName = 'channel1_server2@localhost:' + servers[1].port - const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' }) + const handle = 'channel1_server2@localhost:' + servers[1].port + const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' }) expect(total).to.equal(2) expect(data[0].name).to.equal('video 2 server 2') -- 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-activitypub-video-channels.ts | 2 +- server/tests/api/search/search-activitypub-video-playlists.ts | 2 +- server/tests/api/search/search-activitypub-videos.ts | 2 +- server/tests/api/search/search-channels.ts | 2 +- server/tests/api/search/search-index.ts | 2 +- server/tests/api/search/search-playlists.ts | 2 +- server/tests/api/search/search-videos.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index b33f28266..426cbc8e1 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, createMultipleServers, - SearchCommand, PeerTubeServer, + SearchCommand, setAccessTokensToServers, wait, waitJobs diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index ada2d3d6c..33ca7be12 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, createMultipleServers, - SearchCommand, PeerTubeServer, + SearchCommand, setAccessTokensToServers, setDefaultVideoChannel, wait, diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index a015b72a7..b3cfcacca 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, createMultipleServers, - SearchCommand, PeerTubeServer, + SearchCommand, setAccessTokensToServers, wait, waitJobs diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 07e00a214..4da2d0ece 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, createSingleServer, SearchCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' import { VideoChannel } from '@shared/models' const expect = chai.expect diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index 38edcf7c6..feb35411f 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, createSingleServer, SearchCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index b29c2d127..22e9b8fca 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, createSingleServer, - SearchCommand, PeerTubeServer, + SearchCommand, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils' 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') 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