From af971e06c620bd46a5aa64c8833364e7022b5e3d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:22:51 +0200 Subject: Introduce search command --- server/tests/api/videos/video-nsfw.ts | 14 ++++++-------- server/tests/api/videos/videos-history.ts | 15 +++++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 6c98c9f12..24a4c6152 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -14,8 +14,6 @@ import { getVideoChannelVideos, getVideosList, getVideosListWithToken, - searchVideo, - searchVideoWithToken, ServerInfo, setAccessTokensToServers, updateCustomConfig, @@ -23,7 +21,7 @@ import { uploadVideo, userLogin } from '@shared/extra-utils' -import { CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models' +import { BooleanBothQuery, CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models' const expect = chai.expect @@ -37,7 +35,7 @@ describe('Test video NSFW policy', function () { let userAccessToken: string let customConfig: CustomConfig - function getVideosFunctions (token?: string, query = {}) { + function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { return getMyUserInformation(server.url, server.accessToken) .then(res => { const user: User = res.body @@ -49,7 +47,7 @@ describe('Test video NSFW policy', function () { if (token) { promises = [ getVideosListWithToken(server.url, token, query), - searchVideoWithToken(server.url, 'n', token, query), + server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', ...query } }), getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) ] @@ -66,7 +64,7 @@ describe('Test video NSFW policy', function () { promises = [ getVideosList(server.url), - searchVideo(server.url, 'n'), + server.searchCommand.searchVideos({ search: 'n' }), getAccountVideos(server.url, undefined, accountName, 0, 5), getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) ] @@ -230,7 +228,7 @@ describe('Test video NSFW policy', function () { }) it('Should display NSFW videos when the nsfw param === true', async function () { - for (const res of await getVideosFunctions(server.accessToken, { nsfw: true })) { + for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'true' })) { expect(res.body.total).to.equal(1) const videos = res.body.data @@ -240,7 +238,7 @@ describe('Test video NSFW policy', function () { }) it('Should hide NSFW videos when the nsfw param === true', async function () { - for (const res of await getVideosFunctions(server.accessToken, { nsfw: false })) { + for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'false' })) { expect(res.body.total).to.equal(1) const videos = res.body.data diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index b25cff879..209b93014 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, createUser, @@ -10,17 +11,15 @@ import { getVideoWithToken, killallServers, reRunServer, - searchVideoWithToken, ServerInfo, setAccessTokensToServers, updateMyUser, uploadVideo, userLogin, wait -} from '../../../../shared/extra-utils' -import { Video, VideoDetails } from '../../../../shared/models/videos' -import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +} from '@shared/extra-utils' +import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '@shared/extra-utils/videos/video-history' +import { Video, VideoDetails } from '@shared/models' const expect = chai.expect @@ -89,8 +88,8 @@ describe('Test videos history', function () { } { - const res = await searchVideoWithToken(server.url, 'video', server.accessToken) - videosOfVideos.push(res.body.data) + const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' }) + videosOfVideos.push(body.data) } for (const videos of videosOfVideos) { -- cgit v1.2.3