X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideos-common-filters.ts;h=30251706b6d74b27b3c4142f78de2b60ad083ced;hb=cffef25313bdf7a6c435f56ac6715fdd91acf7b3;hp=1ab78ac498803d4326f2e1d3fdb127faaf96d4f3;hpb=5ccf98a4ecc39d1b50df5b748e885683f71276a9;p=github%2FChocobozzz%2FPeerTube.git 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 () { 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 () {