1 /* tslint:disable:no-unused-expression */
8 flushAndRunMultipleServers,
13 setAccessTokensToServers,
16 } from '../../../../shared/utils'
17 import * as chai from 'chai'
18 import { setActorField, setVideoField } from '../../utils/miscs/sql'
19 import { waitJobs } from '../../../../shared/utils/server/jobs'
20 import { Video } from '../../../../shared/models/videos'
22 const expect = chai.expect
24 describe('Test ActivityPub fetcher', function () {
25 let servers: ServerInfo[]
27 // ---------------------------------------------------------------
29 before(async function () {
32 servers = await flushAndRunMultipleServers(3)
34 // Get the access tokens
35 await setAccessTokensToServers(servers)
37 const user = { username: 'user1', password: 'password' }
38 for (const server of servers) {
39 await createUser(server.url, server.accessToken, user.username, user.password)
42 const userAccessToken = await userLogin(servers[0], user)
44 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' })
45 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' })
46 const badVideoUUID = res.body.video.uuid
47 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
49 await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')
50 await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)
53 it('Should add only the video with a valid actor URL', async function () {
56 await doubleFollow(servers[0], servers[1])
57 await waitJobs(servers)
60 const res = await getVideosListSort(servers[0].url, 'createdAt')
61 expect(res.body.total).to.equal(3)
63 const data: Video[] = res.body.data
64 expect(data[0].name).to.equal('video root')
65 expect(data[1].name).to.equal('bad video root')
66 expect(data[2].name).to.equal('video user')
70 const res = await getVideosListSort(servers[1].url, 'createdAt')
71 expect(res.body.total).to.equal(1)
73 const data: Video[] = res.body.data
74 expect(data[0].name).to.equal('video root')
78 after(async function () {
79 killallServers(servers)
81 // Keep the logs if the test failed