1
0
Fork 0
peertube/server/tests/api/videos/video-description.ts

91 lines
2.6 KiB
TypeScript
Raw Normal View History

2020-01-31 10:56:52 -05:00
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2017-10-30 05:16:27 -04:00
2017-11-17 06:05:59 -05:00
import 'mocha'
2021-07-07 03:16:40 -04:00
import * as chai from 'chai'
import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
2017-10-30 05:16:27 -04:00
const expect = chai.expect
describe('Test video description', function () {
2021-07-16 03:47:51 -04:00
let servers: PeerTubeServer[] = []
2017-10-30 05:16:27 -04:00
let videoUUID = ''
2017-10-30 05:58:43 -04:00
let videoId: number
2020-01-31 10:56:52 -05:00
const longDescription = 'my super description for server 1'.repeat(50)
2017-10-30 05:16:27 -04:00
before(async function () {
this.timeout(40000)
2017-10-30 05:16:27 -04:00
// Run servers
2021-07-16 03:47:51 -04:00
servers = await createMultipleServers(2)
2017-10-30 05:16:27 -04:00
// 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 () {
this.timeout(10000)
2017-10-30 05:16:27 -04:00
const attributes = {
description: longDescription
}
2021-07-16 03:04:35 -04:00
await servers[0].videos.upload({ attributes })
2017-10-30 05:16:27 -04:00
await waitJobs(servers)
2017-10-30 05:16:27 -04:00
2021-07-16 03:04:35 -04:00
const { data } = await servers[0].videos.list()
2017-10-30 05:16:27 -04:00
2021-07-15 04:02:54 -04:00
videoId = data[0].id
videoUUID = data[0].uuid
2017-10-30 05:16:27 -04:00
})
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) {
2021-07-16 03:04:35 -04:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 05:16:27 -04:00
// 30 characters * 6 -> 240 characters
2017-11-17 06:05:59 -05:00
const truncatedDescription = 'my super description for server 1'.repeat(7) +
2020-01-31 10:56:52 -05:00
'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) {
2021-07-16 03:04:35 -04:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 05:16:27 -04:00
2021-07-16 03:04:35 -04:00
const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
2021-07-15 04:02:54 -04:00
expect(description).to.equal(longDescription)
2017-10-30 05:16:27 -04:00
}
})
2017-10-30 05:58:43 -04:00
it('Should update with a short description', async function () {
this.timeout(10000)
2017-10-30 05:58:43 -04:00
const attributes = {
description: 'short description'
}
2021-07-16 03:04:35 -04:00
await servers[0].videos.update({ id: videoId, attributes })
2017-10-30 05:58:43 -04:00
await waitJobs(servers)
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) {
2021-07-16 03:04:35 -04:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 05:58:43 -04:00
expect(video.description).to.equal('short description')
2021-07-16 03:04:35 -04:00
const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
2021-07-15 04:02:54 -04:00
expect(description).to.equal('short description')
2017-10-30 05:58:43 -04:00
}
})
2019-04-24 09:10:37 -04:00
after(async function () {
await cleanupTests(servers)
2017-10-30 05:16:27 -04:00
})
})