X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fstats.ts;h=c207bb5f00196e649e163458c62766e06d2cbab9;hb=7024e9120b381b5b3201212f5a18f5cdc14e15ff;hp=d8a3268bb969d933cd253a580734c8f1f0b05257;hpb=4b5384f6e7be62d072d21d8d964951ba572ab10e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index d8a3268bb..c207bb5f0 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -1,23 +1,23 @@ -/* 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' -import { waitJobs } from '../../utils/server/jobs' +} 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 @@ -26,8 +26,6 @@ describe('Test stats (excluding redundancy)', function () { before(async function () { this.timeout(60000) - - await flushTests() servers = await flushAndRunMultipleServers(3) await setAccessTokensToServers(servers) @@ -37,9 +35,9 @@ describe('Test stats (excluding redundancy)', 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') @@ -60,12 +58,12 @@ describe('Test stats (excluding redundancy)', 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) expect(data.totalInstanceFollowers).to.equal(2) expect(data.totalInstanceFollowing).to.equal(1) - expect(data.videosRedundancy).to.have.lengthOf(0) }) it('Should have the correct stats on instance 2', async function () { @@ -75,12 +73,12 @@ describe('Test stats (excluding redundancy)', 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) expect(data.totalInstanceFollowers).to.equal(1) expect(data.totalInstanceFollowing).to.equal(1) - expect(data.videosRedundancy).to.have.lengthOf(0) }) it('Should have the correct stats on instance 3', async function () { @@ -95,10 +93,9 @@ describe('Test stats (excluding redundancy)', function () { expect(data.totalVideos).to.equal(1) expect(data.totalInstanceFollowing).to.equal(1) expect(data.totalInstanceFollowers).to.equal(0) - expect(data.videosRedundancy).to.have.lengthOf(0) }) after(async function () { - killallServers(servers) + await cleanupTests(servers) }) })