]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/videos-history.ts
Move AP request in requests file
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / videos-history.ts
index c7e55c1ab7625a2dbe043e9a0f4e281e30716b7a..209b93014420e8a75c1178784bd29b61a542ca6e 100644 (file)
@@ -1,7 +1,8 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import * as chai from 'chai'
 import 'mocha'
+import * as chai from 'chai'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
   cleanupTests,
   createUser,
@@ -10,16 +11,15 @@ import {
   getVideoWithToken,
   killallServers,
   reRunServer,
-  searchVideoWithToken,
   ServerInfo,
   setAccessTokensToServers,
   updateMyUser,
   uploadVideo,
   userLogin,
   wait
-} from '../../../../shared/extra-utils'
-import { Video, VideoDetails } from '../../../../shared/models/videos'
-import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history'
+} from '@shared/extra-utils'
+import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '@shared/extra-utils/videos/video-history'
+import { Video, VideoDetails } from '@shared/models'
 
 const expect = chai.expect
 
@@ -88,8 +88,8 @@ describe('Test videos history', function () {
     }
 
     {
-      const res = await searchVideoWithToken(server.url, 'video', server.accessToken)
-      videosOfVideos.push(res.body.data)
+      const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' })
+      videosOfVideos.push(body.data)
     }
 
     for (const videos of videosOfVideos) {
@@ -151,6 +151,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())
   })
@@ -171,7 +180,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 () {