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