aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorWicklow <123956049+wickloww@users.noreply.github.com>2023-04-12 07:32:20 +0000
committerGitHub <noreply@github.com>2023-04-12 09:32:20 +0200
commit2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9 (patch)
treedfe4b6e1e06f617f8968285ca394e73fedefe6b2 /server/tests/api/videos
parent0cda019c1d1f77e06e524362880c38e93b1f5c70 (diff)
downloadPeerTube-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/videos')
-rw-r--r--server/tests/api/videos/videos-common-filters.ts32
1 files changed, 31 insertions, 1 deletions
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts
index 1ab78ac49..30251706b 100644
--- a/server/tests/api/videos/videos-common-filters.ts
+++ b/server/tests/api/videos/videos-common-filters.ts
@@ -162,13 +162,23 @@ describe('Test videos filter', function () {
162 tagsAllOf?: string[] 162 tagsAllOf?: string[]
163 token?: string 163 token?: string
164 expectedStatus?: HttpStatusCode 164 expectedStatus?: HttpStatusCode
165 excludeAlreadyWatched?: boolean
165 }) { 166 }) {
166 const res = await makeGetRequest({ 167 const res = await makeGetRequest({
167 url: options.server.url, 168 url: options.server.url,
168 path: options.path, 169 path: options.path,
169 token: options.token ?? options.server.accessToken, 170 token: options.token ?? options.server.accessToken,
170 query: { 171 query: {
171 ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf', 'hasWebtorrentFiles', 'hasHLSFiles', 'privacyOneOf' ]), 172 ...pick(options, [
173 'isLocal',
174 'include',
175 'category',
176 'tagsAllOf',
177 'hasWebtorrentFiles',
178 'hasHLSFiles',
179 'privacyOneOf',
180 'excludeAlreadyWatched'
181 ]),
172 182
173 sort: 'createdAt' 183 sort: 'createdAt'
174 }, 184 },
@@ -187,6 +197,7 @@ describe('Test videos filter', function () {
187 token?: string 197 token?: string
188 expectedStatus?: HttpStatusCode 198 expectedStatus?: HttpStatusCode
189 skipSubscription?: boolean 199 skipSubscription?: boolean
200 excludeAlreadyWatched?: boolean
190 } 201 }
191 ) { 202 ) {
192 const { skipSubscription = false } = options 203 const { skipSubscription = false } = options
@@ -525,6 +536,25 @@ describe('Test videos filter', function () {
525 } 536 }
526 } 537 }
527 }) 538 })
539
540 it('Should filter already watched videos by the user', async function () {
541 const { id } = await servers[0].videos.upload({ attributes: { name: 'video for history' } })
542
543 for (const path of paths) {
544 const videos = await listVideos({ server: servers[0], path, isLocal: true, excludeAlreadyWatched: true })
545 const foundVideo = videos.find(video => video.id === id)
546
547 expect(foundVideo).to.not.be.undefined
548 }
549 await servers[0].views.view({ id, token: servers[0].accessToken })
550
551 for (const path of paths) {
552 const videos = await listVideos({ server: servers[0], path, excludeAlreadyWatched: true })
553 const foundVideo = videos.find(video => video.id === id)
554
555 expect(foundVideo).to.be.undefined
556 }
557 })
528 }) 558 })
529 559
530 after(async function () { 560 after(async function () {