import 'mocha'
import * as chai from 'chai'
+import { expectStartWith } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
cleanupTests,
createMultipleServers,
doubleFollow,
- expectStartWith,
+ expectNoFailedTranscodingJob,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoDetails } from '@shared/models'
+} from '@shared/server-commands'
const expect = chai.expect
await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
}
- for (const file of video.streamingPlaylists[0].files) {
+ const streamingPlaylistFiles = video.streamingPlaylists.length === 0
+ ? []
+ : video.streamingPlaylists[0].files
+
+ for (const file of streamingPlaylistFiles) {
expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
}
}
-async function expectNoFailedTranscodingJob (server: PeerTubeServer) {
- const { data } = await server.jobs.listFailed({ jobType: 'video-transcoding' })
- expect(data).to.have.lengthOf(0)
-}
-
function runTests (objectStorage: boolean) {
let servers: PeerTubeServer[] = []
let videoUUID: string
const { shortUUID } = await servers[0].videos.quickUpload({ name: 'video' })
videoUUID = shortUUID
+ await waitJobs(servers)
+
const video = await servers[0].videos.get({ id: videoUUID })
publishedAt = video.publishedAt as string
await servers[0].config.enableTranscoding()
-
- await waitJobs(servers)
})
it('Should generate HLS', async function () {
}
})
+ it('Should only generate WebTorrent', async function () {
+ this.timeout(60000)
+
+ await servers[0].videos.removeHLSFiles({ videoId: videoUUID })
+ await waitJobs(servers)
+
+ await servers[0].videos.runTranscoding({ videoId: videoUUID, transcodingType: 'webtorrent' })
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const videoDetails = await server.videos.get({ id: videoUUID })
+
+ expect(videoDetails.files).to.have.lengthOf(5)
+ expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
+
+ if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ }
+ })
+
it('Should not have updated published at attributes', async function () {
const video = await servers[0].videos.get({ id: videoUUID })