import 'mocha'
import * as chai from 'chai'
+import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
import {
- checkVideoFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
- testCaptionFile,
- wait,
waitJobs
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
const expect = chai.expect
it('Should list the captions and return an empty list', async function () {
for (const server of servers) {
- const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.list({ videoId: videoUUID })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
}
it('Should create two new captions', async function () {
this.timeout(30000)
- await servers[0].captions.createVideoCaption({
+ await servers[0].captions.add({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good1.vtt'
})
- await servers[0].captions.createVideoCaption({
+ await servers[0].captions.add({
language: 'zh',
videoId: videoUUID,
fixture: 'subtitle-good2.vtt',
it('Should list these uploaded captions', async function () {
for (const server of servers) {
- const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.list({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should replace an existing caption', async function () {
this.timeout(30000)
- await servers[0].captions.createVideoCaption({
+ await servers[0].captions.add({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good2.vtt'
it('Should have this caption updated', async function () {
for (const server of servers) {
- const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.list({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should replace an existing caption with a srt file and convert it', async function () {
this.timeout(30000)
- await servers[0].captions.createVideoCaption({
+ await servers[0].captions.add({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good.srt'
it('Should have this caption updated and converted', async function () {
for (const server of servers) {
- const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.list({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should remove one caption', async function () {
this.timeout(30000)
- await servers[0].captions.deleteVideoCaption({ videoId: videoUUID, language: 'ar' })
+ await servers[0].captions.delete({ videoId: videoUUID, language: 'ar' })
await waitJobs(servers)
})
it('Should only list the caption that was not deleted', async function () {
for (const server of servers) {
- const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.list({ videoId: videoUUID })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
})
it('Should remove the video, and thus all video captions', async function () {
+ const video = await servers[0].videos.get({ id: videoUUID })
+ const { data: captions } = await servers[0].captions.list({ videoId: videoUUID })
+
await servers[0].videos.remove({ id: videoUUID })
- await checkVideoFilesWereRemoved(videoUUID, servers[0])
+ await checkVideoFilesWereRemoved({ server: servers[0], video, captions })
})
after(async function () {