1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
8 flushAndRunMultipleServers,
11 makeActivityPubGetRequest,
13 setAccessTokensToServers,
15 } from '../../../../shared/extra-utils'
17 const expect = chai.expect
19 describe('Test activitypub', function () {
20 let servers: ServerInfo[] = []
23 before(async function () {
26 servers = await flushAndRunMultipleServers(2)
28 await setAccessTokensToServers(servers)
31 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
32 videoUUID = res.body.video.uuid
35 await doubleFollow(servers[0], servers[1])
38 it('Should return the account object', async function () {
39 const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
40 const object = res.body
42 expect(object.type).to.equal('Person')
43 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
44 expect(object.name).to.equal('root')
45 expect(object.preferredUsername).to.equal('root')
48 it('Should return the video object', async function () {
49 const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID)
50 const object = res.body
52 expect(object.type).to.equal('Video')
53 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
54 expect(object.name).to.equal('video')
57 it('Should redirect to the origin video object', async function () {
58 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)
60 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
63 after(async function () {
64 await cleanupTests(servers)