aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-history.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/videos-history.ts')
-rw-r--r--server/tests/api/videos/videos-history.ts38
1 files changed, 15 insertions, 23 deletions
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index aa0623f7d..8614078f1 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -6,17 +6,14 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 flushAndRunServer, 8 flushAndRunServer,
9 getVideosListWithToken,
10 getVideoWithToken,
11 HistoryCommand, 9 HistoryCommand,
12 killallServers, 10 killallServers,
13 reRunServer, 11 reRunServer,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 uploadVideo,
17 wait 14 wait
18} from '@shared/extra-utils' 15} from '@shared/extra-utils'
19import { Video, VideoDetails } from '@shared/models' 16import { Video } from '@shared/models'
20 17
21const expect = chai.expect 18const expect = chai.expect
22 19
@@ -39,18 +36,18 @@ describe('Test videos history', function () {
39 command = server.historyCommand 36 command = server.historyCommand
40 37
41 { 38 {
42 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) 39 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 1' } })
43 video1UUID = res.body.video.uuid 40 video1UUID = uuid
44 } 41 }
45 42
46 { 43 {
47 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) 44 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 2' } })
48 video2UUID = res.body.video.uuid 45 video2UUID = uuid
49 } 46 }
50 47
51 { 48 {
52 const res = await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) 49 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 3' } })
53 video3UUID = res.body.video.uuid 50 video3UUID = uuid
54 } 51 }
55 52
56 const user = { 53 const user = {
@@ -62,12 +59,10 @@ describe('Test videos history', function () {
62 }) 59 })
63 60
64 it('Should get videos, without watching history', async function () { 61 it('Should get videos, without watching history', async function () {
65 const res = await getVideosListWithToken(server.url, server.accessToken) 62 const { data } = await server.videosCommand.listWithToken()
66 const videos: Video[] = res.body.data
67 63
68 for (const video of videos) { 64 for (const video of data) {
69 const resDetail = await getVideoWithToken(server.url, server.accessToken, video.id) 65 const videoDetails = await server.videosCommand.getWithToken({ id: video.id })
70 const videoDetails: VideoDetails = resDetail.body
71 66
72 expect(video.userHistory).to.be.undefined 67 expect(video.userHistory).to.be.undefined
73 expect(videoDetails.userHistory).to.be.undefined 68 expect(videoDetails.userHistory).to.be.undefined
@@ -83,8 +78,8 @@ describe('Test videos history', function () {
83 const videosOfVideos: Video[][] = [] 78 const videosOfVideos: Video[][] = []
84 79
85 { 80 {
86 const res = await getVideosListWithToken(server.url, server.accessToken) 81 const { data } = await server.videosCommand.listWithToken()
87 videosOfVideos.push(res.body.data) 82 videosOfVideos.push(data)
88 } 83 }
89 84
90 { 85 {
@@ -107,24 +102,21 @@ describe('Test videos history', function () {
107 } 102 }
108 103
109 { 104 {
110 const resDetail = await getVideoWithToken(server.url, server.accessToken, video1UUID) 105 const videoDetails = await server.videosCommand.getWithToken({ id: video1UUID })
111 const videoDetails: VideoDetails = resDetail.body
112 106
113 expect(videoDetails.userHistory).to.not.be.undefined 107 expect(videoDetails.userHistory).to.not.be.undefined
114 expect(videoDetails.userHistory.currentTime).to.equal(3) 108 expect(videoDetails.userHistory.currentTime).to.equal(3)
115 } 109 }
116 110
117 { 111 {
118 const resDetail = await getVideoWithToken(server.url, server.accessToken, video2UUID) 112 const videoDetails = await server.videosCommand.getWithToken({ id: video2UUID })
119 const videoDetails: VideoDetails = resDetail.body
120 113
121 expect(videoDetails.userHistory).to.not.be.undefined 114 expect(videoDetails.userHistory).to.not.be.undefined
122 expect(videoDetails.userHistory.currentTime).to.equal(8) 115 expect(videoDetails.userHistory.currentTime).to.equal(8)
123 } 116 }
124 117
125 { 118 {
126 const resDetail = await getVideoWithToken(server.url, server.accessToken, video3UUID) 119 const videoDetails = await server.videosCommand.getWithToken({ id: video3UUID })
127 const videoDetails: VideoDetails = resDetail.body
128 120
129 expect(videoDetails.userHistory).to.be.undefined 121 expect(videoDetails.userHistory).to.be.undefined
130 } 122 }