PeerTube/server/tests/api/videos/video-description.ts

95 lines
2.6 KiB
TypeScript
Raw Normal View History

2020-01-31 16:56:52 +01:00
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2017-10-30 10:16:27 +01:00
2022-08-17 15:44:32 +02:00
import { expect } from 'chai'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
2017-10-30 10:16:27 +01:00
describe('Test video description', function () {
2021-07-16 09:47:51 +02:00
let servers: PeerTubeServer[] = []
2017-10-30 10:16:27 +01:00
let videoUUID = ''
2017-10-30 10:58:43 +01:00
let videoId: number
2020-01-31 16:56:52 +01:00
const longDescription = 'my super description for server 1'.repeat(50)
2017-10-30 10:16:27 +01:00
before(async function () {
this.timeout(40000)
2017-10-30 10:16:27 +01:00
// Run servers
2021-07-16 09:47:51 +02:00
servers = await createMultipleServers(2)
2017-10-30 10:16:27 +01:00
// Get the access tokens
await setAccessTokensToServers(servers)
2017-11-17 12:05:59 +01:00
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
2017-10-30 10:16:27 +01:00
})
it('Should upload video with long description', async function () {
this.timeout(10000)
2017-10-30 10:16:27 +01:00
const attributes = {
description: longDescription
}
2021-07-16 09:04:35 +02:00
await servers[0].videos.upload({ attributes })
2017-10-30 10:16:27 +01:00
await waitJobs(servers)
2017-10-30 10:16:27 +01:00
2021-07-16 09:04:35 +02:00
const { data } = await servers[0].videos.list()
2017-10-30 10:16:27 +01:00
2021-07-15 10:02:54 +02:00
videoId = data[0].id
videoUUID = data[0].uuid
2017-10-30 10:16:27 +01:00
})
2017-11-17 12:05:59 +01:00
it('Should have a truncated description on each server', async function () {
2017-10-30 10:16:27 +01:00
for (const server of servers) {
2021-07-16 09:04:35 +02:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 10:16:27 +01:00
// 30 characters * 6 -> 240 characters
2017-11-17 12:05:59 +01:00
const truncatedDescription = 'my super description for server 1'.repeat(7) +
2020-01-31 16:56:52 +01:00
'my super descrip...'
2017-10-30 10:16:27 +01:00
expect(video.description).to.equal(truncatedDescription)
}
})
2017-11-17 12:05:59 +01:00
it('Should fetch long description on each server', async function () {
2017-10-30 10:16:27 +01:00
for (const server of servers) {
2021-07-16 09:04:35 +02:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 10:16:27 +01:00
2021-07-16 09:04:35 +02:00
const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
2021-07-15 10:02:54 +02:00
expect(description).to.equal(longDescription)
2017-10-30 10:16:27 +01:00
}
})
2017-10-30 10:58:43 +01:00
it('Should update with a short description', async function () {
this.timeout(10000)
2017-10-30 10:58:43 +01:00
const attributes = {
description: 'short description'
}
2021-07-16 09:04:35 +02:00
await servers[0].videos.update({ id: videoId, attributes })
2017-10-30 10:58:43 +01:00
await waitJobs(servers)
2017-10-30 10:58:43 +01:00
})
2017-11-17 12:05:59 +01:00
it('Should have a small description on each server', async function () {
2017-10-30 10:58:43 +01:00
for (const server of servers) {
2021-07-16 09:04:35 +02:00
const video = await server.videos.get({ id: videoUUID })
2017-10-30 10:58:43 +01:00
expect(video.description).to.equal('short description')
2021-07-16 09:04:35 +02:00
const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
2021-07-15 10:02:54 +02:00
expect(description).to.equal('short description')
2017-10-30 10:58:43 +01:00
}
})
2019-04-24 15:10:37 +02:00
after(async function () {
await cleanupTests(servers)
2017-10-30 10:16:27 +01:00
})
})