1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { VideoPlaylistPrivacy } from '@shared/models'
13 setAccessTokensToServers,
14 setDefaultVideoChannel,
16 } from '../../../../shared/extra-utils'
18 const expect = chai.expect
20 describe('Test playlists search', function () {
21 let server: ServerInfo = null
22 let command: SearchCommand
24 before(async function () {
27 server = await flushAndRunServer(1)
29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
32 const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid
36 displayName: 'Dr. Kenzo Tenma hospital videos',
37 privacy: VideoPlaylistPrivacy.PUBLIC,
38 videoChannelId: server.videoChannel.id
40 const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
42 await addVideoInPlaylist({
44 token: server.accessToken,
45 playlistId: res.body.videoPlaylist.id,
46 elementAttrs: { videoId }
52 displayName: 'Johan & Anna Libert musics',
53 privacy: VideoPlaylistPrivacy.PUBLIC,
54 videoChannelId: server.videoChannel.id
56 const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
58 await addVideoInPlaylist({
60 token: server.accessToken,
61 playlistId: res.body.videoPlaylist.id,
62 elementAttrs: { videoId }
68 displayName: 'Inspector Lunge playlist',
69 privacy: VideoPlaylistPrivacy.PUBLIC,
70 videoChannelId: server.videoChannel.id
72 await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
75 command = server.searchCommand
78 it('Should make a simple search and not have results', async function () {
79 const body = await command.searchPlaylists({ search: 'abc' })
81 expect(body.total).to.equal(0)
82 expect(body.data).to.have.lengthOf(0)
85 it('Should make a search and have results', async function () {
92 const body = await command.advancedPlaylistSearch({ search })
93 expect(body.total).to.equal(1)
94 expect(body.data).to.have.lengthOf(1)
96 const playlist = body.data[0]
97 expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos')
98 expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid)
103 search: 'Anna Livert',
107 const body = await command.advancedPlaylistSearch({ search })
108 expect(body.total).to.equal(1)
109 expect(body.data).to.have.lengthOf(1)
111 const playlist = body.data[0]
112 expect(playlist.displayName).to.equal('Johan & Anna Libert musics')
116 it('Should not display playlists without videos', async function () {
122 const body = await command.advancedPlaylistSearch({ search })
123 expect(body.total).to.equal(0)
124 expect(body.data).to.have.lengthOf(0)
127 after(async function () {
128 await cleanupTests([ server ])