X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Ffilter-hooks.ts;h=02915f08cb2f8199f383cdb778b618544f014c68;hb=dd6d2a7ce50e7ff02e00995ccc87f8f929ad9709;hp=18479dcf5d2d97efdabe03a3c776d1ad9fe54bd6;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 18479dcf5..02915f08c 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -2,32 +2,31 @@ import 'mocha' import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, + createMultipleServers, doubleFollow, - flushAndRunMultipleServers, - ImportsCommand, + FIXTURE_URLS, makeRawRequest, + PeerTubeServer, PluginsCommand, - ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, waitJobs } from '@shared/extra-utils' -import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' +import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' const expect = chai.expect describe('Test plugin filter hooks', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let videoUUID: string let threadId: number before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) await doubleFollow(servers[0], servers[1]) @@ -71,28 +70,28 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.accounts.videos.list.params', async function () { - const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) + const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) // 1 plugin do +1 to the count parameter expect(data).to.have.lengthOf(3) }) it('Should run filter:api.accounts.videos.list.result', async function () { - const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) + const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) // Plugin do +2 to the total result expect(total).to.equal(12) }) it('Should run filter:api.video-channels.videos.list.params', async function () { - const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) + const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) // 1 plugin do +3 to the count parameter expect(data).to.have.lengthOf(5) }) it('Should run filter:api.video-channels.videos.list.result', async function () { - const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) + const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) // Plugin do +3 to the total result expect(total).to.equal(13) @@ -136,7 +135,7 @@ describe('Test plugin filter hooks', function () { name: 'normal title', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id, - targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad' + targetUrl: FIXTURE_URLS.goodVideo + 'bad' } await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) @@ -161,7 +160,7 @@ describe('Test plugin filter hooks', function () { name: 'title with bad word', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const body = await servers[0].imports.importVideo({ attributes }) videoImportId = body.id @@ -256,6 +255,14 @@ describe('Test plugin filter hooks', function () { expect(thread.comment.text.endsWith(' <3')).to.be.true }) + it('Should run filter:api.overviews.videos.list.{params,result}', async function () { + await servers[0].overviews.getVideos({ page: 1 }) + + // 3 because we get 3 samples per page + await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3) + await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3) + }) + describe('Should run filter:video.auto-blacklist.result', function () { async function checkIsBlacklisted (id: number | string, value: boolean) { @@ -273,7 +280,7 @@ describe('Test plugin filter hooks', function () { const attributes = { name: 'video please blacklist me', - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, channelId: servers[0].store.channel.id } const body = await servers[0].imports.importVideo({ attributes })