/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
-import { User, Video, VideoChannel, ViewsPerDate, VideoDetails } from '../../../../shared/index'
+import * as chai from 'chai'
import {
cleanupTests,
createUser,
viewVideo
} from '../../../../shared/extra-utils/index'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
+import { User, Video, VideoChannel, VideoDetails } from '../../../../shared/index'
const expect = chai.expect
}
})
- it('Should report correct channel statistics', async function () {
+ it('Should report correct channel views per days', async function () {
+ this.timeout(10000)
{
const res = await getAccountVideoChannelsList({
accountName: userInfo.account.name + '@' + userInfo.account.host,
withStats: true
})
- res.body.data.forEach((channel: VideoChannel) => {
+
+ 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
- channel.viewsPerDay.forEach((v: ViewsPerDate) => {
+
+ for (const v of channel.viewsPerDay) {
expect(v.date).to.be.an('string')
expect(v.views).to.equal(0)
- })
- })
+ }
+ }
}
{
}
})
+ it('Should report correct videos count', async function () {
+ const res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName: userInfo.account.name + '@' + userInfo.account.host,
+ 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: userInfo.account.name + '@' + userInfo.account.host,
+ 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: userInfo.account.name + '@' + userInfo.account.host,
+ search: 'does not exist'
+ })
+ expect(res.body.total).to.equal(0)
+
+ const channels = res.body.data
+ expect(channels).to.have.lengthOf(0)
+ }
+ })
+
after(async function () {
await cleanupTests(servers)
})