diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/check-params/videos-history.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/check-params/videos-history.ts')
-rw-r--r-- | server/tests/api/check-params/videos-history.ts | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 0e91fe0a8..c3c309ed2 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts | |||
@@ -5,42 +5,39 @@ import { | |||
5 | checkBadCountPagination, | 5 | checkBadCountPagination, |
6 | checkBadStartPagination, | 6 | checkBadStartPagination, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | flushAndRunServer, | 8 | createSingleServer, |
9 | makeGetRequest, | 9 | makeGetRequest, |
10 | makePostBodyRequest, | 10 | makePostBodyRequest, |
11 | makePutBodyRequest, | 11 | makePutBodyRequest, |
12 | ServerInfo, | 12 | PeerTubeServer, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
14 | uploadVideo | 14 | } from '@shared/extra-utils' |
15 | } from '../../../../shared/extra-utils' | 15 | import { HttpStatusCode } from '@shared/models' |
16 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
17 | 16 | ||
18 | describe('Test videos history API validator', function () { | 17 | describe('Test videos history API validator', function () { |
19 | const myHistoryPath = '/api/v1/users/me/history/videos' | 18 | const myHistoryPath = '/api/v1/users/me/history/videos' |
20 | const myHistoryRemove = myHistoryPath + '/remove' | 19 | const myHistoryRemove = myHistoryPath + '/remove' |
21 | let watchingPath: string | 20 | let watchingPath: string |
22 | let server: ServerInfo | 21 | let server: PeerTubeServer |
23 | 22 | ||
24 | // --------------------------------------------------------------- | 23 | // --------------------------------------------------------------- |
25 | 24 | ||
26 | before(async function () { | 25 | before(async function () { |
27 | this.timeout(30000) | 26 | this.timeout(30000) |
28 | 27 | ||
29 | server = await flushAndRunServer(1) | 28 | server = await createSingleServer(1) |
30 | 29 | ||
31 | await setAccessTokensToServers([ server ]) | 30 | await setAccessTokensToServers([ server ]) |
32 | 31 | ||
33 | const res = await uploadVideo(server.url, server.accessToken, {}) | 32 | const { uuid } = await server.videos.upload() |
34 | const videoUUID = res.body.video.uuid | 33 | watchingPath = '/api/v1/videos/' + uuid + '/watching' |
35 | |||
36 | watchingPath = '/api/v1/videos/' + videoUUID + '/watching' | ||
37 | }) | 34 | }) |
38 | 35 | ||
39 | describe('When notifying a user is watching a video', function () { | 36 | describe('When notifying a user is watching a video', function () { |
40 | 37 | ||
41 | it('Should fail with an unauthenticated user', async function () { | 38 | it('Should fail with an unauthenticated user', async function () { |
42 | const fields = { currentTime: 5 } | 39 | const fields = { currentTime: 5 } |
43 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 40 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
44 | }) | 41 | }) |
45 | 42 | ||
46 | it('Should fail with an incorrect video id', async function () { | 43 | it('Should fail with an incorrect video id', async function () { |
@@ -51,7 +48,7 @@ describe('Test videos history API validator', function () { | |||
51 | path, | 48 | path, |
52 | fields, | 49 | fields, |
53 | token: server.accessToken, | 50 | token: server.accessToken, |
54 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 51 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
55 | }) | 52 | }) |
56 | }) | 53 | }) |
57 | 54 | ||
@@ -64,7 +61,7 @@ describe('Test videos history API validator', function () { | |||
64 | path, | 61 | path, |
65 | fields, | 62 | fields, |
66 | token: server.accessToken, | 63 | token: server.accessToken, |
67 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 64 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
68 | }) | 65 | }) |
69 | }) | 66 | }) |
70 | 67 | ||
@@ -75,7 +72,7 @@ describe('Test videos history API validator', function () { | |||
75 | path: watchingPath, | 72 | path: watchingPath, |
76 | fields, | 73 | fields, |
77 | token: server.accessToken, | 74 | token: server.accessToken, |
78 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 75 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
79 | }) | 76 | }) |
80 | }) | 77 | }) |
81 | 78 | ||
@@ -87,7 +84,7 @@ describe('Test videos history API validator', function () { | |||
87 | path: watchingPath, | 84 | path: watchingPath, |
88 | fields, | 85 | fields, |
89 | token: server.accessToken, | 86 | token: server.accessToken, |
90 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 87 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
91 | }) | 88 | }) |
92 | }) | 89 | }) |
93 | }) | 90 | }) |
@@ -102,17 +99,17 @@ describe('Test videos history API validator', function () { | |||
102 | }) | 99 | }) |
103 | 100 | ||
104 | it('Should fail with an unauthenticated user', async function () { | 101 | it('Should fail with an unauthenticated user', async function () { |
105 | await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 102 | await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
106 | }) | 103 | }) |
107 | 104 | ||
108 | it('Should succeed with the correct params', async function () { | 105 | it('Should succeed with the correct params', async function () { |
109 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 106 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 }) |
110 | }) | 107 | }) |
111 | }) | 108 | }) |
112 | 109 | ||
113 | describe('When removing user videos history', function () { | 110 | describe('When removing user videos history', function () { |
114 | it('Should fail with an unauthenticated user', async function () { | 111 | it('Should fail with an unauthenticated user', async function () { |
115 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 112 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
116 | }) | 113 | }) |
117 | 114 | ||
118 | it('Should fail with a bad beforeDate parameter', async function () { | 115 | it('Should fail with a bad beforeDate parameter', async function () { |
@@ -122,7 +119,7 @@ describe('Test videos history API validator', function () { | |||
122 | token: server.accessToken, | 119 | token: server.accessToken, |
123 | path: myHistoryRemove, | 120 | path: myHistoryRemove, |
124 | fields: body, | 121 | fields: body, |
125 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 122 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
126 | }) | 123 | }) |
127 | }) | 124 | }) |
128 | 125 | ||
@@ -133,7 +130,7 @@ describe('Test videos history API validator', function () { | |||
133 | token: server.accessToken, | 130 | token: server.accessToken, |
134 | path: myHistoryRemove, | 131 | path: myHistoryRemove, |
135 | fields: body, | 132 | fields: body, |
136 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 133 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
137 | }) | 134 | }) |
138 | }) | 135 | }) |
139 | 136 | ||
@@ -142,7 +139,7 @@ describe('Test videos history API validator', function () { | |||
142 | url: server.url, | 139 | url: server.url, |
143 | token: server.accessToken, | 140 | token: server.accessToken, |
144 | path: myHistoryRemove, | 141 | path: myHistoryRemove, |
145 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 142 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
146 | }) | 143 | }) |
147 | }) | 144 | }) |
148 | }) | 145 | }) |