X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Ffilter-hooks.ts;h=e938663da43435b566cba21722ab5d1db592356a;hb=04aed76711909507e74905bde3a7fa024d3585c9;hp=6f7fec767e76443463410eb707e73e316af880a0;hpb=74a4d53110ebc073dafeb74a7ac815fe00f4706b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 6f7fec767..e938663da 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -2,19 +2,16 @@ import 'mocha' import * as chai from 'chai' -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, + cleanupTests, createVideoPlaylist, doubleFollow, + flushAndRunMultipleServers, getAccountVideos, - getConfig, getMyVideos, - getPluginTestPath, getVideo, getVideoChannelVideos, getVideoCommentThreads, @@ -23,30 +20,28 @@ import { getVideosListPagination, getVideoThreadComments, getVideoWithToken, - installPlugin, makeRawRequest, + PluginsCommand, registerUser, - searchVideo, + 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' -import { advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels' +} from '@shared/models' const expect = chai.expect @@ -56,24 +51,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 }) @@ -82,13 +68,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 } + } } } }) @@ -167,7 +155,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 () { @@ -327,7 +315,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) @@ -336,7 +324,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) @@ -354,8 +342,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 () { @@ -373,15 +361,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 + } } } }) @@ -437,9 +427,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 + } } }) @@ -474,20 +466,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) @@ -495,9 +491,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) @@ -507,8 +505,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) @@ -516,9 +516,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) @@ -526,6 +528,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 () {