X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideos-history.ts;h=b25cff879603fc97e60ee4468507521448a6a6ef;hb=657bba2b29715f654264422d868e3e661bbdf895;hp=f7d3a6aeb0ab0717c1ed9a2f951aee0d09de4100;hpb=8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index f7d3a6aeb..b25cff879 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -1,14 +1,15 @@ -/* 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, reRunServer, - runServer, + killallServers, + reRunServer, searchVideoWithToken, ServerInfo, setAccessTokensToServers, @@ -16,9 +17,10 @@ import { uploadVideo, userLogin, wait -} from '../../../../shared/utils' +} 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 @@ -33,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 ]) @@ -58,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) }) @@ -152,6 +152,15 @@ describe('Test videos history', function () { expect(res.body.data).to.have.lengthOf(0) }) + it('Should be able to search through videos in my history', async function () { + const res = await listMyVideosHistory(server.url, server.accessToken, '2') + + expect(res.body.total).to.equal(1) + + const videos: Video[] = res.body.data + expect(videos[0].name).to.equal('video 2') + }) + it('Should clear my history', async function () { await removeMyVideosHistory(server.url, server.accessToken, video3WatchedDate.toISOString()) }) @@ -172,7 +181,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 () { @@ -223,11 +232,6 @@ describe('Test videos history', function () { }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })