/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@server/tests/shared'
import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands'
-const expect = chai.expect
-
describe('Test views overall stats', function () {
let servers: PeerTubeServer[]
expect(video.views).to.equal(0)
expect(stats.averageWatchTime).to.equal(0)
expect(stats.totalWatchTime).to.equal(0)
+ expect(stats.totalViewers).to.equal(0)
}
})
expect(video.views).to.equal(0)
expect(stats.averageWatchTime).to.equal(1)
expect(stats.totalWatchTime).to.equal(1)
+ expect(stats.totalViewers).to.equal(1)
}
})
expect(video.views).to.equal(1)
expect(stats.averageWatchTime).to.equal(2)
expect(stats.totalWatchTime).to.equal(4)
+ expect(stats.totalViewers).to.equal(2)
}
{
expect(video.views).to.equal(1)
expect(stats.averageWatchTime).to.equal(21)
expect(stats.totalWatchTime).to.equal(41)
+ expect(stats.totalViewers).to.equal(2)
}
}
})
expect(video.views).to.equal(1)
expect(stats.averageWatchTime).to.equal(2)
expect(stats.totalWatchTime).to.equal(6)
+ expect(stats.totalViewers).to.equal(3)
}
{
expect(video.views).to.equal(1)
expect(stats.averageWatchTime).to.equal(14)
expect(stats.totalWatchTime).to.equal(43)
+ expect(stats.totalViewers).to.equal(3)
}
})
expect(video.views).to.equal(2)
expect(stats.averageWatchTime).to.equal(3)
expect(stats.totalWatchTime).to.equal(11)
+ expect(stats.totalViewers).to.equal(4)
}
{
expect(video.views).to.equal(2)
expect(stats.averageWatchTime).to.equal(22)
expect(stats.totalWatchTime).to.equal(88)
+ expect(stats.totalViewers).to.equal(4)
}
})
const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId, startDate: beforeView.toISOString() })
expect(stats.averageWatchTime).to.equal(3)
expect(stats.totalWatchTime).to.equal(3)
+ expect(stats.totalViewers).to.equal(1)
}
{
const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId, endDate: beforeView.toISOString() })
expect(stats.averageWatchTime).to.equal(22)
expect(stats.totalWatchTime).to.equal(88)
+ expect(stats.totalViewers).to.equal(4)
}
})