PeerTube/server/tests/api/videos/video-blacklist.ts

93 lines
2.7 KiB
TypeScript
Raw Normal View History

2017-09-04 21:21:47 +02:00
/* tslint:disable:no-unused-expression */
import * as chai from 'chai'
2017-11-17 12:05:59 +01:00
import 'mocha'
2017-09-04 21:21:47 +02:00
import {
2017-11-17 12:05:59 +01:00
addVideoToBlacklist,
flushAndRunMultipleServers,
2017-09-04 21:21:47 +02:00
getVideosList,
2017-11-17 12:05:59 +01:00
killallServers,
2017-09-04 21:21:47 +02:00
searchVideo,
2017-11-17 12:05:59 +01:00
ServerInfo,
setAccessTokensToServers,
uploadVideo
2017-12-28 13:59:22 +01:00
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
import { waitJobs } from '../../utils/server/jobs'
2017-11-17 12:05:59 +01:00
const expect = chai.expect
2017-09-04 21:21:47 +02:00
describe('Test video blacklists', function () {
let servers: ServerInfo[] = []
before(async function () {
this.timeout(50000)
2017-09-04 21:21:47 +02:00
// Run servers
servers = await flushAndRunMultipleServers(2)
// Get the access tokens
await setAccessTokensToServers(servers)
2017-11-17 12:05:59 +01:00
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
2017-09-04 21:21:47 +02:00
2017-11-17 12:05:59 +01:00
// Upload a video on server 2
2017-09-04 21:21:47 +02:00
const videoAttributes = {
2017-11-17 12:05:59 +01:00
name: 'my super name for server 2',
description: 'my super description for server 2'
2017-09-04 21:21:47 +02:00
}
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
// Wait videos propagation, server 2 has transcoding enabled
await waitJobs(servers)
2017-09-04 21:21:47 +02:00
const res = await getVideosList(servers[0].url)
const videos = res.body.data
expect(videos.length).to.equal(1)
2017-11-17 12:05:59 +01:00
servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
2017-09-04 21:21:47 +02:00
})
2017-11-17 12:05:59 +01:00
it('Should blacklist a remote video on server 1', async function () {
2017-09-04 21:21:47 +02:00
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
})
2017-11-17 12:05:59 +01:00
it('Should not have the video blacklisted in videos list on server 1', async function () {
2017-09-04 21:21:47 +02:00
const res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
expect(res.body.data.length).to.equal(0)
})
2017-11-17 12:05:59 +01:00
it('Should not have the video blacklisted in videos search on server 1', async function () {
2017-09-04 21:21:47 +02:00
const res = await searchVideo(servers[0].url, 'name')
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
expect(res.body.data.length).to.equal(0)
})
2017-11-17 12:05:59 +01:00
it('Should have the blacklisted video in videos list on server 2', async function () {
2017-09-04 21:21:47 +02:00
const res = await getVideosList(servers[1].url)
expect(res.body.total).to.equal(1)
expect(res.body.data).to.be.an('array')
expect(res.body.data.length).to.equal(1)
})
2017-11-17 12:05:59 +01:00
it('Should have the video blacklisted in videos search on server 2', async function () {
2017-09-04 21:21:47 +02:00
const res = await searchVideo(servers[1].url, 'name')
expect(res.body.total).to.equal(1)
expect(res.body.data).to.be.an('array')
expect(res.body.data.length).to.equal(1)
})
after(async function () {
killallServers(servers)
})
})