X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-captions.ts;h=b7f26c35fcf60c3d676e4347085024b50451b389;hb=c6f8ca4d6596572de981162983bd02eb2613791d;hp=4c67e96f78de34fddfacf291a2d21166ca1d7354;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 4c67e96f7..b7f26c35f 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts @@ -2,37 +2,36 @@ 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, - flushAndRunMultipleServers, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, - testCaptionFile, - wait, waitJobs -} from '@shared/extra-utils' +} from '@shared/server-commands' const expect = chai.expect describe('Test video captions', function () { const uuidRegex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' - let servers: ServerInfo[] + let servers: PeerTubeServer[] let videoUUID: string before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await doubleFollow(servers[0], servers[1]) await waitJobs(servers) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'my video name' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'my video name' } }) videoUUID = uuid await waitJobs(servers) @@ -40,7 +39,7 @@ describe('Test video captions', function () { it('Should list the captions and return an empty list', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.list({ videoId: videoUUID }) expect(body.total).to.equal(0) expect(body.data).to.have.lengthOf(0) } @@ -49,13 +48,13 @@ describe('Test video captions', function () { it('Should create two new captions', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.add({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good1.vtt' }) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.add({ language: 'zh', videoId: videoUUID, fixture: 'subtitle-good2.vtt', @@ -67,7 +66,7 @@ describe('Test video captions', function () { it('Should list these uploaded captions', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.list({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -88,7 +87,7 @@ describe('Test video captions', function () { it('Should replace an existing caption', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.add({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good2.vtt' @@ -99,7 +98,7 @@ describe('Test video captions', function () { it('Should have this caption updated', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.list({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -114,7 +113,7 @@ describe('Test video captions', function () { it('Should replace an existing caption with a srt file and convert it', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.add({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good.srt' @@ -128,7 +127,7 @@ describe('Test video captions', function () { it('Should have this caption updated and converted', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.list({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -157,14 +156,14 @@ describe('Test video captions', function () { it('Should remove one caption', async function () { this.timeout(30000) - await servers[0].captionsCommand.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.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.list({ videoId: videoUUID }) expect(body.total).to.equal(1) expect(body.data).to.have.lengthOf(1) @@ -178,9 +177,12 @@ describe('Test video captions', function () { }) it('Should remove the video, and thus all video captions', async function () { - await servers[0].videosCommand.remove({ id: videoUUID }) + const video = await servers[0].videos.get({ id: videoUUID }) + const { data: captions } = await servers[0].captions.list({ videoId: videoUUID }) - await checkVideoFilesWereRemoved(videoUUID, servers[0]) + await servers[0].videos.remove({ id: videoUUID }) + + await checkVideoFilesWereRemoved({ server: servers[0], video, captions }) }) after(async function () {