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

95 lines
2.6 KiB
TypeScript
Raw Normal View History

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