X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideos-history.ts;h=661d603cb9a369cc2765d44d597669bce1ecd553;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=f654a422bd45eff49ae18dd0fd50944df6f1b775;hpb=73471b1a52f242e86364ffb077ea6cadb3b07ae2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index f654a422b..661d603cb 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -1,23 +1,26 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import * as chai from 'chai' import 'mocha' import { + cleanupTests, createUser, - flushTests, + flushAndRunServer, getVideosListWithToken, getVideoWithToken, killallServers, - runServer, + reRunServer, searchVideoWithToken, ServerInfo, setAccessTokensToServers, updateMyUser, uploadVideo, - userLogin -} from '../../../../shared/utils' + userLogin, + wait +} from '../../../../shared/extra-utils' import { Video, VideoDetails } from '../../../../shared/models/videos' -import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/utils/videos/video-history' +import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect @@ -32,9 +35,7 @@ describe('Test videos history', function () { before(async function () { this.timeout(30000) - await flushTests() - - server = await runServer(1) + server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) @@ -57,7 +58,7 @@ describe('Test videos history', function () { username: 'user_1', password: 'super password' } - await createUser(server.url, server.accessToken, user.username, user.password) + await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) userAccessToken = await userLogin(server, user) }) @@ -171,7 +172,7 @@ describe('Test videos history', function () { videosHistoryEnabled: false }) - await userWatchVideo(server.url, server.accessToken, video2UUID, 8, 409) + await userWatchVideo(server.url, server.accessToken, video2UUID, 8, HttpStatusCode.CONFLICT_409) }) it('Should re-enable videos history', async function () { @@ -192,12 +193,36 @@ describe('Test videos history', function () { expect(videos[1].name).to.equal('video 3') }) - after(async function () { + it('Should not clean old history', async function () { + this.timeout(50000) + killallServers([ server ]) - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await reRunServer(server, { history: { videos: { max_age: '10 days' } } }) + + await wait(6000) + + // Should still have history + + const res = await listMyVideosHistory(server.url, server.accessToken) + + expect(res.body.total).to.equal(2) + }) + + it('Should clean old history', async function () { + this.timeout(50000) + + killallServers([ server ]) + + await reRunServer(server, { history: { videos: { max_age: '5 seconds' } } }) + + await wait(6000) + + const res = await listMyVideosHistory(server.url, server.accessToken) + expect(res.body.total).to.equal(0) + }) + + after(async function () { + await cleanupTests([ server ]) }) })