Skip to content

Commit

Permalink
add tests for active video channels stats
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk committed Feb 26, 2021
1 parent cb4394e commit a47dd05
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions server/tests/api/server/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import 'mocha'
import * as chai from 'chai'
import {
addVideoChannel,
cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
follow,
getMyUserInformation,
ServerInfo,
unfollow,
updateCustomSubConfig,
Expand Down Expand Up @@ -115,7 +117,7 @@ describe('Test stats (excluding redundancy)', function () {
expect(data.totalVideos).to.equal(0)
})

it('Should have the correct active user/channels stats', async function () {
it('Should have the correct active user stats', async function () {
const server = servers[0]

{
Expand All @@ -124,10 +126,6 @@ describe('Test stats (excluding redundancy)', function () {
expect(data.totalDailyActiveUsers).to.equal(1)
expect(data.totalWeeklyActiveUsers).to.equal(1)
expect(data.totalMonthlyActiveUsers).to.equal(1)

expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
}

{
Expand All @@ -141,6 +139,42 @@ describe('Test stats (excluding redundancy)', function () {
}
})

it('Should have the correct active channel stats', async function () {
const server = servers[0]
const videoChannelProperties = { name: 'second_channel', displayName: 'My second channel' }

{
const res = await getStats(server.url)
const data: ServerStats = res.body
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
}

{
await addVideoChannel(server.url, server.accessToken, videoChannelProperties)

const res = await getStats(server.url)
const data: ServerStats = res.body
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
}

{
const resChannel = await getMyUserInformation(server.url, server.accessToken)
const videoChannel = resChannel.body.videoChannels.find(v => v.name === videoChannelProperties.name)

await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.webm', channelId: videoChannel.id })

const res = await getStats(server.url)
const data: ServerStats = res.body
expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2)
}
})

it('Should correctly count video file sizes if transcoding is enabled', async function () {
this.timeout(60000)

Expand Down

0 comments on commit a47dd05

Please sign in to comment.