]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/videos-common-filters.ts
Fix s3 mock cleanup
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / videos-common-filters.ts
index 1ab78ac498803d4326f2e1d3fdb127faaf96d4f3..30251706b6d74b27b3c4142f78de2b60ad083ced 100644 (file)
@@ -162,13 +162,23 @@ describe('Test videos filter', function () {
       tagsAllOf?: string[]
       token?: string
       expectedStatus?: HttpStatusCode
+      excludeAlreadyWatched?: boolean
     }) {
       const res = await makeGetRequest({
         url: options.server.url,
         path: options.path,
         token: options.token ?? options.server.accessToken,
         query: {
-          ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf', 'hasWebtorrentFiles', 'hasHLSFiles', 'privacyOneOf' ]),
+          ...pick(options, [
+            'isLocal',
+            'include',
+            'category',
+            'tagsAllOf',
+            'hasWebtorrentFiles',
+            'hasHLSFiles',
+            'privacyOneOf',
+            'excludeAlreadyWatched'
+          ]),
 
           sort: 'createdAt'
         },
@@ -187,6 +197,7 @@ describe('Test videos filter', function () {
         token?: string
         expectedStatus?: HttpStatusCode
         skipSubscription?: boolean
+        excludeAlreadyWatched?: boolean
       }
     ) {
       const { skipSubscription = false } = options
@@ -525,6 +536,25 @@ describe('Test videos filter', function () {
         }
       }
     })
+
+    it('Should filter already watched videos by the user', async function () {
+      const { id } = await servers[0].videos.upload({ attributes: { name: 'video for history' } })
+
+      for (const path of paths) {
+        const videos = await listVideos({ server: servers[0], path, isLocal: true, excludeAlreadyWatched: true })
+        const foundVideo = videos.find(video => video.id === id)
+
+        expect(foundVideo).to.not.be.undefined
+      }
+      await servers[0].views.view({ id, token: servers[0].accessToken })
+
+      for (const path of paths) {
+        const videos = await listVideos({ server: servers[0], path, excludeAlreadyWatched: true })
+        const foundVideo = videos.find(video => video.id === id)
+
+        expect(foundVideo).to.be.undefined
+      }
+    })
   })
 
   after(async function () {