+ it('Should report correct channel views per days', async function () {
+ this.timeout(10000)
+
+ {
+ const res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName,
+ withStats: true
+ })
+
+ const channels: VideoChannel[] = res.body.data
+
+ for (const channel of channels) {
+ 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 res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName,
+ withStats: true
+ })
+ const channelWithView = res.body.data.find((channel: VideoChannel) => 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 res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName,
+ withStats: true
+ })
+ const channels: VideoChannel[] = res.body.data
+
+ const totoChannel = channels.find(c => c.name === 'toto_channel')
+ const rootChannel = channels.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 res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName,
+ search: 'root'
+ })
+ expect(res.body.total).to.equal(1)
+
+ const channels = res.body.data
+ expect(channels).to.have.lengthOf(1)
+ }
+
+ {
+ const res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName,
+ search: 'does not exist'
+ })
+ expect(res.body.total).to.equal(0)
+
+ const channels = res.body.data
+ expect(channels).to.have.lengthOf(0)
+ }
+ })
+
+ it('Should list channels by updatedAt desc if a video has been uploaded', async function () {
+ this.timeout(30000)
+
+ await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: totoChannel })
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getAccountVideoChannelsList({
+ url: server.url,
+ accountName,
+ sort: '-updatedAt'
+ })
+
+ const channels: VideoChannel[] = res.body.data
+ expect(channels[0].name).to.equal('toto_channel')
+ expect(channels[1].name).to.equal('root_channel')
+ }
+
+ await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: servers[0].videoChannel.id })
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getAccountVideoChannelsList({
+ url: server.url,
+ accountName,
+ sort: '-updatedAt'
+ })
+
+ const channels: VideoChannel[] = res.body.data
+ expect(channels[0].name).to.equal('root_channel')
+ expect(channels[1].name).to.equal('toto_channel')
+ }
+ })
+