1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
6 PeerTubeProblemDocument,
12 } from '@shared/models'
15 createMultipleServers,
17 makeActivityPubGetRequest,
22 setAccessTokensToServers,
23 setDefaultVideoChannel,
25 } from '@shared/server-commands'
26 import { FIXTURE_URLS } from '../shared'
28 describe('Test plugin filter hooks', function () {
29 let servers: PeerTubeServer[]
32 let videoPlaylistUUID: string
34 before(async function () {
37 servers = await createMultipleServers(2)
38 await setAccessTokensToServers(servers)
39 await setDefaultVideoChannel(servers)
40 await doubleFollow(servers[0], servers[1])
42 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
43 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
45 ({ uuid: videoPlaylistUUID } = await servers[0].playlists.create({
47 displayName: 'my super playlist',
48 privacy: VideoPlaylistPrivacy.PUBLIC,
49 description: 'my super description',
50 videoChannelId: servers[0].store.channel.id
55 for (let i = 0; i < 10; i++) {
56 const video = await servers[0].videos.upload({ attributes: { name: 'default video ' + i } })
57 await servers[0].playlists.addElement({ playlistId: videoPlaylistUUID, attributes: { videoId: video.id } })
60 const { data } = await servers[0].videos.list()
61 videoUUID = data[0].uuid
63 await servers[0].config.updateCustomSubConfig({
65 live: { enabled: true },
66 signup: { enabled: true },
69 http: { enabled: true },
70 torrent: { enabled: true }
76 // Root subscribes to itself
77 await servers[0].subscriptions.add({ targetUri: 'root_channel@' + servers[0].host })
80 describe('Videos', function () {
82 it('Should run filter:api.videos.list.params', async function () {
83 const { data } = await servers[0].videos.list({ start: 0, count: 2 })
85 // 2 plugins do +1 to the count parameter
86 expect(data).to.have.lengthOf(4)
89 it('Should run filter:api.videos.list.result', async function () {
90 const { total } = await servers[0].videos.list({ start: 0, count: 0 })
92 // Plugin do +1 to the total result
93 expect(total).to.equal(11)
96 it('Should run filter:api.video-playlist.videos.list.params', async function () {
97 const { data } = await servers[0].playlists.listVideos({
99 playlistId: videoPlaylistUUID
102 // 1 plugin do +1 to the count parameter
103 expect(data).to.have.lengthOf(3)
106 it('Should run filter:api.video-playlist.videos.list.result', async function () {
107 const { total } = await servers[0].playlists.listVideos({
109 playlistId: videoPlaylistUUID
112 // Plugin do +1 to the total result
113 expect(total).to.equal(11)
116 it('Should run filter:api.accounts.videos.list.params', async function () {
117 const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
119 // 1 plugin do +1 to the count parameter
120 expect(data).to.have.lengthOf(3)
123 it('Should run filter:api.accounts.videos.list.result', async function () {
124 const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
126 // Plugin do +2 to the total result
127 expect(total).to.equal(12)
130 it('Should run filter:api.video-channels.videos.list.params', async function () {
131 const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
133 // 1 plugin do +3 to the count parameter
134 expect(data).to.have.lengthOf(5)
137 it('Should run filter:api.video-channels.videos.list.result', async function () {
138 const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
140 // Plugin do +3 to the total result
141 expect(total).to.equal(13)
144 it('Should run filter:api.user.me.videos.list.params', async function () {
145 const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
147 // 1 plugin do +4 to the count parameter
148 expect(data).to.have.lengthOf(6)
151 it('Should run filter:api.user.me.videos.list.result', async function () {
152 const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
154 // Plugin do +4 to the total result
155 expect(total).to.equal(14)
158 it('Should run filter:api.user.me.subscription-videos.list.params', async function () {
159 const { data } = await servers[0].videos.listMySubscriptionVideos({ start: 0, count: 2 })
161 // 1 plugin do +1 to the count parameter
162 expect(data).to.have.lengthOf(3)
165 it('Should run filter:api.user.me.subscription-videos.list.result', async function () {
166 const { total } = await servers[0].videos.listMySubscriptionVideos({ start: 0, count: 2 })
168 // Plugin do +4 to the total result
169 expect(total).to.equal(14)
172 it('Should run filter:api.video.get.result', async function () {
173 const video = await servers[0].videos.get({ id: videoUUID })
174 expect(video.name).to.contain('<3')
178 describe('Video/live/import accept', function () {
180 it('Should run filter:api.video.upload.accept.result', async function () {
181 await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
184 it('Should run filter:api.live-video.create.accept.result', async function () {
186 name: 'video with bad word',
187 privacy: VideoPrivacy.PUBLIC,
188 channelId: servers[0].store.channel.id
191 await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
194 it('Should run filter:api.video.pre-import-url.accept.result', async function () {
196 name: 'normal title',
197 privacy: VideoPrivacy.PUBLIC,
198 channelId: servers[0].store.channel.id,
199 targetUrl: FIXTURE_URLS.goodVideo + 'bad'
201 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
204 it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
207 privacy: VideoPrivacy.PUBLIC,
208 channelId: servers[0].store.channel.id,
209 torrentfile: 'video-720p.torrent' as any
211 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
214 it('Should run filter:api.video.post-import-url.accept.result', async function () {
217 let videoImportId: number
221 name: 'title with bad word',
222 privacy: VideoPrivacy.PUBLIC,
223 channelId: servers[0].store.channel.id,
224 targetUrl: FIXTURE_URLS.goodVideo
226 const body = await servers[0].imports.importVideo({ attributes })
227 videoImportId = body.id
230 await waitJobs(servers)
233 const body = await servers[0].imports.getMyVideoImports()
234 const videoImports = body.data
236 const videoImport = videoImports.find(i => i.id === videoImportId)
238 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
239 expect(videoImport.state.label).to.equal('Rejected')
243 it('Should run filter:api.video.post-import-torrent.accept.result', async function () {
246 let videoImportId: number
250 name: 'title with bad word',
251 privacy: VideoPrivacy.PUBLIC,
252 channelId: servers[0].store.channel.id,
253 torrentfile: 'video-720p.torrent' as any
255 const body = await servers[0].imports.importVideo({ attributes })
256 videoImportId = body.id
259 await waitJobs(servers)
262 const { data: videoImports } = await servers[0].imports.getMyVideoImports()
264 const videoImport = videoImports.find(i => i.id === videoImportId)
266 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
267 expect(videoImport.state.label).to.equal('Rejected')
272 describe('Video comments accept', function () {
274 it('Should run filter:api.video-thread.create.accept.result', async function () {
275 await servers[0].comments.createThread({
277 text: 'comment with bad word',
278 expectedStatus: HttpStatusCode.FORBIDDEN_403
282 it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
283 const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
284 threadId = created.id
286 await servers[0].comments.addReply({
288 toCommentId: threadId,
289 text: 'comment with bad word',
290 expectedStatus: HttpStatusCode.FORBIDDEN_403
292 await servers[0].comments.addReply({
294 toCommentId: threadId,
295 text: 'comment with good word',
296 expectedStatus: HttpStatusCode.OK_200
300 it('Should run filter:activity-pub.remote-video-comment.create.accept.result on a thread creation', async function () {
303 await servers[1].comments.createThread({ videoId: videoUUID, text: 'comment with bad word' })
305 await waitJobs(servers)
308 const thread = await servers[0].comments.listThreads({ videoId: videoUUID })
309 expect(thread.data).to.have.lengthOf(1)
310 expect(thread.data[0].text).to.not.include(' bad ')
314 const thread = await servers[1].comments.listThreads({ videoId: videoUUID })
315 expect(thread.data).to.have.lengthOf(2)
319 it('Should run filter:activity-pub.remote-video-comment.create.accept.result on a reply creation', async function () {
322 const { data } = await servers[1].comments.listThreads({ videoId: videoUUID })
323 const threadIdServer2 = data.find(t => t.text === 'thread').id
325 await servers[1].comments.addReply({
327 toCommentId: threadIdServer2,
328 text: 'comment with bad word'
331 await waitJobs(servers)
334 const tree = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
335 expect(tree.children).to.have.lengthOf(1)
336 expect(tree.children[0].comment.text).to.not.include(' bad ')
340 const tree = await servers[1].comments.getThread({ videoId: videoUUID, threadId: threadIdServer2 })
341 expect(tree.children).to.have.lengthOf(2)
346 describe('Video comments', function () {
348 it('Should run filter:api.video-threads.list.params', async function () {
349 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
351 // our plugin do +1 to the count parameter
352 expect(data).to.have.lengthOf(1)
355 it('Should run filter:api.video-threads.list.result', async function () {
356 const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
358 // Plugin do +1 to the total result
359 expect(total).to.equal(2)
362 it('Should run filter:api.video-thread-comments.list.params')
364 it('Should run filter:api.video-thread-comments.list.result', async function () {
365 const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
367 expect(thread.comment.text.endsWith(' <3')).to.be.true
370 it('Should run filter:api.overviews.videos.list.{params,result}', async function () {
371 await servers[0].overviews.getVideos({ page: 1 })
373 // 3 because we get 3 samples per page
374 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3)
375 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3)
379 describe('filter:video.auto-blacklist.result', function () {
381 async function checkIsBlacklisted (id: number | string, value: boolean) {
382 const video = await servers[0].videos.getWithToken({ id })
383 expect(video.blacklisted).to.equal(value)
386 it('Should blacklist on upload', async function () {
387 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } })
388 await checkIsBlacklisted(uuid, true)
391 it('Should blacklist on import', async function () {
395 name: 'video please blacklist me',
396 targetUrl: FIXTURE_URLS.goodVideo,
397 channelId: servers[0].store.channel.id
399 const body = await servers[0].imports.importVideo({ attributes })
400 await checkIsBlacklisted(body.video.uuid, true)
403 it('Should blacklist on update', async function () {
404 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
405 await checkIsBlacklisted(uuid, false)
407 await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
408 await checkIsBlacklisted(uuid, true)
411 it('Should blacklist on remote upload', async function () {
414 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } })
415 await waitJobs(servers)
417 await checkIsBlacklisted(uuid, true)
420 it('Should blacklist on remote update', async function () {
423 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } })
424 await waitJobs(servers)
426 await checkIsBlacklisted(uuid, false)
428 await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
429 await waitJobs(servers)
431 await checkIsBlacklisted(uuid, true)
435 describe('Should run filter:api.user.signup.allowed.result', function () {
437 before(async function () {
438 await servers[0].config.updateExistingSubConfig({ newConfig: { signup: { requiresApproval: false } } })
441 it('Should run on config endpoint', async function () {
442 const body = await servers[0].config.getConfig()
443 expect(body.signup.allowed).to.be.true
446 it('Should allow a signup', async function () {
447 await servers[0].registrations.register({ username: 'john1' })
450 it('Should not allow a signup', async function () {
451 const res = await servers[0].registrations.register({
453 expectedStatus: HttpStatusCode.FORBIDDEN_403
456 expect(res.body.error).to.equal('No jma 1')
460 describe('Should run filter:api.user.request-signup.allowed.result', function () {
462 before(async function () {
463 await servers[0].config.updateExistingSubConfig({ newConfig: { signup: { requiresApproval: true } } })
466 it('Should run on config endpoint', async function () {
467 const body = await servers[0].config.getConfig()
468 expect(body.signup.allowed).to.be.true
471 it('Should allow a signup request', async function () {
472 await servers[0].registrations.requestRegistration({ username: 'john2', registrationReason: 'tt' })
475 it('Should not allow a signup request', async function () {
476 const body = await servers[0].registrations.requestRegistration({
478 registrationReason: 'tt',
479 expectedStatus: HttpStatusCode.FORBIDDEN_403
482 expect((body as unknown as PeerTubeProblemDocument).error).to.equal('No jma 2')
486 describe('Download hooks', function () {
487 const downloadVideos: VideoDetails[] = []
488 let downloadVideo2Token: string
490 before(async function () {
493 await servers[0].config.updateCustomSubConfig({
506 const uuids: string[] = []
508 for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) {
509 const uuid = (await servers[0].videos.quickUpload({ name })).uuid
513 await waitJobs(servers)
515 for (const uuid of uuids) {
516 downloadVideos.push(await servers[0].videos.get({ id: uuid }))
519 downloadVideo2Token = await servers[0].videoToken.getVideoFileToken({ videoId: downloadVideos[2].uuid })
522 it('Should run filter:api.download.torrent.allowed.result', async function () {
523 const res = await makeRawRequest({ url: downloadVideos[0].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
524 expect(res.body.error).to.equal('Liu Bei')
526 await makeRawRequest({ url: downloadVideos[1].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.OK_200 })
527 await makeRawRequest({ url: downloadVideos[2].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.OK_200 })
530 it('Should run filter:api.download.video.allowed.result', async function () {
532 const refused = downloadVideos[1].files[0].fileDownloadUrl
534 downloadVideos[0].files[0].fileDownloadUrl,
535 downloadVideos[2].files[0].fileDownloadUrl
538 const res = await makeRawRequest({ url: refused, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
539 expect(res.body.error).to.equal('Cao Cao')
541 for (const url of allowed) {
542 await makeRawRequest({ url, expectedStatus: HttpStatusCode.OK_200 })
543 await makeRawRequest({ url, expectedStatus: HttpStatusCode.OK_200 })
548 const refused = downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl
551 downloadVideos[2].files[0].fileDownloadUrl,
552 downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl,
553 downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl
556 // Only streaming playlist is refuse
557 const res = await makeRawRequest({ url: refused, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
558 expect(res.body.error).to.equal('Sun Jian')
560 // But not we there is a user in res
561 await makeRawRequest({ url: refused, token: servers[0].accessToken, expectedStatus: HttpStatusCode.OK_200 })
562 await makeRawRequest({ url: refused, query: { videoFileToken: downloadVideo2Token }, expectedStatus: HttpStatusCode.OK_200 })
565 for (const url of allowed) {
566 await makeRawRequest({ url, expectedStatus: HttpStatusCode.OK_200 })
572 describe('Embed filters', function () {
573 const embedVideos: VideoDetails[] = []
574 const embedPlaylists: VideoPlaylist[] = []
576 before(async function () {
579 await servers[0].config.disableTranscoding()
581 for (const name of [ 'bad embed', 'good embed' ]) {
583 const uuid = (await servers[0].videos.quickUpload({ name })).uuid
584 embedVideos.push(await servers[0].videos.get({ id: uuid }))
588 const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
589 const { id } = await servers[0].playlists.create({ attributes })
591 const playlist = await servers[0].playlists.get({ playlistId: id })
592 embedPlaylists.push(playlist)
597 it('Should run filter:html.embed.video.allowed.result', async function () {
598 const res = await makeGetRequest({ url: servers[0].url, path: embedVideos[0].embedPath, expectedStatus: HttpStatusCode.OK_200 })
599 expect(res.text).to.equal('Lu Bu')
602 it('Should run filter:html.embed.video-playlist.allowed.result', async function () {
603 const res = await makeGetRequest({ url: servers[0].url, path: embedPlaylists[0].embedPath, expectedStatus: HttpStatusCode.OK_200 })
604 expect(res.text).to.equal('Diao Chan')
608 describe('Search filters', function () {
610 before(async function () {
611 await servers[0].config.updateCustomSubConfig({
616 isDefaultSearch: false,
617 disableLocalSearch: false
624 it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
625 await servers[0].search.advancedVideoSearch({
631 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
632 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
635 it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
636 await servers[0].search.advancedVideoSearch({
639 searchTarget: 'search-index'
643 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
644 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
645 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
646 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
649 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
650 await servers[0].search.advancedChannelSearch({
656 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
657 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
660 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
661 await servers[0].search.advancedChannelSearch({
664 searchTarget: 'search-index'
668 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
669 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
670 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
671 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
674 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
675 await servers[0].search.advancedPlaylistSearch({
681 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
682 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
685 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
686 await servers[0].search.advancedPlaylistSearch({
689 searchTarget: 'search-index'
693 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
694 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
695 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
696 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
700 describe('Upload/import/live attributes filters', function () {
702 before(async function () {
703 await servers[0].config.enableLive({ transcoding: false, allowReplay: false })
704 await servers[0].config.enableImports()
705 await servers[0].config.disableTranscoding()
708 it('Should run filter:api.video.upload.video-attribute.result', async function () {
709 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
710 const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode })
712 const video = await servers[0].videos.get({ id })
713 expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result')
717 it('Should run filter:api.video.import-url.video-attribute.result', async function () {
720 description: 'import url',
721 channelId: servers[0].store.channel.id,
722 targetUrl: FIXTURE_URLS.goodVideo,
723 privacy: VideoPrivacy.PUBLIC
725 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
727 const video = await servers[0].videos.get({ id })
728 expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result')
731 it('Should run filter:api.video.import-torrent.video-attribute.result', async function () {
734 description: 'import torrent',
735 channelId: servers[0].store.channel.id,
736 magnetUri: FIXTURE_URLS.magnet,
737 privacy: VideoPrivacy.PUBLIC
739 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
741 const video = await servers[0].videos.get({ id })
742 expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result')
745 it('Should run filter:api.video.live.video-attribute.result', async function () {
749 channelId: servers[0].store.channel.id,
750 privacy: VideoPrivacy.PUBLIC
752 const { id } = await servers[0].live.create({ fields })
754 const video = await servers[0].videos.get({ id })
755 expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result')
759 describe('Stats filters', function () {
761 it('Should run filter:api.server.stats.get.result', async function () {
762 const data = await servers[0].stats.get()
764 expect((data as any).customStats).to.equal(14)
769 describe('Job queue filters', function () {
770 let videoUUID: string
772 before(async function () {
773 this.timeout(120_000)
775 await servers[0].config.enableMinimumTranscoding()
776 const { uuid } = await servers[0].videos.quickUpload({ name: 'studio' })
778 const video = await servers[0].videos.get({ id: uuid })
779 expect(video.duration).at.least(2)
780 videoUUID = video.uuid
782 await waitJobs(servers)
784 await servers[0].config.enableStudio()
787 it('Should run filter:job-queue.process.params', async function () {
788 this.timeout(120_000)
790 await servers[0].videoStudio.createEditionTasks({
796 file: 'video_very_short_240p.mp4'
802 await waitJobs(servers)
804 await servers[0].servers.waitUntilLog('Run hook filter:job-queue.process.params', 1, false)
806 const video = await servers[0].videos.get({ id: videoUUID })
807 expect(video.duration).at.most(2)
810 it('Should run filter:job-queue.process.result', async function () {
811 await servers[0].servers.waitUntilLog('Run hook filter:job-queue.process.result', 1, false)
815 describe('Transcoding filters', async function () {
817 it('Should run filter:transcoding.auto.resolutions-to-transcode.result', async function () {
818 const { uuid } = await servers[0].videos.quickUpload({ name: 'transcode-filter' })
820 await waitJobs(servers)
822 const video = await servers[0].videos.get({ id: uuid })
823 expect(video.files).to.have.lengthOf(2)
824 expect(video.files.find(f => f.resolution.id === 100 as any)).to.exist
828 describe('Video channel filters', async function () {
830 it('Should run filter:api.video-channels.list.params', async function () {
831 const { data } = await servers[0].channels.list({ start: 0, count: 0 })
833 // plugin do +1 to the count parameter
834 expect(data).to.have.lengthOf(1)
837 it('Should run filter:api.video-channels.list.result', async function () {
838 const { total } = await servers[0].channels.list({ start: 0, count: 1 })
840 // plugin do +1 to the total parameter
841 expect(total).to.equal(4)
844 it('Should run filter:api.video-channel.get.result', async function () {
845 const channel = await servers[0].channels.get({ channelName: 'root_channel' })
846 expect(channel.displayName).to.equal('Main root channel <3')
850 describe('Activity Pub', function () {
852 it('Should run filter:activity-pub.activity.context.build.result', async function () {
853 const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID)
854 expect(body.type).to.equal('Video')
856 expect(body['@context'].some(c => c === 'https://example.com/new-context')).to.be.true
859 it('Should run filter:activity-pub.video.json-ld.build.result', async function () {
860 const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID)
861 expect(body.name).to.equal('default video 0')
862 expect(body.videoName).to.equal('default video 0')
866 after(async function () {
867 await cleanupTests(servers)