addVideoToBlacklist,
cleanupTests,
createUser,
+ doubleFollow,
flushAndRunMultipleServers,
getBlacklistedVideosList,
getMyUserInformation,
killallServers,
removeVideoFromBlacklist,
reRunServer,
- searchVideo,
ServerInfo,
setAccessTokensToServers,
updateVideo,
updateVideoBlacklist,
uploadVideo,
- userLogin
-} from '../../../../shared/extra-utils/index'
-import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
-import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import { getGoodVideoUrl, getMagnetURI, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
-import { User, UserRole } from '../../../../shared/models/users'
-import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
-import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos'
+ userLogin,
+ waitJobs
+} from '@shared/extra-utils'
+import { getGoodVideoUrl, getMagnetURI, importVideo } from '@shared/extra-utils/videos/video-imports'
+import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
const expect = chai.expect
}
{
- const res = await searchVideo(servers[0].url, 'name')
+ const body = await servers[0].searchCommand.searchVideos({ search: 'name' })
- expect(res.body.total).to.equal(0)
- expect(res.body.data).to.be.an('array')
- expect(res.body.data.length).to.equal(0)
+ expect(body.total).to.equal(0)
+ expect(body.data).to.be.an('array')
+ expect(body.data.length).to.equal(0)
}
})
}
{
- const res = await searchVideo(servers[1].url, 'video')
+ const body = await servers[1].searchCommand.searchVideos({ search: 'name' })
- expect(res.body.total).to.equal(2)
- expect(res.body.data).to.be.an('array')
- expect(res.body.data.length).to.equal(2)
+ expect(body.total).to.equal(2)
+ expect(body.data).to.be.an('array')
+ expect(body.data.length).to.equal(2)
}
})
})
/* 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,
getVideoChannelsList,
getVideoChannelVideos,
+ SearchCommand,
ServerInfo,
setAccessTokensToServers,
updateMyUser,
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
let userServer2Token: string
let videoServer2UUID: string
let channelIdServer2: number
+ let command: SearchCommand
before(async function () {
this.timeout(120000)
}
await waitJobs(servers)
+
+ command = servers[0].searchCommand
})
it('Should not find a remote video channel', async 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)
}
})
]
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')
}
})
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')
}
})
]
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')
}
})
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
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)
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 () {
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
let playlistServer2UUID: string
let video2Server2: string
+ let command: SearchCommand
+
before(async function () {
this.timeout(120000)
}
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 () {
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)
}
}
})
]
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)
}
})
// 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)
})
// 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 () {
/* 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,
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
let videoServer1UUID: string
let videoServer2UUID: string
+ let command: SearchCommand
+
before(async function () {
this.timeout(120000)
}
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')
}
})
]
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')
}
})
// 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)
// 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 () {
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)
}
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 () {
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')
}
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)
}
})
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)
await setAccessTokensToServers([ server ])
await uploadVideo(server.url, server.accessToken, { name: localVideoName })
+
+ command = server.searchCommand
})
describe('Default search', async 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 () {
}
})
- 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 () {
}
})
- 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')
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 () {
{
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
{
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)
}
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
})
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
})
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)
})
})
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,
describe('Test playlists search', function () {
let server: ServerInfo = null
+ let command: SearchCommand
before(async function () {
this.timeout(30000)
}
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 () {
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)
}
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')
}
})
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 () {
import * as chai from 'chai'
import { VideoPrivacy } from '@shared/models'
import {
- advancedVideosSearch,
cleanupTests,
createLive,
flushAndRunServer,
immutableAssign,
- searchVideo,
+ SearchCommand,
sendRTMPStreamInVideo,
ServerInfo,
setAccessTokensToServers,
let startDate: string
let videoUUID: string
+ let command: SearchCommand
+
before(async function () {
this.timeout(60000)
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
})
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
})
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')
})
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')
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 () {
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 () {
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 () {
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 () {
}
{
- 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)
}
})
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')
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')
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')
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')
})
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')
})
{
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)
}
{
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)
}
{
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 () {
}
{
- 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)
}
{
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)
}
})
getVideoChannelVideos,
getVideosList,
getVideosListWithToken,
- searchVideo,
- searchVideoWithToken,
ServerInfo,
setAccessTokensToServers,
updateCustomConfig,
uploadVideo,
userLogin
} from '@shared/extra-utils'
-import { CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models'
+import { BooleanBothQuery, CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models'
const expect = chai.expect
let userAccessToken: string
let customConfig: CustomConfig
- function getVideosFunctions (token?: string, query = {}) {
+ function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
return getMyUserInformation(server.url, server.accessToken)
.then(res => {
const user: User = res.body
if (token) {
promises = [
getVideosListWithToken(server.url, token, query),
- searchVideoWithToken(server.url, 'n', token, query),
+ server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', ...query } }),
getAccountVideos(server.url, token, accountName, 0, 5, undefined, query),
getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query)
]
promises = [
getVideosList(server.url),
- searchVideo(server.url, 'n'),
+ server.searchCommand.searchVideos({ search: 'n' }),
getAccountVideos(server.url, undefined, accountName, 0, 5),
getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5)
]
})
it('Should display NSFW videos when the nsfw param === true', async function () {
- for (const res of await getVideosFunctions(server.accessToken, { nsfw: true })) {
+ for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'true' })) {
expect(res.body.total).to.equal(1)
const videos = res.body.data
})
it('Should hide NSFW videos when the nsfw param === true', async function () {
- for (const res of await getVideosFunctions(server.accessToken, { nsfw: false })) {
+ for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'false' })) {
expect(res.body.total).to.equal(1)
const videos = res.body.data
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
+import { HttpStatusCode } from '@shared/core-utils'
import {
cleanupTests,
createUser,
getVideoWithToken,
killallServers,
reRunServer,
- searchVideoWithToken,
ServerInfo,
setAccessTokensToServers,
updateMyUser,
uploadVideo,
userLogin,
wait
-} from '../../../../shared/extra-utils'
-import { Video, VideoDetails } from '../../../../shared/models/videos'
-import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '@shared/extra-utils/videos/video-history'
+import { Video, VideoDetails } from '@shared/models'
const expect = chai.expect
}
{
- const res = await searchVideoWithToken(server.url, 'video', server.accessToken)
- videosOfVideos.push(res.body.data)
+ const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' })
+ videosOfVideos.push(body.data)
}
for (const videos of videosOfVideos) {
import 'mocha'
import * as chai from 'chai'
-import { advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels'
-import { ServerConfig } from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/core-utils'
import {
addVideoCommentReply,
addVideoCommentThread,
- advancedVideoPlaylistSearch,
- advancedVideosSearch,
+ cleanupTests,
createLive,
createVideoPlaylist,
doubleFollow,
+ flushAndRunMultipleServers,
getAccountVideos,
getConfig,
getMyVideos,
installPlugin,
makeRawRequest,
registerUser,
+ ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomSubConfig,
updateVideo,
uploadVideo,
uploadVideoAndGetId,
- waitJobs
-} from '../../../shared/extra-utils'
-import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
-import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports'
+ waitJobs,
+ waitUntilLog
+} from '@shared/extra-utils'
+import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
import {
+ ServerConfig,
VideoCommentThreadTree,
VideoDetails,
VideoImport,
VideoPlaylist,
VideoPlaylistPrivacy,
VideoPrivacy
-} from '../../../shared/models/videos'
+} from '@shared/models'
const expect = chai.expect
})
it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
- await advancedVideosSearch(servers[0].url, {
- search: 'Sun Quan'
+ await servers[0].searchCommand.advancedVideoSearch({
+ search: {
+ search: 'Sun Quan'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1)
})
it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
- await advancedVideosSearch(servers[0].url, {
- search: 'Sun Quan',
- searchTarget: 'search-index'
+ await servers[0].searchCommand.advancedVideoSearch({
+ search: {
+ search: 'Sun Quan',
+ searchTarget: 'search-index'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1)
})
it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
- await advancedVideoChannelSearch(servers[0].url, {
- search: 'Sun Ce'
+ await servers[0].searchCommand.advancedChannelSearch({
+ search: {
+ search: 'Sun Ce'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1)
})
it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
- await advancedVideoChannelSearch(servers[0].url, {
- search: 'Sun Ce',
- searchTarget: 'search-index'
+ await servers[0].searchCommand.advancedChannelSearch({
+ search: {
+ search: 'Sun Ce',
+ searchTarget: 'search-index'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1)
})
it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
- await advancedVideoPlaylistSearch(servers[0].url, {
- search: 'Sun Jian'
+ await servers[0].searchCommand.advancedPlaylistSearch({
+ search: {
+ search: 'Sun Jian'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1)
})
it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
- await advancedVideoPlaylistSearch(servers[0].url, {
- search: 'Sun Jian',
- searchTarget: 'search-index'
+ await servers[0].searchCommand.advancedPlaylistSearch({
+ search: {
+ search: 'Sun Jian',
+ searchTarget: 'search-index'
+ }
})
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1)
export * from './requests/check-api-params'
export * from './requests/requests'
-export * from './search/video-channels'
-export * from './search/video-playlists'
-export * from './search/videos'
+export * from './search'
export * from './server/activitypub'
export * from './server/clients'
getVideos (options: OverrideCommandOptions & {
page: number
- token?: string
}) {
const { token, page } = options
const path = '/api/v1/overviews/videos'
--- /dev/null
+export * from './search-command'
--- /dev/null
+import {
+ ResultList,
+ Video,
+ VideoChannel,
+ VideoChannelsSearchQuery,
+ VideoPlaylist,
+ VideoPlaylistsSearchQuery,
+ VideosSearchQuery
+} from '@shared/models'
+import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { AbstractCommand, OverrideCommandOptions } from '../shared'
+
+export class SearchCommand extends AbstractCommand {
+
+ searchChannels (options: OverrideCommandOptions & {
+ search: string
+ }) {
+ return this.advancedChannelSearch({
+ ...options,
+
+ search: { search: options.search }
+ })
+ }
+
+ advancedChannelSearch (options: OverrideCommandOptions & {
+ search: VideoChannelsSearchQuery
+ }) {
+ const { search, token } = options
+ const path = '/api/v1/search/video-channels'
+
+ return this.getRequestBody<ResultList<VideoChannel>>({
+ ...options,
+
+ token: token || null,
+
+ path,
+ query: search,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+
+ searchPlaylists (options: OverrideCommandOptions & {
+ search: string
+ }) {
+ return this.advancedPlaylistSearch({
+ ...options,
+
+ search: { search: options.search }
+ })
+ }
+
+ advancedPlaylistSearch (options: OverrideCommandOptions & {
+ search: VideoPlaylistsSearchQuery
+ }) {
+ const { search, token } = options
+ const path = '/api/v1/search/video-playlists'
+
+ return this.getRequestBody<ResultList<VideoPlaylist>>({
+ ...options,
+
+ token: token || null,
+
+ path,
+ query: search,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+
+ searchVideos (options: OverrideCommandOptions & {
+ search: string
+ sort?: string
+ }) {
+ const { search, sort } = options
+
+ return this.advancedVideoSearch({
+ ...options,
+
+ search: {
+ search: search,
+ sort: sort ?? '-publishedAt'
+ }
+ })
+ }
+
+ advancedVideoSearch (options: OverrideCommandOptions & {
+ search: VideosSearchQuery
+ }) {
+ const { search, token } = options
+ const path = '/api/v1/search/videos'
+
+ return this.getRequestBody<ResultList<Video>>({
+ ...options,
+
+ token: token || null,
+
+ path,
+ query: search,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+}
+++ /dev/null
-import { VideoChannelsSearchQuery } from '@shared/models'
-import { makeGetRequest } from '../requests/requests'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-
-function searchVideoChannel (url: string, search: string, token?: string, statusCodeExpected = HttpStatusCode.OK_200) {
- const path = '/api/v1/search/video-channels'
-
- return makeGetRequest({
- url,
- path,
- query: {
- sort: '-createdAt',
- search
- },
- token,
- statusCodeExpected
- })
-}
-
-function advancedVideoChannelSearch (url: string, search: VideoChannelsSearchQuery) {
- const path = '/api/v1/search/video-channels'
-
- return makeGetRequest({
- url,
- path,
- query: search,
- statusCodeExpected: HttpStatusCode.OK_200
- })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- searchVideoChannel,
- advancedVideoChannelSearch
-}
+++ /dev/null
-import { VideoPlaylistsSearchQuery } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
-import { makeGetRequest } from '../requests/requests'
-
-function searchVideoPlaylists (url: string, search: string, token?: string, statusCodeExpected = HttpStatusCode.OK_200) {
- const path = '/api/v1/search/video-playlists'
-
- return makeGetRequest({
- url,
- path,
- query: {
- sort: '-createdAt',
- search
- },
- token,
- statusCodeExpected
- })
-}
-
-function advancedVideoPlaylistSearch (url: string, search: VideoPlaylistsSearchQuery) {
- const path = '/api/v1/search/video-playlists'
-
- return makeGetRequest({
- url,
- path,
- query: search,
- statusCodeExpected: HttpStatusCode.OK_200
- })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- searchVideoPlaylists,
- advancedVideoPlaylistSearch
-}
+++ /dev/null
-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-
-import * as request from 'supertest'
-import { VideosSearchQuery } from '../../models/search'
-import { immutableAssign } from '../miscs/miscs'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-
-function searchVideo (url: string, search: string, sort = '-publishedAt') {
- const path = '/api/v1/search/videos'
-
- const query = { sort, search: search }
- const req = request(url)
- .get(path)
- .query(query)
- .set('Accept', 'application/json')
-
- return req.expect(HttpStatusCode.OK_200)
- .expect('Content-Type', /json/)
-}
-
-function searchVideoWithToken (url: string, search: string, token: string, query: { nsfw?: boolean } = {}) {
- const path = '/api/v1/search/videos'
- const req = request(url)
- .get(path)
- .set('Authorization', 'Bearer ' + token)
- .query(immutableAssign(query, { sort: '-publishedAt', search }))
- .set('Accept', 'application/json')
-
- return req.expect(HttpStatusCode.OK_200)
- .expect('Content-Type', /json/)
-}
-
-function searchVideoWithSort (url: string, search: string, sort: string) {
- const path = '/api/v1/search/videos'
-
- const query = { search, sort }
-
- return request(url)
- .get(path)
- .query(query)
- .set('Accept', 'application/json')
- .expect(HttpStatusCode.OK_200)
- .expect('Content-Type', /json/)
-}
-
-function advancedVideosSearch (url: string, options: VideosSearchQuery) {
- const path = '/api/v1/search/videos'
-
- return request(url)
- .get(path)
- .query(options)
- .set('Accept', 'application/json')
- .expect(HttpStatusCode.OK_200)
- .expect('Content-Type', /json/)
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- searchVideo,
- advancedVideosSearch,
- searchVideoWithToken,
- searchVideoWithSort
-}
import { AbusesCommand } from '../moderation'
import { OverviewsCommand } from '../overviews'
import { makeGetRequest } from '../requests/requests'
+import { SearchCommand } from '../search'
interface ServerInfo {
app: ChildProcess
logsCommand?: LogsCommand
abusesCommand?: AbusesCommand
overviewsCommand?: OverviewsCommand
+ searchCommand?: SearchCommand
}
function parallelTests () {
server.logsCommand = new LogsCommand(server)
server.abusesCommand = new AbusesCommand(server)
server.overviewsCommand = new OverviewsCommand(server)
+ server.searchCommand = new SearchCommand(server)
res(server)
})
import { getLowercaseExtension } from '@server/helpers/core-utils'
import { buildUUID } from '@server/helpers/uuid'
import { HttpStatusCode } from '@shared/core-utils'
-import { VideosCommonQuery } from '@shared/models'
+import { BooleanBothQuery, VideosCommonQuery } from '@shared/models'
import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
import { VideoDetails, VideoPrivacy } from '../../models/videos'
import {
.expect('Content-Type', /json/)
}
-function getVideosListWithToken (url: string, token: string, query: { nsfw?: boolean } = {}) {
+function getVideosListWithToken (url: string, token: string, query: { nsfw?: BooleanBothQuery } = {}) {
const path = '/api/v1/videos'
return request(url)
count: number,
sort?: string,
query: {
- nsfw?: boolean
+ nsfw?: BooleanBothQuery
search?: string
} = {}
) {
start: number,
count: number,
sort?: string,
- query: { nsfw?: boolean } = {}
+ query: { nsfw?: BooleanBothQuery } = {}
) {
const path = '/api/v1/video-channels/' + videoChannelName + '/videos'