X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideos-history.ts;h=ab40bb64cb76c1455b445a22c5b05dc661e8f1aa;hb=1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a;hp=f654a422bd45eff49ae18dd0fd50944df6f1b775;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;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..ab40bb64c 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -7,14 +7,15 @@ import { flushTests, getVideosListWithToken, getVideoWithToken, - killallServers, + killallServers, reRunServer, runServer, searchVideoWithToken, ServerInfo, setAccessTokensToServers, updateMyUser, uploadVideo, - userLogin + userLogin, + wait } from '../../../../shared/utils' import { Video, VideoDetails } from '../../../../shared/models/videos' import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/utils/videos/video-history' @@ -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) }) @@ -192,6 +193,35 @@ describe('Test videos history', function () { expect(videos[1].name).to.equal('video 3') }) + it('Should not clean old history', async function () { + this.timeout(50000) + + killallServers([ server ]) + + 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 () { killallServers([ server ])