2017-10-30 05:16:27 -04:00
|
|
|
/* tslint:disable:no-unused-expression */
|
|
|
|
|
|
|
|
import * as chai from 'chai'
|
2017-11-17 06:05:59 -05:00
|
|
|
import 'mocha'
|
2017-10-30 05:16:27 -04:00
|
|
|
import {
|
|
|
|
flushAndRunMultipleServers,
|
|
|
|
flushTests,
|
|
|
|
getVideo,
|
2017-11-17 06:05:59 -05:00
|
|
|
getVideoDescription,
|
2017-10-30 05:16:27 -04:00
|
|
|
getVideosList,
|
|
|
|
killallServers,
|
|
|
|
ServerInfo,
|
|
|
|
setAccessTokensToServers,
|
2017-11-17 06:05:59 -05:00
|
|
|
updateVideo,
|
2017-10-30 05:16:27 -04:00
|
|
|
uploadVideo,
|
2017-11-17 06:05:59 -05:00
|
|
|
wait
|
2017-10-30 05:16:27 -04:00
|
|
|
} from '../utils'
|
2017-11-17 06:05:59 -05:00
|
|
|
import { doubleFollow } from '../utils/follows'
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test video description', function () {
|
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
let videoUUID = ''
|
2017-10-30 05:58:43 -04:00
|
|
|
let videoId: number
|
2017-11-17 06:05:59 -05:00
|
|
|
let longDescription = 'my super description for server 1'.repeat(50)
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
before(async function () {
|
2017-11-17 09:42:12 -05:00
|
|
|
this.timeout(40000)
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
// Run servers
|
|
|
|
servers = await flushAndRunMultipleServers(2)
|
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
2017-11-17 06:05:59 -05:00
|
|
|
// Server 1 and server 2 follow each other
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
2017-10-30 05:16:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should upload video with long description', async function () {
|
2017-11-17 09:42:12 -05:00
|
|
|
this.timeout(10000)
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
description: longDescription
|
|
|
|
}
|
|
|
|
await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
|
|
|
|
|
2017-11-17 09:42:12 -05:00
|
|
|
await wait(5000)
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
const res = await getVideosList(servers[0].url)
|
|
|
|
|
2017-10-30 05:58:43 -04:00
|
|
|
videoId = res.body.data[0].id
|
2017-10-30 05:16:27 -04:00
|
|
|
videoUUID = res.body.data[0].uuid
|
|
|
|
})
|
|
|
|
|
2017-11-17 06:05:59 -05:00
|
|
|
it('Should have a truncated description on each server', async function () {
|
2017-10-30 05:16:27 -04:00
|
|
|
for (const server of servers) {
|
|
|
|
const res = await getVideo(server.url, videoUUID)
|
|
|
|
const video = res.body
|
|
|
|
|
|
|
|
// 30 characters * 6 -> 240 characters
|
2017-11-17 06:05:59 -05:00
|
|
|
const truncatedDescription = 'my super description for server 1'.repeat(7) +
|
|
|
|
'my super descrip...'
|
2017-10-30 05:16:27 -04:00
|
|
|
|
|
|
|
expect(video.description).to.equal(truncatedDescription)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-11-17 06:05:59 -05:00
|
|
|
it('Should fetch long description on each server', async function () {
|
2017-10-30 05:16:27 -04:00
|
|
|
for (const server of servers) {
|
|
|
|
const res = await getVideo(server.url, videoUUID)
|
|
|
|
const video = res.body
|
|
|
|
|
|
|
|
const res2 = await getVideoDescription(server.url, video.descriptionPath)
|
|
|
|
expect(res2.body.description).to.equal(longDescription)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-10-30 05:58:43 -04:00
|
|
|
it('Should update with a short description', async function () {
|
2017-11-17 09:42:12 -05:00
|
|
|
this.timeout(10000)
|
2017-10-30 05:58:43 -04:00
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
description: 'short description'
|
|
|
|
}
|
|
|
|
await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes)
|
|
|
|
|
2017-11-17 09:42:12 -05:00
|
|
|
await wait(5000)
|
2017-10-30 05:58:43 -04:00
|
|
|
})
|
|
|
|
|
2017-11-17 06:05:59 -05:00
|
|
|
it('Should have a small description on each server', async function () {
|
2017-10-30 05:58:43 -04:00
|
|
|
for (const server of servers) {
|
|
|
|
const res = await getVideo(server.url, videoUUID)
|
|
|
|
const video = res.body
|
|
|
|
|
|
|
|
expect(video.description).to.equal('short description')
|
|
|
|
|
|
|
|
const res2 = await getVideoDescription(server.url, video.descriptionPath)
|
|
|
|
expect(res2.body.description).to.equal('short description')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-10-30 05:16:27 -04:00
|
|
|
after(async function () {
|
|
|
|
killallServers(servers)
|
|
|
|
|
|
|
|
// Keep the logs if the test failed
|
|
|
|
if (this['ok']) {
|
|
|
|
await flushTests()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|