1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { VideoPlaylistPrivacy } from '@shared/models'
11 setAccessTokensToServers,
12 setDefaultVideoChannel,
14 } from '../../../../shared/extra-utils'
16 const expect = chai.expect
18 describe('Test playlists search', function () {
19 let server: ServerInfo = null
20 let command: SearchCommand
22 before(async function () {
25 server = await flushAndRunServer(1)
27 await setAccessTokensToServers([ server ])
28 await setDefaultVideoChannel([ server ])
30 const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid
34 displayName: 'Dr. Kenzo Tenma hospital videos',
35 privacy: VideoPlaylistPrivacy.PUBLIC,
36 videoChannelId: server.videoChannel.id
38 const created = await server.playlistsCommand.create({ attributes })
40 await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
45 displayName: 'Johan & Anna Libert musics',
46 privacy: VideoPlaylistPrivacy.PUBLIC,
47 videoChannelId: server.videoChannel.id
49 const created = await server.playlistsCommand.create({ attributes })
51 await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
56 displayName: 'Inspector Lunge playlist',
57 privacy: VideoPlaylistPrivacy.PUBLIC,
58 videoChannelId: server.videoChannel.id
60 await server.playlistsCommand.create({ attributes })
63 command = server.searchCommand
66 it('Should make a simple search and not have results', async function () {
67 const body = await command.searchPlaylists({ search: 'abc' })
69 expect(body.total).to.equal(0)
70 expect(body.data).to.have.lengthOf(0)
73 it('Should make a search and have results', async function () {
80 const body = await command.advancedPlaylistSearch({ search })
81 expect(body.total).to.equal(1)
82 expect(body.data).to.have.lengthOf(1)
84 const playlist = body.data[0]
85 expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos')
86 expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid)
91 search: 'Anna Livert',
95 const body = await command.advancedPlaylistSearch({ search })
96 expect(body.total).to.equal(1)
97 expect(body.data).to.have.lengthOf(1)
99 const playlist = body.data[0]
100 expect(playlist.displayName).to.equal('Johan & Anna Libert musics')
104 it('Should not display playlists without videos', async function () {
110 const body = await command.advancedPlaylistSearch({ search })
111 expect(body.total).to.equal(0)
112 expect(body.data).to.have.lengthOf(0)
115 after(async function () {
116 await cleanupTests([ server ])