aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/videos-history.ts37
1 files changed, 35 insertions, 2 deletions
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 31a0752c7..82f38b7b4 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -6,6 +6,7 @@ import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
9 makeDeleteRequest,
9 makeGetRequest, 10 makeGetRequest,
10 makePostBodyRequest, 11 makePostBodyRequest,
11 makePutBodyRequest, 12 makePutBodyRequest,
@@ -18,6 +19,7 @@ describe('Test videos history API validator', function () {
18 const myHistoryRemove = myHistoryPath + '/remove' 19 const myHistoryRemove = myHistoryPath + '/remove'
19 let watchingPath: string 20 let watchingPath: string
20 let server: PeerTubeServer 21 let server: PeerTubeServer
22 let videoId: number
21 23
22 // --------------------------------------------------------------- 24 // ---------------------------------------------------------------
23 25
@@ -28,8 +30,9 @@ describe('Test videos history API validator', function () {
28 30
29 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
30 32
31 const { uuid } = await server.videos.upload() 33 const { id, uuid } = await server.videos.upload()
32 watchingPath = '/api/v1/videos/' + uuid + '/watching' 34 watchingPath = '/api/v1/videos/' + uuid + '/watching'
35 videoId = id
33 }) 36 })
34 37
35 describe('When notifying a user is watching a video', function () { 38 describe('When notifying a user is watching a video', function () {
@@ -106,7 +109,37 @@ describe('Test videos history API validator', function () {
106 }) 109 })
107 }) 110 })
108 111
109 describe('When removing user videos history', function () { 112 describe('When removing a specific user video history element', function () {
113 let path: string
114
115 before(function () {
116 path = myHistoryPath + '/' + videoId
117 })
118
119 it('Should fail with an unauthenticated user', async function () {
120 await makeDeleteRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
121 })
122
123 it('Should fail with a bad videoId parameter', async function () {
124 await makeDeleteRequest({
125 url: server.url,
126 token: server.accessToken,
127 path: myHistoryRemove + '/hi',
128 expectedStatus: HttpStatusCode.BAD_REQUEST_400
129 })
130 })
131
132 it('Should succeed with the correct parameters', async function () {
133 await makeDeleteRequest({
134 url: server.url,
135 token: server.accessToken,
136 path,
137 expectedStatus: HttpStatusCode.NO_CONTENT_204
138 })
139 })
140 })
141
142 describe('When removing all user videos history', function () {
110 it('Should fail with an unauthenticated user', async function () { 143 it('Should fail with an unauthenticated user', async function () {
111 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 144 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
112 }) 145 })