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 --- .../tests/api/check-params/videos-common-filters.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'server/tests/api/check-params') 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 () { include?: VideoInclude privacyOneOf?: VideoPrivacy[] expectedStatus: HttpStatusCode + excludeAlreadyWatched?: boolean + unauthenticatedUser?: boolean }) { const paths = [ '/api/v1/video-channels/root_channel/videos', @@ -131,14 +133,19 @@ describe('Test video filters validators', function () { ] for (const path of paths) { + const token = options.unauthenticatedUser + ? undefined + : options.token || server.accessToken + await makeGetRequest({ url: server.url, path, - token: options.token || server.accessToken, + token, query: { isLocal: options.isLocal, privacyOneOf: options.privacyOneOf, - include: options.include + include: options.include, + excludeAlreadyWatched: options.excludeAlreadyWatched }, expectedStatus: options.expectedStatus }) @@ -213,6 +220,14 @@ describe('Test video filters validators', function () { } }) }) + + it('Should fail when trying to exclude already watched videos for an unlogged user', async function () { + await testEndpoints({ excludeAlreadyWatched: true, unauthenticatedUser: true, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + }) + + it('Should succeed when trying to exclude already watched videos for a logged user', async function () { + await testEndpoints({ token: userAccessToken, excludeAlreadyWatched: true, expectedStatus: HttpStatusCode.OK_200 }) + }) }) after(async function () { -- cgit v1.2.3