1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
12 setAccessTokensToServers
13 } from '@shared/extra-utils'
14 import { VideoChannel } from '@shared/models'
16 const expect = chai.expect
18 describe('Test channels search', function () {
19 let server: ServerInfo = null
20 let command: SearchCommand
22 before(async function () {
25 server = await flushAndRunServer(1)
27 await setAccessTokensToServers([ server ])
30 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' })
32 name: 'squall_channel',
33 displayName: 'Squall channel'
35 await addVideoChannel(server.url, server.accessToken, channel)
38 command = server.searchCommand
41 it('Should make a simple search and not have results', async function () {
42 const body = await command.searchChannels({ search: 'abc' })
44 expect(body.total).to.equal(0)
45 expect(body.data).to.have.lengthOf(0)
48 it('Should make a search and have results', async function () {
55 const body = await command.advancedChannelSearch({ search })
56 expect(body.total).to.equal(1)
57 expect(body.data).to.have.lengthOf(1)
59 const channel: VideoChannel = body.data[0]
60 expect(channel.name).to.equal('squall_channel')
61 expect(channel.displayName).to.equal('Squall channel')
71 const body = await command.advancedChannelSearch({ search })
72 expect(body.total).to.equal(1)
73 expect(body.data).to.have.lengthOf(0)
77 after(async function () {
78 await cleanupTests([ server ])