+ await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'banner' })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const videoChannel = await findChannel(server, secondVideoChannelId)
+ await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), false)
+
+ expect(videoChannel.banner).to.be.null
+ }
+ })
+
+ it('Should list the second video channel videos', async function () {
+ this.timeout(10000)
+
+ for (const server of servers) {
+ const channelURI = 'second_video_channel@localhost:' + servers[0].port
+ const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
+ expect(res1.body.total).to.equal(1)
+ expect(res1.body.data).to.be.an('array')
+ expect(res1.body.data).to.have.lengthOf(1)
+ expect(res1.body.data[0].name).to.equal('my video name')
+ }
+ })
+
+ it('Should change the video channel of a video', async function () {
+ this.timeout(10000)
+
+ await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: servers[0].videoChannel.id })
+
+ await waitJobs(servers)
+ })
+
+ it('Should list the first video channel videos', async function () {
+ this.timeout(10000)
+
+ for (const server of servers) {
+ const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
+ const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
+ expect(res1.body.total).to.equal(0)
+
+ const channelURI = 'root_channel@localhost:' + servers[0].port
+ const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
+ expect(res2.body.total).to.equal(1)
+
+ const videos: Video[] = res2.body.data
+ expect(videos).to.be.an('array')
+ expect(videos).to.have.lengthOf(1)
+ expect(videos[0].name).to.equal('my video name')
+ }
+ })
+
+ it('Should delete video channel', async function () {
+ await servers[0].channelsCommand.delete({ channelName: 'second_video_channel' })
+ })
+
+ it('Should have video channel deleted', async function () {
+ const body = await servers[0].channelsCommand.list({ start: 0, count: 10 })
+
+ expect(body.total).to.equal(1)
+ expect(body.data).to.be.an('array')
+ expect(body.data).to.have.lengthOf(1)
+ expect(body.data[0].displayName).to.equal('Main root channel')
+ })
+
+ it('Should create the main channel with an uuid if there is a conflict', async function () {
+ {
+ const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
+ const created = await servers[0].channelsCommand.create({ attributes: videoChannel })
+ totoChannel = created.id
+ }
+
+ {
+ await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' })
+ const accessToken = await userLogin(servers[0], { username: 'toto', password: 'password' })
+
+ const res = await getMyUserInformation(servers[0].url, accessToken)
+ const videoChannel = res.body.videoChannels[0]
+ expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
+ }
+ })
+
+ it('Should report correct channel views per days', async function () {
+ this.timeout(10000)
+
+ {
+ const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
+
+ for (const channel of data) {
+ expect(channel).to.haveOwnProperty('viewsPerDay')
+ expect(channel.viewsPerDay).to.have.length(30 + 1) // daysPrior + today
+
+ for (const v of channel.viewsPerDay) {
+ expect(v.date).to.be.an('string')
+ expect(v.views).to.equal(0)
+ }
+ }
+ }
+
+ {
+ // video has been posted on channel servers[0].videoChannel.id since last update
+ await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.1,127.0.0.1')
+ await viewVideo(servers[0].url, videoUUID, 204, '0.0.0.2,127.0.0.1')
+
+ // Wait the repeatable job
+ await wait(8000)
+
+ const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
+ const channelWithView = data.find(channel => channel.id === servers[0].videoChannel.id)
+ expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2)
+ }
+ })
+
+ it('Should report correct videos count', async function () {
+ const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
+
+ const totoChannel = data.find(c => c.name === 'toto_channel')
+ const rootChannel = data.find(c => c.name === 'root_channel')
+
+ expect(rootChannel.videosCount).to.equal(1)
+ expect(totoChannel.videosCount).to.equal(0)
+ })
+
+ it('Should search among account video channels', async function () {
+ {
+ const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'root' })
+ expect(body.total).to.equal(1)
+
+ const channels = body.data
+ expect(channels).to.have.lengthOf(1)