1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as chai from 'chai'
8 flushAndRunMultipleServers,
9 makeActivityPubGetRequest,
11 setAccessTokensToServers,
13 } from '../../../../shared/extra-utils'
14 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
16 const expect = chai.expect
18 describe('Test activitypub', function () {
19 let servers: ServerInfo[] = []
22 before(async function () {
25 servers = await flushAndRunMultipleServers(2)
27 await setAccessTokensToServers(servers)
30 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
31 videoUUID = res.body.video.uuid
34 await doubleFollow(servers[0], servers[1])
37 it('Should return the account object', async function () {
38 const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
39 const object = res.body
41 expect(object.type).to.equal('Person')
42 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
43 expect(object.name).to.equal('root')
44 expect(object.preferredUsername).to.equal('root')
47 it('Should return the video object', async function () {
48 const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID)
49 const object = res.body
51 expect(object.type).to.equal('Video')
52 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
53 expect(object.name).to.equal('video')
56 it('Should redirect to the origin video object', async function () {
57 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302)
59 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
62 after(async function () {
63 await cleanupTests(servers)