aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-16 14:13:01 +0200
committerChocobozzz <me@florianbigard.com>2020-06-16 14:13:01 +0200
commit1ba471c55fdbf05ef2c10152b3e4b0c5d8da3213 (patch)
tree0f231073a848f3089752fda5fe378ff5b64c229b /server/tests/api
parentaf75e2d8df92d5d602e11353536ec6804a25f16f (diff)
downloadPeerTube-1ba471c55fdbf05ef2c10152b3e4b0c5d8da3213.tar.gz
PeerTube-1ba471c55fdbf05ef2c10152b3e4b0c5d8da3213.tar.zst
PeerTube-1ba471c55fdbf05ef2c10152b3e4b0c5d8da3213.zip
Add videos count in channels list
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/videos/video-channels.ts29
1 files changed, 24 insertions, 5 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 89026aba7..e7d9238dd 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -365,7 +365,7 @@ describe('Test video channels', function () {
365 } 365 }
366 }) 366 })
367 367
368 it('Should report correct channel statistics', async function () { 368 it('Should report correct channel views per days', async function () {
369 this.timeout(10000) 369 this.timeout(10000)
370 370
371 { 371 {
@@ -374,14 +374,18 @@ describe('Test video channels', function () {
374 accountName: userInfo.account.name + '@' + userInfo.account.host, 374 accountName: userInfo.account.name + '@' + userInfo.account.host,
375 withStats: true 375 withStats: true
376 }) 376 })
377 res.body.data.forEach((channel: VideoChannel) => { 377
378 const channels: VideoChannel[] = res.body.data
379
380 for (const channel of channels) {
378 expect(channel).to.haveOwnProperty('viewsPerDay') 381 expect(channel).to.haveOwnProperty('viewsPerDay')
379 expect(channel.viewsPerDay).to.have.length(30 + 1) // daysPrior + today 382 expect(channel.viewsPerDay).to.have.length(30 + 1) // daysPrior + today
380 channel.viewsPerDay.forEach((v: ViewsPerDate) => { 383
384 for (const v of channel.viewsPerDay) {
381 expect(v.date).to.be.an('string') 385 expect(v.date).to.be.an('string')
382 expect(v.views).to.equal(0) 386 expect(v.views).to.equal(0)
383 }) 387 }
384 }) 388 }
385 } 389 }
386 390
387 { 391 {
@@ -402,6 +406,21 @@ describe('Test video channels', function () {
402 } 406 }
403 }) 407 })
404 408
409 it('Should report correct videos count', async function () {
410 const res = await getAccountVideoChannelsList({
411 url: servers[0].url,
412 accountName: userInfo.account.name + '@' + userInfo.account.host,
413 withStats: true
414 })
415 const channels: VideoChannel[] = res.body.data
416
417 const totoChannel = channels.find(c => c.name === 'toto_channel')
418 const rootChannel = channels.find(c => c.name === 'root_channel')
419
420 expect(rootChannel.videosCount).to.equal(1)
421 expect(totoChannel.videosCount).to.equal(0)
422 })
423
405 after(async function () { 424 after(async function () {
406 await cleanupTests(servers) 425 await cleanupTests(servers)
407 }) 426 })