]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/plugins/filter-hooks.ts
015459ead183bd0edc9896b522c838cee5d670ed
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / filter-hooks.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import * as chai from 'chai'
5 import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
6 import {
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 makeRawRequest,
11 PeerTubeServer,
12 PluginsCommand,
13 setAccessTokensToServers,
14 setDefaultVideoChannel,
15 waitJobs
16 } from '@shared/server-commands'
17 import { FIXTURE_URLS } from '../shared'
18
19 const expect = chai.expect
20
21 describe('Test plugin filter hooks', function () {
22 let servers: PeerTubeServer[]
23 let videoUUID: string
24 let threadId: number
25 let videoPlaylistUUID: string
26
27 before(async function () {
28 this.timeout(60000)
29
30 servers = await createMultipleServers(2)
31 await setAccessTokensToServers(servers)
32 await setDefaultVideoChannel(servers)
33 await doubleFollow(servers[0], servers[1])
34
35 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
36 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
37 {
38 ({ uuid: videoPlaylistUUID } = await servers[0].playlists.create({
39 attributes: {
40 displayName: 'my super playlist',
41 privacy: VideoPlaylistPrivacy.PUBLIC,
42 description: 'my super description',
43 videoChannelId: servers[0].store.channel.id
44 }
45 }))
46 }
47
48 for (let i = 0; i < 10; i++) {
49 const video = await servers[0].videos.upload({ attributes: { name: 'default video ' + i } })
50 await servers[0].playlists.addElement({ playlistId: videoPlaylistUUID, attributes: { videoId: video.id } })
51 }
52
53 const { data } = await servers[0].videos.list()
54 videoUUID = data[0].uuid
55
56 await servers[0].config.updateCustomSubConfig({
57 newConfig: {
58 live: { enabled: true },
59 signup: { enabled: true },
60 import: {
61 videos: {
62 http: { enabled: true },
63 torrent: { enabled: true }
64 }
65 }
66 }
67 })
68 })
69
70 it('Should run filter:api.videos.list.params', async function () {
71 const { data } = await servers[0].videos.list({ start: 0, count: 2 })
72
73 // 2 plugins do +1 to the count parameter
74 expect(data).to.have.lengthOf(4)
75 })
76
77 it('Should run filter:api.videos.list.result', async function () {
78 const { total } = await servers[0].videos.list({ start: 0, count: 0 })
79
80 // Plugin do +1 to the total result
81 expect(total).to.equal(11)
82 })
83
84 it('Should run filter:api.video-playlist.videos.list.params', async function () {
85 const { data } = await servers[0].playlists.listVideos({
86 count: 2,
87 playlistId: videoPlaylistUUID
88 })
89
90 // 1 plugin do +1 to the count parameter
91 expect(data).to.have.lengthOf(3)
92 })
93
94 it('Should run filter:api.video-playlist.videos.list.result', async function () {
95 const { total } = await servers[0].playlists.listVideos({
96 count: 0,
97 playlistId: videoPlaylistUUID
98 })
99
100 // Plugin do +1 to the total result
101 expect(total).to.equal(11)
102 })
103
104 it('Should run filter:api.accounts.videos.list.params', async function () {
105 const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
106
107 // 1 plugin do +1 to the count parameter
108 expect(data).to.have.lengthOf(3)
109 })
110
111 it('Should run filter:api.accounts.videos.list.result', async function () {
112 const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
113
114 // Plugin do +2 to the total result
115 expect(total).to.equal(12)
116 })
117
118 it('Should run filter:api.video-channels.videos.list.params', async function () {
119 const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
120
121 // 1 plugin do +3 to the count parameter
122 expect(data).to.have.lengthOf(5)
123 })
124
125 it('Should run filter:api.video-channels.videos.list.result', async function () {
126 const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
127
128 // Plugin do +3 to the total result
129 expect(total).to.equal(13)
130 })
131
132 it('Should run filter:api.user.me.videos.list.params', async function () {
133 const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
134
135 // 1 plugin do +4 to the count parameter
136 expect(data).to.have.lengthOf(6)
137 })
138
139 it('Should run filter:api.user.me.videos.list.result', async function () {
140 const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
141
142 // Plugin do +4 to the total result
143 expect(total).to.equal(14)
144 })
145
146 it('Should run filter:api.video.get.result', async function () {
147 const video = await servers[0].videos.get({ id: videoUUID })
148 expect(video.name).to.contain('<3')
149 })
150
151 it('Should run filter:api.video.upload.accept.result', async function () {
152 await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
153 })
154
155 it('Should run filter:api.live-video.create.accept.result', async function () {
156 const attributes = {
157 name: 'video with bad word',
158 privacy: VideoPrivacy.PUBLIC,
159 channelId: servers[0].store.channel.id
160 }
161
162 await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
163 })
164
165 it('Should run filter:api.video.pre-import-url.accept.result', async function () {
166 const attributes = {
167 name: 'normal title',
168 privacy: VideoPrivacy.PUBLIC,
169 channelId: servers[0].store.channel.id,
170 targetUrl: FIXTURE_URLS.goodVideo + 'bad'
171 }
172 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
173 })
174
175 it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
176 const attributes = {
177 name: 'bad torrent',
178 privacy: VideoPrivacy.PUBLIC,
179 channelId: servers[0].store.channel.id,
180 torrentfile: 'video-720p.torrent' as any
181 }
182 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
183 })
184
185 it('Should run filter:api.video.post-import-url.accept.result', async function () {
186 this.timeout(60000)
187
188 let videoImportId: number
189
190 {
191 const attributes = {
192 name: 'title with bad word',
193 privacy: VideoPrivacy.PUBLIC,
194 channelId: servers[0].store.channel.id,
195 targetUrl: FIXTURE_URLS.goodVideo
196 }
197 const body = await servers[0].imports.importVideo({ attributes })
198 videoImportId = body.id
199 }
200
201 await waitJobs(servers)
202
203 {
204 const body = await servers[0].imports.getMyVideoImports()
205 const videoImports = body.data
206
207 const videoImport = videoImports.find(i => i.id === videoImportId)
208
209 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
210 expect(videoImport.state.label).to.equal('Rejected')
211 }
212 })
213
214 it('Should run filter:api.video.post-import-torrent.accept.result', async function () {
215 this.timeout(60000)
216
217 let videoImportId: number
218
219 {
220 const attributes = {
221 name: 'title with bad word',
222 privacy: VideoPrivacy.PUBLIC,
223 channelId: servers[0].store.channel.id,
224 torrentfile: 'video-720p.torrent' as any
225 }
226 const body = await servers[0].imports.importVideo({ attributes })
227 videoImportId = body.id
228 }
229
230 await waitJobs(servers)
231
232 {
233 const { data: videoImports } = await servers[0].imports.getMyVideoImports()
234
235 const videoImport = videoImports.find(i => i.id === videoImportId)
236
237 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
238 expect(videoImport.state.label).to.equal('Rejected')
239 }
240 })
241
242 it('Should run filter:api.video-thread.create.accept.result', async function () {
243 await servers[0].comments.createThread({
244 videoId: videoUUID,
245 text: 'comment with bad word',
246 expectedStatus: HttpStatusCode.FORBIDDEN_403
247 })
248 })
249
250 it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
251 const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
252 threadId = created.id
253
254 await servers[0].comments.addReply({
255 videoId: videoUUID,
256 toCommentId: threadId,
257 text: 'comment with bad word',
258 expectedStatus: HttpStatusCode.FORBIDDEN_403
259 })
260 await servers[0].comments.addReply({
261 videoId: videoUUID,
262 toCommentId: threadId,
263 text: 'comment with good word',
264 expectedStatus: HttpStatusCode.OK_200
265 })
266 })
267
268 it('Should run filter:api.video-threads.list.params', async function () {
269 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
270
271 // our plugin do +1 to the count parameter
272 expect(data).to.have.lengthOf(1)
273 })
274
275 it('Should run filter:api.video-threads.list.result', async function () {
276 const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
277
278 // Plugin do +1 to the total result
279 expect(total).to.equal(2)
280 })
281
282 it('Should run filter:api.video-thread-comments.list.params')
283
284 it('Should run filter:api.video-thread-comments.list.result', async function () {
285 const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
286
287 expect(thread.comment.text.endsWith(' <3')).to.be.true
288 })
289
290 it('Should run filter:api.overviews.videos.list.{params,result}', async function () {
291 await servers[0].overviews.getVideos({ page: 1 })
292
293 // 3 because we get 3 samples per page
294 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3)
295 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3)
296 })
297
298 describe('filter:video.auto-blacklist.result', function () {
299
300 async function checkIsBlacklisted (id: number | string, value: boolean) {
301 const video = await servers[0].videos.getWithToken({ id })
302 expect(video.blacklisted).to.equal(value)
303 }
304
305 it('Should blacklist on upload', async function () {
306 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } })
307 await checkIsBlacklisted(uuid, true)
308 })
309
310 it('Should blacklist on import', async function () {
311 this.timeout(15000)
312
313 const attributes = {
314 name: 'video please blacklist me',
315 targetUrl: FIXTURE_URLS.goodVideo,
316 channelId: servers[0].store.channel.id
317 }
318 const body = await servers[0].imports.importVideo({ attributes })
319 await checkIsBlacklisted(body.video.uuid, true)
320 })
321
322 it('Should blacklist on update', async function () {
323 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
324 await checkIsBlacklisted(uuid, false)
325
326 await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
327 await checkIsBlacklisted(uuid, true)
328 })
329
330 it('Should blacklist on remote upload', async function () {
331 this.timeout(120000)
332
333 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } })
334 await waitJobs(servers)
335
336 await checkIsBlacklisted(uuid, true)
337 })
338
339 it('Should blacklist on remote update', async function () {
340 this.timeout(120000)
341
342 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } })
343 await waitJobs(servers)
344
345 await checkIsBlacklisted(uuid, false)
346
347 await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
348 await waitJobs(servers)
349
350 await checkIsBlacklisted(uuid, true)
351 })
352 })
353
354 describe('Should run filter:api.user.signup.allowed.result', function () {
355
356 it('Should run on config endpoint', async function () {
357 const body = await servers[0].config.getConfig()
358 expect(body.signup.allowed).to.be.true
359 })
360
361 it('Should allow a signup', async function () {
362 await servers[0].users.register({ username: 'john', password: 'password' })
363 })
364
365 it('Should not allow a signup', async function () {
366 const res = await servers[0].users.register({
367 username: 'jma',
368 password: 'password',
369 expectedStatus: HttpStatusCode.FORBIDDEN_403
370 })
371
372 expect(res.body.error).to.equal('No jma')
373 })
374 })
375
376 describe('Download hooks', function () {
377 const downloadVideos: VideoDetails[] = []
378
379 before(async function () {
380 this.timeout(120000)
381
382 await servers[0].config.updateCustomSubConfig({
383 newConfig: {
384 transcoding: {
385 webtorrent: {
386 enabled: true
387 },
388 hls: {
389 enabled: true
390 }
391 }
392 }
393 })
394
395 const uuids: string[] = []
396
397 for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) {
398 const uuid = (await servers[0].videos.quickUpload({ name })).uuid
399 uuids.push(uuid)
400 }
401
402 await waitJobs(servers)
403
404 for (const uuid of uuids) {
405 downloadVideos.push(await servers[0].videos.get({ id: uuid }))
406 }
407 })
408
409 it('Should run filter:api.download.torrent.allowed.result', async function () {
410 const res = await makeRawRequest(downloadVideos[0].files[0].torrentDownloadUrl, 403)
411 expect(res.body.error).to.equal('Liu Bei')
412
413 await makeRawRequest(downloadVideos[1].files[0].torrentDownloadUrl, 200)
414 await makeRawRequest(downloadVideos[2].files[0].torrentDownloadUrl, 200)
415 })
416
417 it('Should run filter:api.download.video.allowed.result', async function () {
418 {
419 const res = await makeRawRequest(downloadVideos[1].files[0].fileDownloadUrl, 403)
420 expect(res.body.error).to.equal('Cao Cao')
421
422 await makeRawRequest(downloadVideos[0].files[0].fileDownloadUrl, 200)
423 await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200)
424 }
425
426 {
427 const res = await makeRawRequest(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403)
428 expect(res.body.error).to.equal('Sun Jian')
429
430 await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200)
431
432 await makeRawRequest(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200)
433 await makeRawRequest(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200)
434 }
435 })
436 })
437
438 describe('Embed filters', function () {
439 const embedVideos: VideoDetails[] = []
440 const embedPlaylists: VideoPlaylist[] = []
441
442 before(async function () {
443 this.timeout(60000)
444
445 await servers[0].config.disableTranscoding()
446
447 for (const name of [ 'bad embed', 'good embed' ]) {
448 {
449 const uuid = (await servers[0].videos.quickUpload({ name })).uuid
450 embedVideos.push(await servers[0].videos.get({ id: uuid }))
451 }
452
453 {
454 const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
455 const { id } = await servers[0].playlists.create({ attributes })
456
457 const playlist = await servers[0].playlists.get({ playlistId: id })
458 embedPlaylists.push(playlist)
459 }
460 }
461 })
462
463 it('Should run filter:html.embed.video.allowed.result', async function () {
464 const res = await makeRawRequest(servers[0].url + embedVideos[0].embedPath, 200)
465 expect(res.text).to.equal('Lu Bu')
466 })
467
468 it('Should run filter:html.embed.video-playlist.allowed.result', async function () {
469 const res = await makeRawRequest(servers[0].url + embedPlaylists[0].embedPath, 200)
470 expect(res.text).to.equal('Diao Chan')
471 })
472 })
473
474 describe('Search filters', function () {
475
476 before(async function () {
477 await servers[0].config.updateCustomSubConfig({
478 newConfig: {
479 search: {
480 searchIndex: {
481 enabled: true,
482 isDefaultSearch: false,
483 disableLocalSearch: false
484 }
485 }
486 }
487 })
488 })
489
490 it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
491 await servers[0].search.advancedVideoSearch({
492 search: {
493 search: 'Sun Quan'
494 }
495 })
496
497 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
498 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
499 })
500
501 it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
502 await servers[0].search.advancedVideoSearch({
503 search: {
504 search: 'Sun Quan',
505 searchTarget: 'search-index'
506 }
507 })
508
509 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
510 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
511 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
512 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
513 })
514
515 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
516 await servers[0].search.advancedChannelSearch({
517 search: {
518 search: 'Sun Ce'
519 }
520 })
521
522 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
523 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
524 })
525
526 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
527 await servers[0].search.advancedChannelSearch({
528 search: {
529 search: 'Sun Ce',
530 searchTarget: 'search-index'
531 }
532 })
533
534 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
535 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
536 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
537 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
538 })
539
540 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
541 await servers[0].search.advancedPlaylistSearch({
542 search: {
543 search: 'Sun Jian'
544 }
545 })
546
547 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
548 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
549 })
550
551 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
552 await servers[0].search.advancedPlaylistSearch({
553 search: {
554 search: 'Sun Jian',
555 searchTarget: 'search-index'
556 }
557 })
558
559 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
560 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
561 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
562 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
563 })
564 })
565
566 describe('Upload/import/live attributes filters', function () {
567
568 before(async function () {
569 await servers[0].config.enableLive({ transcoding: false, allowReplay: false })
570 await servers[0].config.enableImports()
571 await servers[0].config.disableTranscoding()
572 })
573
574 it('Should run filter:api.video.upload.video-attribute.result', async function () {
575 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
576 const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode })
577
578 const video = await servers[0].videos.get({ id })
579 expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result')
580 }
581 })
582
583 it('Should run filter:api.video.import-url.video-attribute.result', async function () {
584 const attributes = {
585 name: 'video',
586 description: 'import url',
587 channelId: servers[0].store.channel.id,
588 targetUrl: FIXTURE_URLS.goodVideo,
589 privacy: VideoPrivacy.PUBLIC
590 }
591 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
592
593 const video = await servers[0].videos.get({ id })
594 expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result')
595 })
596
597 it('Should run filter:api.video.import-torrent.video-attribute.result', async function () {
598 const attributes = {
599 name: 'video',
600 description: 'import torrent',
601 channelId: servers[0].store.channel.id,
602 magnetUri: FIXTURE_URLS.magnet,
603 privacy: VideoPrivacy.PUBLIC
604 }
605 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
606
607 const video = await servers[0].videos.get({ id })
608 expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result')
609 })
610
611 it('Should run filter:api.video.live.video-attribute.result', async function () {
612 const fields = {
613 name: 'live',
614 description: 'live',
615 channelId: servers[0].store.channel.id,
616 privacy: VideoPrivacy.PUBLIC
617 }
618 const { id } = await servers[0].live.create({ fields })
619
620 const video = await servers[0].videos.get({ id })
621 expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result')
622 })
623 })
624
625 describe('Stats filters', function () {
626
627 it('Should run filter:api.server.stats.get.result', async function () {
628 const data = await servers[0].stats.get()
629
630 expect((data as any).customStats).to.equal(14)
631 })
632
633 })
634
635 describe('Job queue filters', function () {
636 let videoUUID: string
637
638 before(async function () {
639 this.timeout(120_000)
640
641 await servers[0].config.enableMinimumTranscoding()
642 const { uuid } = await servers[0].videos.quickUpload({ name: 'studio' })
643
644 const video = await servers[0].videos.get({ id: uuid })
645 expect(video.duration).at.least(2)
646 videoUUID = video.uuid
647
648 await waitJobs(servers)
649
650 await servers[0].config.enableStudio()
651 })
652
653 it('Should run filter:job-queue.process.params', async function () {
654 this.timeout(120_000)
655
656 await servers[0].videoStudio.createEditionTasks({
657 videoId: videoUUID,
658 tasks: [
659 {
660 name: 'add-intro',
661 options: {
662 file: 'video_very_short_240p.mp4'
663 }
664 }
665 ]
666 })
667
668 await waitJobs(servers)
669
670 await servers[0].servers.waitUntilLog('Run hook filter:job-queue.process.params', 1, false)
671
672 const video = await servers[0].videos.get({ id: videoUUID })
673 expect(video.duration).at.most(2)
674 })
675
676 it('Should run filter:job-queue.process.result', async function () {
677 await servers[0].servers.waitUntilLog('Run hook filter:job-queue.process.result', 1, false)
678 })
679 })
680
681 describe('Transcoding filters', async function () {
682
683 it('Should run filter:transcoding.auto.lower-resolutions-to-transcode.result', async function () {
684 const { uuid } = await servers[0].videos.quickUpload({ name: 'transcode-filter' })
685
686 await waitJobs(servers)
687
688 const video = await servers[0].videos.get({ id: uuid })
689 expect(video.files).to.have.lengthOf(2)
690 expect(video.files.find(f => f.resolution.id === 100 as any)).to.exist
691 })
692 })
693
694 describe('Video channel filters', async function () {
695
696 it('Should run filter:api.video-channels.list.params', async function () {
697 const { data } = await servers[0].channels.list({ start: 0, count: 0 })
698
699 // plugin do +1 to the count parameter
700 expect(data).to.have.lengthOf(1)
701 })
702
703 it('Should run filter:api.video-channels.list.result', async function () {
704 const { total } = await servers[0].channels.list({ start: 0, count: 1 })
705
706 // plugin do +1 to the total parameter
707 expect(total).to.equal(4)
708 })
709
710 it('Should run filter:api.video-channel.get.result', async function () {
711 const channel = await servers[0].channels.get({ channelName: 'root_channel' })
712 expect(channel.displayName).to.equal('Main root channel <3')
713 })
714 })
715
716 after(async function () {
717 await cleanupTests(servers)
718 })
719 })