aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos-history.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-24 13:36:47 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commitb211106695bb82f6c32e53306081b5262c3d109d (patch)
treefa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/tests/api/check-params/videos-history.ts
parent69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff)
downloadPeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.gz
PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.zst
PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.zip
Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint * Merge watching and view endpoints * Introduce WatchAction AP activity * Add tables to store viewer information of local videos * Add endpoints to fetch video views/viewers stats of local videos * Refactor views/viewers handlers * Support "views" and "viewers" counters for both VOD and live videos
Diffstat (limited to 'server/tests/api/check-params/videos-history.ts')
-rw-r--r--server/tests/api/check-params/videos-history.ts46
1 files changed, 5 insertions, 41 deletions
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 82f38b7b4..c1b2d8bf3 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -17,7 +17,7 @@ import {
17describe('Test videos history API validator', function () { 17describe('Test videos history API validator', function () {
18 const myHistoryPath = '/api/v1/users/me/history/videos' 18 const myHistoryPath = '/api/v1/users/me/history/videos'
19 const myHistoryRemove = myHistoryPath + '/remove' 19 const myHistoryRemove = myHistoryPath + '/remove'
20 let watchingPath: string 20 let viewPath: string
21 let server: PeerTubeServer 21 let server: PeerTubeServer
22 let videoId: number 22 let videoId: number
23 23
@@ -31,51 +31,15 @@ describe('Test videos history API validator', function () {
31 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
32 32
33 const { id, uuid } = await server.videos.upload() 33 const { id, uuid } = await server.videos.upload()
34 watchingPath = '/api/v1/videos/' + uuid + '/watching' 34 viewPath = '/api/v1/videos/' + uuid + '/views'
35 videoId = id 35 videoId = id
36 }) 36 })
37 37
38 describe('When notifying a user is watching a video', function () { 38 describe('When notifying a user is watching a video', function () {
39 39
40 it('Should fail with an unauthenticated user', async function () { 40 it('Should fail with a bad token', async function () {
41 const fields = { currentTime: 5 }
42 await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
43 })
44
45 it('Should fail with an incorrect video id', async function () {
46 const fields = { currentTime: 5 } 41 const fields = { currentTime: 5 }
47 const path = '/api/v1/videos/blabla/watching' 42 await makePutBodyRequest({ url: server.url, path: viewPath, fields, token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
48 await makePutBodyRequest({
49 url: server.url,
50 path,
51 fields,
52 token: server.accessToken,
53 expectedStatus: HttpStatusCode.BAD_REQUEST_400
54 })
55 })
56
57 it('Should fail with an unknown video', async function () {
58 const fields = { currentTime: 5 }
59 const path = '/api/v1/videos/d91fff41-c24d-4508-8e13-3bd5902c3b02/watching'
60
61 await makePutBodyRequest({
62 url: server.url,
63 path,
64 fields,
65 token: server.accessToken,
66 expectedStatus: HttpStatusCode.NOT_FOUND_404
67 })
68 })
69
70 it('Should fail with a bad current time', async function () {
71 const fields = { currentTime: 'hello' }
72 await makePutBodyRequest({
73 url: server.url,
74 path: watchingPath,
75 fields,
76 token: server.accessToken,
77 expectedStatus: HttpStatusCode.BAD_REQUEST_400
78 })
79 }) 43 })
80 44
81 it('Should succeed with the correct parameters', async function () { 45 it('Should succeed with the correct parameters', async function () {
@@ -83,7 +47,7 @@ describe('Test videos history API validator', function () {
83 47
84 await makePutBodyRequest({ 48 await makePutBodyRequest({
85 url: server.url, 49 url: server.url,
86 path: watchingPath, 50 path: viewPath,
87 fields, 51 fields,
88 token: server.accessToken, 52 token: server.accessToken,
89 expectedStatus: HttpStatusCode.NO_CONTENT_204 53 expectedStatus: HttpStatusCode.NO_CONTENT_204