From 2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9 Mon Sep 17 00:00:00 2001 From: Wicklow <123956049+wickloww@users.noreply.github.com> Date: Wed, 12 Apr 2023 07:32:20 +0000 Subject: Feature/filter already watched videos (#5739) * filter already watched videos * Updated code based on review comments --- server/tests/api/videos/videos-common-filters.ts | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'server/tests/api/videos') 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 () { -- cgit v1.2.3