1 /* tslint:disable:no-unused-expression */
8 flushAndRunMultipleServers,
13 setAccessTokensToServers,
19 } from '../../../../shared/utils'
20 import * as chai from 'chai'
21 import { Video } from '../../../../shared/models/videos'
23 const expect = chai.expect
25 describe('Test ActivityPub fetcher', function () {
26 let servers: ServerInfo[]
28 // ---------------------------------------------------------------
30 before(async function () {
33 servers = await flushAndRunMultipleServers(3)
35 // Get the access tokens
36 await setAccessTokensToServers(servers)
38 const user = { username: 'user1', password: 'password' }
39 for (const server of servers) {
40 await createUser(server.url, server.accessToken, user.username, user.password)
43 const userAccessToken = await userLogin(servers[0], user)
45 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
46 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
47 const badVideoUUID = res.body.video.uuid
48 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
50 await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')
51 await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)
54 it('Should add only the video with a valid actor URL', async function () {
57 await doubleFollow(servers[0], servers[1])
58 await waitJobs(servers)
61 const res = await getVideosListSort(servers[0].url, 'createdAt')
62 expect(res.body.total).to.equal(3)
64 const data: Video[] = res.body.data
65 expect(data[0].name).to.equal('video root')
66 expect(data[1].name).to.equal('bad video root')
67 expect(data[2].name).to.equal('video user')
71 const res = await getVideosListSort(servers[1].url, 'createdAt')
72 expect(res.body.total).to.equal(1)
74 const data: Video[] = res.body.data
75 expect(data[0].name).to.equal('video root')
79 after(async function () {
80 killallServers(servers)
82 // Keep the logs if the test failed