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, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils'
+import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
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 ])
- await uploadVideo(server.url, server.accessToken, { name: localVideoName })
+ await server.videos.upload({ attributes: { name: localVideoName } })
- command = server.searchCommand
+ command = server.search
})
describe('Default search', async 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: {
})
it('Should make an index videos search by default', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
})
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: {
}
{
- 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)
}
})
let nsfwUUID: string
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'display' }
}
}
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'do_not_list' }
}