diff options
Diffstat (limited to 'server/tests/api/check-params/videos-history.ts')
-rw-r--r-- | server/tests/api/check-params/videos-history.ts | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 941f62654..0e91fe0a8 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts | |||
@@ -13,6 +13,7 @@ import { | |||
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | uploadVideo | 14 | uploadVideo |
15 | } from '../../../../shared/extra-utils' | 15 | } from '../../../../shared/extra-utils' |
16 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
16 | 17 | ||
17 | describe('Test videos history API validator', function () { | 18 | describe('Test videos history API validator', function () { |
18 | const myHistoryPath = '/api/v1/users/me/history/videos' | 19 | const myHistoryPath = '/api/v1/users/me/history/videos' |
@@ -39,31 +40,55 @@ describe('Test videos history API validator', function () { | |||
39 | 40 | ||
40 | it('Should fail with an unauthenticated user', async function () { | 41 | it('Should fail with an unauthenticated user', async function () { |
41 | const fields = { currentTime: 5 } | 42 | const fields = { currentTime: 5 } |
42 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: 401 }) | 43 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
43 | }) | 44 | }) |
44 | 45 | ||
45 | it('Should fail with an incorrect video id', async function () { | 46 | it('Should fail with an incorrect video id', async function () { |
46 | const fields = { currentTime: 5 } | 47 | const fields = { currentTime: 5 } |
47 | const path = '/api/v1/videos/blabla/watching' | 48 | const path = '/api/v1/videos/blabla/watching' |
48 | await makePutBodyRequest({ url: server.url, path, fields, token: server.accessToken, statusCodeExpected: 400 }) | 49 | await makePutBodyRequest({ |
50 | url: server.url, | ||
51 | path, | ||
52 | fields, | ||
53 | token: server.accessToken, | ||
54 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | ||
55 | }) | ||
49 | }) | 56 | }) |
50 | 57 | ||
51 | it('Should fail with an unknown video', async function () { | 58 | it('Should fail with an unknown video', async function () { |
52 | const fields = { currentTime: 5 } | 59 | const fields = { currentTime: 5 } |
53 | const path = '/api/v1/videos/d91fff41-c24d-4508-8e13-3bd5902c3b02/watching' | 60 | const path = '/api/v1/videos/d91fff41-c24d-4508-8e13-3bd5902c3b02/watching' |
54 | 61 | ||
55 | await makePutBodyRequest({ url: server.url, path, fields, token: server.accessToken, statusCodeExpected: 404 }) | 62 | await makePutBodyRequest({ |
63 | url: server.url, | ||
64 | path, | ||
65 | fields, | ||
66 | token: server.accessToken, | ||
67 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | ||
68 | }) | ||
56 | }) | 69 | }) |
57 | 70 | ||
58 | it('Should fail with a bad current time', async function () { | 71 | it('Should fail with a bad current time', async function () { |
59 | const fields = { currentTime: 'hello' } | 72 | const fields = { currentTime: 'hello' } |
60 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, token: server.accessToken, statusCodeExpected: 400 }) | 73 | await makePutBodyRequest({ |
74 | url: server.url, | ||
75 | path: watchingPath, | ||
76 | fields, | ||
77 | token: server.accessToken, | ||
78 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | ||
79 | }) | ||
61 | }) | 80 | }) |
62 | 81 | ||
63 | it('Should succeed with the correct parameters', async function () { | 82 | it('Should succeed with the correct parameters', async function () { |
64 | const fields = { currentTime: 5 } | 83 | const fields = { currentTime: 5 } |
65 | 84 | ||
66 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, token: server.accessToken, statusCodeExpected: 204 }) | 85 | await makePutBodyRequest({ |
86 | url: server.url, | ||
87 | path: watchingPath, | ||
88 | fields, | ||
89 | token: server.accessToken, | ||
90 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | ||
91 | }) | ||
67 | }) | 92 | }) |
68 | }) | 93 | }) |
69 | 94 | ||
@@ -77,17 +102,17 @@ describe('Test videos history API validator', function () { | |||
77 | }) | 102 | }) |
78 | 103 | ||
79 | it('Should fail with an unauthenticated user', async function () { | 104 | it('Should fail with an unauthenticated user', async function () { |
80 | await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: 401 }) | 105 | await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
81 | }) | 106 | }) |
82 | 107 | ||
83 | it('Should succeed with the correct params', async function () { | 108 | it('Should succeed with the correct params', async function () { |
84 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: 200 }) | 109 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) |
85 | }) | 110 | }) |
86 | }) | 111 | }) |
87 | 112 | ||
88 | describe('When removing user videos history', function () { | 113 | describe('When removing user videos history', function () { |
89 | it('Should fail with an unauthenticated user', async function () { | 114 | it('Should fail with an unauthenticated user', async function () { |
90 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: 401 }) | 115 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
91 | }) | 116 | }) |
92 | 117 | ||
93 | it('Should fail with a bad beforeDate parameter', async function () { | 118 | it('Should fail with a bad beforeDate parameter', async function () { |
@@ -97,7 +122,7 @@ describe('Test videos history API validator', function () { | |||
97 | token: server.accessToken, | 122 | token: server.accessToken, |
98 | path: myHistoryRemove, | 123 | path: myHistoryRemove, |
99 | fields: body, | 124 | fields: body, |
100 | statusCodeExpected: 400 | 125 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 |
101 | }) | 126 | }) |
102 | }) | 127 | }) |
103 | 128 | ||
@@ -108,7 +133,7 @@ describe('Test videos history API validator', function () { | |||
108 | token: server.accessToken, | 133 | token: server.accessToken, |
109 | path: myHistoryRemove, | 134 | path: myHistoryRemove, |
110 | fields: body, | 135 | fields: body, |
111 | statusCodeExpected: 204 | 136 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 |
112 | }) | 137 | }) |
113 | }) | 138 | }) |
114 | 139 | ||
@@ -117,7 +142,7 @@ describe('Test videos history API validator', function () { | |||
117 | url: server.url, | 142 | url: server.url, |
118 | token: server.accessToken, | 143 | token: server.accessToken, |
119 | path: myHistoryRemove, | 144 | path: myHistoryRemove, |
120 | statusCodeExpected: 204 | 145 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 |
121 | }) | 146 | }) |
122 | }) | 147 | }) |
123 | }) | 148 | }) |