aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos-common-filters.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/videos-common-filters.ts')
-rw-r--r--server/tests/api/check-params/videos-common-filters.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/server/tests/api/check-params/videos-common-filters.ts b/server/tests/api/check-params/videos-common-filters.ts
index 11d9fd95b..3e44e2f67 100644
--- a/server/tests/api/check-params/videos-common-filters.ts
+++ b/server/tests/api/check-params/videos-common-filters.ts
@@ -122,6 +122,8 @@ describe('Test video filters validators', function () {
122 include?: VideoInclude 122 include?: VideoInclude
123 privacyOneOf?: VideoPrivacy[] 123 privacyOneOf?: VideoPrivacy[]
124 expectedStatus: HttpStatusCode 124 expectedStatus: HttpStatusCode
125 excludeAlreadyWatched?: boolean
126 unauthenticatedUser?: boolean
125 }) { 127 }) {
126 const paths = [ 128 const paths = [
127 '/api/v1/video-channels/root_channel/videos', 129 '/api/v1/video-channels/root_channel/videos',
@@ -131,14 +133,19 @@ describe('Test video filters validators', function () {
131 ] 133 ]
132 134
133 for (const path of paths) { 135 for (const path of paths) {
136 const token = options.unauthenticatedUser
137 ? undefined
138 : options.token || server.accessToken
139
134 await makeGetRequest({ 140 await makeGetRequest({
135 url: server.url, 141 url: server.url,
136 path, 142 path,
137 token: options.token || server.accessToken, 143 token,
138 query: { 144 query: {
139 isLocal: options.isLocal, 145 isLocal: options.isLocal,
140 privacyOneOf: options.privacyOneOf, 146 privacyOneOf: options.privacyOneOf,
141 include: options.include 147 include: options.include,
148 excludeAlreadyWatched: options.excludeAlreadyWatched
142 }, 149 },
143 expectedStatus: options.expectedStatus 150 expectedStatus: options.expectedStatus
144 }) 151 })
@@ -213,6 +220,14 @@ describe('Test video filters validators', function () {
213 } 220 }
214 }) 221 })
215 }) 222 })
223
224 it('Should fail when trying to exclude already watched videos for an unlogged user', async function () {
225 await testEndpoints({ excludeAlreadyWatched: true, unauthenticatedUser: true, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
226 })
227
228 it('Should succeed when trying to exclude already watched videos for a logged user', async function () {
229 await testEndpoints({ token: userAccessToken, excludeAlreadyWatched: true, expectedStatus: HttpStatusCode.OK_200 })
230 })
216 }) 231 })
217 232
218 after(async function () { 233 after(async function () {