X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Ffilter-hooks.ts;h=203642d8debf45e468865b2f7b212814dd3928c4;hb=e6346d59e63135cf012ed18c102d3b0179ef565f;hp=ac958c5f571d42612a851b16e28870dc840a6fac;hpb=e62f03ae0412f4efa62917d8741bc1a39e8ed7fc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index ac958c5f5..203642d8d 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -2,50 +2,44 @@ import 'mocha' import * as chai from 'chai' -import { advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels' -import { ServerConfig } from '@shared/models' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/core-utils' import { addVideoCommentReply, addVideoCommentThread, - advancedVideosSearch, - createLive, - createVideoPlaylist, + cleanupTests, doubleFollow, + flushAndRunMultipleServers, getAccountVideos, - getConfig, getMyVideos, - getPluginTestPath, getVideo, getVideoChannelVideos, getVideoCommentThreads, - getVideoPlaylist, getVideosList, getVideosListPagination, getVideoThreadComments, getVideoWithToken, - installPlugin, makeRawRequest, + PluginsCommand, registerUser, + ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, - updateCustomSubConfig, updateVideo, uploadVideo, uploadVideoAndGetId, - waitJobs -} from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' -import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports' + waitJobs, + waitUntilLog +} from '@shared/extra-utils' +import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports' import { + VideoCommentThreadTree, VideoDetails, VideoImport, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy -} from '../../../shared/models/videos' -import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' +} from '@shared/models' const expect = chai.expect @@ -55,24 +49,15 @@ describe('Test plugin filter hooks', function () { let threadId: number before(async function () { - this.timeout(30000) + this.timeout(60000) servers = await flushAndRunMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) await doubleFollow(servers[0], servers[1]) - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath() - }) - - await installPlugin({ - url: servers[0].url, - accessToken: servers[0].accessToken, - path: getPluginTestPath('-two') - }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() }) + await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) for (let i = 0; i < 10; i++) { await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i }) @@ -81,13 +66,15 @@ describe('Test plugin filter hooks', function () { const res = await getVideosList(servers[0].url) videoUUID = res.body.data[0].uuid - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - live: { enabled: true }, - signup: { enabled: true }, - import: { - videos: { - http: { enabled: true }, - torrent: { enabled: true } + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + live: { enabled: true }, + signup: { enabled: true }, + import: { + videos: { + http: { enabled: true }, + torrent: { enabled: true } + } } } }) @@ -166,7 +153,7 @@ describe('Test plugin filter hooks', function () { channelId: servers[0].videoChannel.id } - await createLive(servers[0].url, servers[0].accessToken, attributes, HttpStatusCode.FORBIDDEN_403) + await servers[0].liveCommand.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should run filter:api.video.pre-import-url.accept.result', async function () { @@ -326,7 +313,7 @@ describe('Test plugin filter hooks', function () { }) it('Should blacklist on remote upload', async function () { - this.timeout(45000) + this.timeout(120000) const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'remote please blacklist me' }) await waitJobs(servers) @@ -335,7 +322,7 @@ describe('Test plugin filter hooks', function () { }) it('Should blacklist on remote update', async function () { - this.timeout(45000) + this.timeout(120000) const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video' }) await waitJobs(servers) @@ -353,8 +340,8 @@ describe('Test plugin filter hooks', function () { describe('Should run filter:api.user.signup.allowed.result', function () { it('Should run on config endpoint', async function () { - const res = await getConfig(servers[0].url) - expect((res.body as ServerConfig).signup.allowed).to.be.true + const body = await servers[0].configCommand.getConfig() + expect(body.signup.allowed).to.be.true }) it('Should allow a signup', async function () { @@ -372,15 +359,17 @@ describe('Test plugin filter hooks', function () { const downloadVideos: VideoDetails[] = [] before(async function () { - this.timeout(60000) - - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - transcoding: { - webtorrent: { - enabled: true - }, - hls: { - enabled: true + this.timeout(120000) + + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + transcoding: { + webtorrent: { + enabled: true + }, + hls: { + enabled: true + } } } }) @@ -436,9 +425,11 @@ describe('Test plugin filter hooks', function () { before(async function () { this.timeout(60000) - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - transcoding: { - enabled: false + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + transcoding: { + enabled: false + } } }) @@ -450,11 +441,11 @@ describe('Test plugin filter hooks', function () { } { - const playlistAttrs = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC } - const res = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs }) + const attributes = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC } + const { id } = await servers[0].playlistsCommand.create({ attributes }) - const resPlaylist = await getVideoPlaylist(servers[0].url, res.body.videoPlaylist.id) - embedPlaylists.push(resPlaylist.body) + const playlist = await servers[0].playlistsCommand.get({ playlistId: id }) + embedPlaylists.push(playlist) } } }) @@ -473,20 +464,24 @@ describe('Test plugin filter hooks', function () { describe('Search filters', function () { before(async function () { - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: false, - disableLocalSearch: false + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled: true, + isDefaultSearch: false, + disableLocalSearch: false + } } } }) }) it('Should run filter:api.search.videos.local.list.{params,result}', async function () { - await advancedVideosSearch(servers[0].url, { - search: 'Sun Quan' + await servers[0].searchCommand.advancedVideoSearch({ + search: { + search: 'Sun Quan' + } }) await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) @@ -494,9 +489,11 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.search.videos.index.list.{params,result}', async function () { - await advancedVideosSearch(servers[0].url, { - search: 'Sun Quan', - searchTarget: 'search-index' + await servers[0].searchCommand.advancedVideoSearch({ + search: { + search: 'Sun Quan', + searchTarget: 'search-index' + } }) await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) @@ -506,8 +503,10 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { - await advancedVideoChannelSearch(servers[0].url, { - search: 'Sun Ce' + await servers[0].searchCommand.advancedChannelSearch({ + search: { + search: 'Sun Ce' + } }) await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) @@ -515,9 +514,11 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { - await advancedVideoChannelSearch(servers[0].url, { - search: 'Sun Ce', - searchTarget: 'search-index' + await servers[0].searchCommand.advancedChannelSearch({ + search: { + search: 'Sun Ce', + searchTarget: 'search-index' + } }) await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) @@ -525,6 +526,31 @@ describe('Test plugin filter hooks', function () { await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1) await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1) }) + + it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { + await servers[0].searchCommand.advancedPlaylistSearch({ + search: { + search: 'Sun Jian' + } + }) + + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) + }) + + it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { + await servers[0].searchCommand.advancedPlaylistSearch({ + search: { + search: 'Sun Jian', + searchTarget: 'search-index' + } + }) + + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.params', 1) + await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.result', 1) + }) }) after(async function () {