2020-06-10 03:58:44 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
|
|
|
|
|
|
|
import * as chai from 'chai'
|
2021-07-28 06:40:26 -05:00
|
|
|
import {
|
|
|
|
BooleanBothQuery,
|
|
|
|
VideoChannelsSearchQuery,
|
|
|
|
VideoPlaylistPrivacy,
|
|
|
|
VideoPlaylistsSearchQuery,
|
|
|
|
VideoPlaylistType,
|
|
|
|
VideosSearchQuery
|
|
|
|
} from '@shared/models'
|
2022-08-17 08:40:57 -05:00
|
|
|
import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/server-commands'
|
2020-06-10 03:58:44 -05:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2022-02-28 01:34:43 -06:00
|
|
|
describe('Test index search', function () {
|
2020-06-10 03:58:44 -05:00
|
|
|
const localVideoName = 'local video' + new Date().toISOString()
|
|
|
|
|
2021-07-16 02:47:51 -05:00
|
|
|
let server: PeerTubeServer = null
|
2021-07-06 08:22:51 -05:00
|
|
|
let command: SearchCommand
|
|
|
|
|
2020-06-10 03:58:44 -05:00
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2021-07-16 02:47:51 -05:00
|
|
|
server = await createSingleServer(1)
|
2020-06-10 03:58:44 -05:00
|
|
|
|
|
|
|
await setAccessTokensToServers([ server ])
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.videos.upload({ attributes: { name: localVideoName } })
|
2021-07-06 08:22:51 -05:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
command = server.search
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('Default search', async function () {
|
|
|
|
|
|
|
|
it('Should make a local videos search by default', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.config.updateCustomSubConfig({
|
2021-07-07 04:51:09 -05:00
|
|
|
newConfig: {
|
|
|
|
search: {
|
|
|
|
searchIndex: {
|
|
|
|
enabled: true,
|
|
|
|
isDefaultSearch: false,
|
|
|
|
disableLocalSearch: false
|
|
|
|
}
|
2020-06-10 03:58:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'local video' })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.equal(1)
|
|
|
|
expect(body.data[0].name).to.equal(localVideoName)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make a local channels search by default', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchChannels({ search: 'root' })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
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)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make an index videos search by default', async function () {
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.config.updateCustomSubConfig({
|
2021-07-07 04:51:09 -05:00
|
|
|
newConfig: {
|
|
|
|
search: {
|
|
|
|
searchIndex: {
|
|
|
|
enabled: true,
|
|
|
|
isDefaultSearch: true,
|
|
|
|
disableLocalSearch: false
|
|
|
|
}
|
2020-06-10 03:58:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'local video' })
|
|
|
|
expect(body.total).to.be.greaterThan(2)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make an index channels search by default', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchChannels({ search: 'root' })
|
|
|
|
expect(body.total).to.be.greaterThan(2)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make an index videos search if local search is disabled', async function () {
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.config.updateCustomSubConfig({
|
2021-07-07 04:51:09 -05:00
|
|
|
newConfig: {
|
|
|
|
search: {
|
|
|
|
searchIndex: {
|
|
|
|
enabled: true,
|
|
|
|
isDefaultSearch: false,
|
|
|
|
disableLocalSearch: true
|
|
|
|
}
|
2020-06-10 03:58:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'local video' })
|
|
|
|
expect(body.total).to.be.greaterThan(2)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make an index channels search if local search is disabled', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchChannels({ search: 'root' })
|
|
|
|
expect(body.total).to.be.greaterThan(2)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Videos search', async function () {
|
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
async function check (search: VideosSearchQuery, exists = true) {
|
|
|
|
const body = await command.advancedVideoSearch({ search })
|
|
|
|
|
|
|
|
if (exists === false) {
|
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(body.total).to.equal(1)
|
|
|
|
expect(body.data).to.have.lengthOf(1)
|
|
|
|
|
|
|
|
const video = body.data[0]
|
|
|
|
|
|
|
|
expect(video.name).to.equal('What is PeerTube?')
|
|
|
|
expect(video.category.label).to.equal('Science & Technology')
|
|
|
|
expect(video.licence.label).to.equal('Attribution - Share Alike')
|
|
|
|
expect(video.privacy.label).to.equal('Public')
|
|
|
|
expect(video.duration).to.equal(113)
|
|
|
|
expect(video.thumbnailUrl.startsWith('https://framatube.org/static/thumbnails')).to.be.true
|
|
|
|
|
|
|
|
expect(video.account.host).to.equal('framatube.org')
|
|
|
|
expect(video.account.name).to.equal('framasoft')
|
|
|
|
expect(video.account.url).to.equal('https://framatube.org/accounts/framasoft')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 06:40:16 -05:00
|
|
|
expect(video.account.avatar).to.exist
|
2022-06-08 07:58:34 -05:00
|
|
|
expect(video.account.avatars.length).to.equal(2, 'Account should have one avatar image')
|
2021-07-29 06:40:16 -05:00
|
|
|
|
|
|
|
expect(video.channel.host).to.equal('framatube.org')
|
2021-08-11 01:16:01 -05:00
|
|
|
expect(video.channel.name).to.equal('joinpeertube')
|
|
|
|
expect(video.channel.url).to.equal('https://framatube.org/video-channels/joinpeertube')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 06:40:16 -05:00
|
|
|
expect(video.channel.avatar).to.exist
|
2022-06-08 07:58:34 -05:00
|
|
|
expect(video.channel.avatars.length).to.equal(2, 'Channel should have one avatar image')
|
2021-07-29 06:40:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const baseSearch: VideosSearchQuery = {
|
|
|
|
search: 'what is peertube',
|
|
|
|
start: 0,
|
|
|
|
count: 2,
|
|
|
|
categoryOneOf: [ 15 ],
|
|
|
|
licenceOneOf: [ 2 ],
|
|
|
|
tagsAllOf: [ 'framasoft', 'peertube' ],
|
|
|
|
startDate: '2018-10-01T10:50:46.396Z',
|
|
|
|
endDate: '2018-10-01T10:55:46.396Z'
|
|
|
|
}
|
|
|
|
|
2020-06-10 03:58:44 -05:00
|
|
|
it('Should make a simple search and not have results', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'djidane'.repeat(50) })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make a simple search and have results', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'What is PeerTube' })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.be.greaterThan(1)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should make a simple search', async function () {
|
|
|
|
await check(baseSearch)
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should search by start date', async function () {
|
|
|
|
const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' }
|
|
|
|
await check(search, false)
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should search by tags', async function () {
|
|
|
|
const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] }
|
|
|
|
await check(search, false)
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should search by duration', async function () {
|
|
|
|
const search = { ...baseSearch, durationMin: 2000 }
|
|
|
|
await check(search, false)
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should search by nsfw attribute', async function () {
|
2020-06-10 03:58:44 -05:00
|
|
|
{
|
2021-07-13 02:43:59 -05:00
|
|
|
const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery }
|
2020-06-10 03:58:44 -05:00
|
|
|
await check(search, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-13 02:43:59 -05:00
|
|
|
const search = { ...baseSearch, nsfw: 'false' as BooleanBothQuery }
|
2020-06-10 03:58:44 -05:00
|
|
|
await check(search, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-13 02:43:59 -05:00
|
|
|
const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery }
|
2020-06-10 03:58:44 -05:00
|
|
|
await check(search, true)
|
|
|
|
}
|
2021-07-29 06:40:16 -05:00
|
|
|
})
|
2021-07-28 06:40:26 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
it('Should search by host', async function () {
|
2021-07-28 06:40:26 -05:00
|
|
|
{
|
|
|
|
const search = { ...baseSearch, host: 'example.com' }
|
|
|
|
await check(search, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const search = { ...baseSearch, host: 'framatube.org' }
|
|
|
|
await check(search, true)
|
|
|
|
}
|
2021-07-29 06:40:16 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should search by uuids', async function () {
|
|
|
|
const goodUUID = '9c9de5e8-0a1e-484a-b099-e80766180a6d'
|
|
|
|
const goodShortUUID = 'kkGMgK9ZtnKfYAgnEtQxbv'
|
|
|
|
const badUUID = 'c29c5b77-4a04-493d-96a9-2e9267e308f0'
|
|
|
|
const badShortUUID = 'rP5RgUeX9XwTSrspCdkDej'
|
2021-07-29 04:54:38 -05:00
|
|
|
|
|
|
|
{
|
2021-07-29 06:40:16 -05:00
|
|
|
const uuidsMatrix = [
|
|
|
|
[ goodUUID ],
|
|
|
|
[ goodUUID, badShortUUID ],
|
|
|
|
[ badShortUUID, goodShortUUID ],
|
|
|
|
[ goodUUID, goodShortUUID ]
|
|
|
|
]
|
|
|
|
|
|
|
|
for (const uuids of uuidsMatrix) {
|
|
|
|
const search = { ...baseSearch, uuids }
|
|
|
|
await check(search, true)
|
2021-07-29 04:54:38 -05:00
|
|
|
}
|
2021-07-29 06:40:16 -05:00
|
|
|
}
|
2021-07-29 04:54:38 -05:00
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
{
|
|
|
|
const uuidsMatrix = [
|
|
|
|
[ badUUID ],
|
|
|
|
[ badShortUUID ]
|
|
|
|
]
|
|
|
|
|
|
|
|
for (const uuids of uuidsMatrix) {
|
|
|
|
const search = { ...baseSearch, uuids }
|
|
|
|
await check(search, false)
|
2021-07-29 04:54:38 -05:00
|
|
|
}
|
|
|
|
}
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have a correct pagination', async function () {
|
|
|
|
const search = {
|
|
|
|
search: 'video',
|
|
|
|
start: 0,
|
|
|
|
count: 5
|
|
|
|
}
|
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.advancedVideoSearch({ search })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.be.greaterThan(5)
|
|
|
|
expect(body.data).to.have.lengthOf(5)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
2020-06-12 09:24:58 -05:00
|
|
|
|
|
|
|
it('Should use the nsfw instance policy as default', async function () {
|
|
|
|
let nsfwUUID: string
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.config.updateCustomSubConfig({
|
2021-07-07 04:51:09 -05:00
|
|
|
newConfig: {
|
|
|
|
instance: { defaultNSFWPolicy: 'display' }
|
|
|
|
}
|
|
|
|
})
|
2020-06-12 09:24:58 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' })
|
|
|
|
expect(body.data).to.have.length.greaterThan(0)
|
2020-06-12 09:24:58 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const video = body.data[0]
|
2020-06-12 09:24:58 -05:00
|
|
|
expect(video.nsfw).to.be.true
|
|
|
|
|
|
|
|
nsfwUUID = video.uuid
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
await server.config.updateCustomSubConfig({
|
2021-07-07 04:51:09 -05:00
|
|
|
newConfig: {
|
|
|
|
instance: { defaultNSFWPolicy: 'do_not_list' }
|
|
|
|
}
|
|
|
|
})
|
2020-06-12 09:24:58 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' })
|
2020-06-12 09:24:58 -05:00
|
|
|
|
|
|
|
try {
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.data).to.have.lengthOf(0)
|
|
|
|
} catch {
|
|
|
|
const video = body.data[0]
|
2020-06-12 09:24:58 -05:00
|
|
|
|
|
|
|
expect(video.uuid).not.equal(nsfwUUID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('Channels search', async function () {
|
|
|
|
|
2021-07-29 06:40:16 -05:00
|
|
|
async function check (search: VideoChannelsSearchQuery, exists = true) {
|
|
|
|
const body = await command.advancedChannelSearch({ search })
|
|
|
|
|
|
|
|
if (exists === false) {
|
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(body.total).to.be.greaterThan(0)
|
|
|
|
expect(body.data).to.have.length.greaterThan(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')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 06:40:16 -05:00
|
|
|
expect(videoChannel.avatar).to.exist
|
2022-06-08 07:58:34 -05:00
|
|
|
expect(videoChannel.avatars.length).to.equal(2, 'Channel should have two avatar images')
|
2021-07-29 06:40:16 -05:00
|
|
|
expect(videoChannel.displayName).to.exist
|
|
|
|
|
|
|
|
expect(videoChannel.ownerAccount.url).to.equal('https://framatube.org/accounts/framasoft')
|
|
|
|
expect(videoChannel.ownerAccount.name).to.equal('framasoft')
|
|
|
|
expect(videoChannel.ownerAccount.host).to.equal('framatube.org')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 06:40:16 -05:00
|
|
|
expect(videoChannel.ownerAccount.avatar).to.exist
|
2022-06-08 07:58:34 -05:00
|
|
|
expect(videoChannel.ownerAccount.avatars.length).to.equal(2, 'Account should have two avatar images')
|
2021-07-29 06:40:16 -05:00
|
|
|
}
|
|
|
|
|
2020-06-10 03:58:44 -05:00
|
|
|
it('Should make a simple search and not have results', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.searchChannels({ search: 'a'.repeat(500) })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make a search and have results', async function () {
|
2021-07-28 06:40:26 -05:00
|
|
|
await check({ search: 'Framasoft', sort: 'createdAt' }, true)
|
2021-07-29 06:40:16 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make host search and have appropriate results', async function () {
|
2022-06-03 08:13:23 -05:00
|
|
|
await check({ search: 'Framasoft videos', host: 'example.com' }, false)
|
|
|
|
await check({ search: 'Framasoft videos', host: 'framatube.org' }, true)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
2021-07-29 06:40:16 -05:00
|
|
|
|
|
|
|
it('Should make handles search and have appropriate results', async function () {
|
|
|
|
await check({ handles: [ 'bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org' ] }, true)
|
|
|
|
await check({ handles: [ 'jeanine', 'bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org' ] }, true)
|
|
|
|
await check({ handles: [ 'jeanine', 'chocobozzz_channel2@peertube2.cpy.re' ] }, false)
|
|
|
|
})
|
2020-06-10 03:58:44 -05:00
|
|
|
|
|
|
|
it('Should have a correct pagination', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } })
|
2020-06-10 03:58:44 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.be.greaterThan(2)
|
|
|
|
expect(body.data).to.have.lengthOf(2)
|
2020-06-10 03:58:44 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-06-17 09:02:38 -05:00
|
|
|
describe('Playlists search', async function () {
|
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
async function check (search: VideoPlaylistsSearchQuery, exists = true) {
|
|
|
|
const body = await command.advancedPlaylistSearch({ search })
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
if (exists === false) {
|
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
|
|
|
return
|
|
|
|
}
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(body.total).to.be.greaterThan(0)
|
|
|
|
expect(body.data).to.have.length.greaterThan(0)
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
const videoPlaylist = body.data[0]
|
2021-07-28 06:40:26 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.url).to.equal('https://peertube2.cpy.re/videos/watch/playlist/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
|
|
|
|
expect(videoPlaylist.thumbnailUrl).to.exist
|
|
|
|
expect(videoPlaylist.embedUrl).to.equal('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
|
2021-07-28 06:40:26 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.type.id).to.equal(VideoPlaylistType.REGULAR)
|
|
|
|
expect(videoPlaylist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
|
|
|
|
expect(videoPlaylist.videosLength).to.exist
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.createdAt).to.exist
|
|
|
|
expect(videoPlaylist.updatedAt).to.exist
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.uuid).to.equal('73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
|
|
|
|
expect(videoPlaylist.displayName).to.exist
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.ownerAccount.url).to.equal('https://peertube2.cpy.re/accounts/chocobozzz')
|
|
|
|
expect(videoPlaylist.ownerAccount.name).to.equal('chocobozzz')
|
|
|
|
expect(videoPlaylist.ownerAccount.host).to.equal('peertube2.cpy.re')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.ownerAccount.avatar).to.exist
|
2022-03-02 01:40:50 -06:00
|
|
|
expect(videoPlaylist.ownerAccount.avatars.length).to.equal(2, 'Account should have two avatar images')
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.videoChannel.url).to.equal('https://peertube2.cpy.re/video-channels/chocobozzz_channel')
|
|
|
|
expect(videoPlaylist.videoChannel.name).to.equal('chocobozzz_channel')
|
|
|
|
expect(videoPlaylist.videoChannel.host).to.equal('peertube2.cpy.re')
|
2022-02-28 01:34:43 -06:00
|
|
|
// TODO: remove, deprecated in 4.2
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(videoPlaylist.videoChannel.avatar).to.exist
|
2022-03-02 01:40:50 -06:00
|
|
|
expect(videoPlaylist.videoChannel.avatars.length).to.equal(2, 'Channel should have two avatar images')
|
2021-07-29 04:54:38 -05:00
|
|
|
}
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
it('Should make a simple search and not have results', async function () {
|
|
|
|
const body = await command.searchPlaylists({ search: 'a'.repeat(500) })
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
expect(body.total).to.equal(0)
|
|
|
|
expect(body.data).to.have.lengthOf(0)
|
|
|
|
})
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-29 04:54:38 -05:00
|
|
|
it('Should make a search and have results', async function () {
|
2021-07-28 06:40:26 -05:00
|
|
|
await check({ search: 'E2E playlist', sort: '-match' }, true)
|
2021-07-29 04:54:38 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make host search and have appropriate results', async function () {
|
2021-07-28 06:40:26 -05:00
|
|
|
await check({ search: 'E2E playlist', host: 'example.com' }, false)
|
2021-07-29 04:54:38 -05:00
|
|
|
await check({ search: 'E2E playlist', host: 'peertube2.cpy.re', sort: '-match' }, true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should make a search by uuids and have appropriate results', async function () {
|
|
|
|
const goodUUID = '73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'
|
|
|
|
const goodShortUUID = 'fgei1ws1oa6FCaJ2qZPG29'
|
|
|
|
const badUUID = 'c29c5b77-4a04-493d-96a9-2e9267e308f0'
|
|
|
|
const badShortUUID = 'rP5RgUeX9XwTSrspCdkDej'
|
|
|
|
|
|
|
|
{
|
|
|
|
const uuidsMatrix = [
|
|
|
|
[ goodUUID ],
|
|
|
|
[ goodUUID, badShortUUID ],
|
|
|
|
[ badShortUUID, goodShortUUID ],
|
|
|
|
[ goodUUID, goodShortUUID ]
|
|
|
|
]
|
|
|
|
|
|
|
|
for (const uuids of uuidsMatrix) {
|
|
|
|
const search = { search: 'E2E playlist', sort: '-match', uuids }
|
|
|
|
await check(search, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const uuidsMatrix = [
|
|
|
|
[ badUUID ],
|
|
|
|
[ badShortUUID ]
|
|
|
|
]
|
|
|
|
|
|
|
|
for (const uuids of uuidsMatrix) {
|
|
|
|
const search = { search: 'E2E playlist', sort: '-match', uuids }
|
|
|
|
await check(search, false)
|
|
|
|
}
|
|
|
|
}
|
2021-06-17 09:02:38 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have a correct pagination', async function () {
|
2021-07-06 08:22:51 -05:00
|
|
|
const body = await command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } })
|
2021-06-17 09:02:38 -05:00
|
|
|
|
2021-07-06 08:22:51 -05:00
|
|
|
expect(body.total).to.be.greaterThan(2)
|
|
|
|
expect(body.data).to.have.lengthOf(2)
|
2021-06-17 09:02:38 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-06-10 03:58:44 -05:00
|
|
|
after(async function () {
|
|
|
|
await cleanupTests([ server ])
|
|
|
|
})
|
|
|
|
})
|