diff options
author | Wicklow <123956049+wickloww@users.noreply.github.com> | 2023-04-12 07:32:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 09:32:20 +0200 |
commit | 2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9 (patch) | |
tree | dfe4b6e1e06f617f8968285ca394e73fedefe6b2 /server/tests/api/check-params | |
parent | 0cda019c1d1f77e06e524362880c38e93b1f5c70 (diff) | |
download | PeerTube-2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9.tar.gz PeerTube-2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9.tar.zst PeerTube-2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9.zip |
Feature/filter already watched videos (#5739)
* filter already watched videos
* Updated code based on review comments
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/videos-common-filters.ts | 19 |
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 () { |