X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-channels.ts;h=367f99fdd6c6ea5c05c262a994126cf76182d440;hb=daf6e4801052d3ca6be2fafd20bae2323b1ce175;hp=876a6ab66381e92afc615a28684e0efeb8936d86;hpb=3d527ba173a37bd61ec8ad742642bb320d12995c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 876a6ab66..367f99fdd 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -1,8 +1,7 @@ /* 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, @@ -30,6 +29,7 @@ import { 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 @@ -365,7 +365,8 @@ describe('Test video channels', function () { } }) - 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({ @@ -373,14 +374,18 @@ describe('Test video channels', function () { 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) - }) - }) + } + } } { @@ -401,6 +406,47 @@ describe('Test video channels', function () { } }) + 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) })