X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fstats.ts;h=c207bb5f00196e649e163458c62766e06d2cbab9;hb=7024e9120b381b5b3201212f5a18f5cdc14e15ff;hp=71d54c0ab2c8410668dd792c3e62a1639a90131d;hpb=09cababd79f9d445aa027c93cdfe823745fa041a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 71d54c0ab..c207bb5f0 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -1,32 +1,31 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import * as chai from 'chai' import 'mocha' import { ServerStats } from '../../../../shared/models/server/server-stats.model' import { + cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, follow, - killallServers, ServerInfo, uploadVideo, viewVideo, wait -} from '../../utils' -import { flushTests, setAccessTokensToServers } from '../../utils/index' -import { getStats } from '../../utils/server/stats' -import { addVideoCommentThread } from '../../utils/videos/video-comments' +} from '../../../../shared/extra-utils' +import { setAccessTokensToServers } from '../../../../shared/extra-utils/index' +import { getStats } from '../../../../shared/extra-utils/server/stats' +import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' +import { waitJobs } from '../../../../shared/extra-utils/server/jobs' const expect = chai.expect -describe('Test stats', function () { +describe('Test stats (excluding redundancy)', function () { let servers: ServerInfo[] = [] before(async function () { this.timeout(60000) - - await flushTests() servers = await flushAndRunMultipleServers(3) await setAccessTokensToServers(servers) @@ -36,17 +35,20 @@ describe('Test stats', function () { username: 'user1', password: 'super_password' } - await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) + await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, {}) + const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' }) const videoUUID = resVideo.body.video.uuid await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment') await viewVideo(servers[0].url, videoUUID) + // Wait the video views repeatable job + await wait(8000) + await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) - await wait(5000) + await waitJobs(servers) }) it('Should have the correct stats on instance 1', async function () { @@ -56,6 +58,7 @@ describe('Test stats', function () { expect(data.totalLocalVideoComments).to.equal(1) expect(data.totalLocalVideos).to.equal(1) expect(data.totalLocalVideoViews).to.equal(1) + expect(data.totalLocalVideoFilesSize).to.equal(218910) expect(data.totalUsers).to.equal(2) expect(data.totalVideoComments).to.equal(1) expect(data.totalVideos).to.equal(1) @@ -70,6 +73,7 @@ describe('Test stats', function () { expect(data.totalLocalVideoComments).to.equal(0) expect(data.totalLocalVideos).to.equal(0) expect(data.totalLocalVideoViews).to.equal(0) + expect(data.totalLocalVideoFilesSize).to.equal(0) expect(data.totalUsers).to.equal(1) expect(data.totalVideoComments).to.equal(1) expect(data.totalVideos).to.equal(1) @@ -92,11 +96,6 @@ describe('Test stats', function () { }) after(async function () { - killallServers(servers) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests(servers) }) })