1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { completeCheckHlsPlaylist } from '@server/tests/shared'
4 import { areMockObjectStorageTestsDisabled, wait } from '@shared/core-utils'
5 import { VideoPrivacy } from '@shared/models'
12 setAccessTokensToServers,
14 } from '@shared/server-commands'
16 describe('Test update video privacy while transcoding', function () {
17 let servers: PeerTubeServer[] = []
19 const videoUUIDs: string[] = []
21 function runTestSuite (hlsOnly: boolean, objectStorageBaseUrl?: string) {
23 it('Should not have an error while quickly updating a private video to public after upload #1', async function () {
28 privacy: VideoPrivacy.PRIVATE
31 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: false })
32 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
35 await waitJobs(servers)
37 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
40 it('Should not have an error while quickly updating a private video to public after upload #2', async function () {
45 name: 'quick update 2',
46 privacy: VideoPrivacy.PRIVATE
49 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
50 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
53 await waitJobs(servers)
55 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
59 it('Should not have an error while quickly updating a private video to public after upload #3', async function () {
63 name: 'quick update 3',
64 privacy: VideoPrivacy.PRIVATE
67 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
69 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
72 await waitJobs(servers)
74 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
78 before(async function () {
81 const configOverride = {
84 allow_audio_files: true,
90 servers = await createMultipleServers(2, configOverride)
92 // Get the access tokens
93 await setAccessTokensToServers(servers)
95 // Server 1 and server 2 follow each other
96 await doubleFollow(servers[0], servers[1])
99 describe('With WebTorrent & HLS enabled', function () {
103 describe('With only HLS enabled', function () {
105 before(async function () {
106 await servers[0].config.updateCustomSubConfig({
110 allowAudioFiles: true,
135 describe('With object storage enabled', function () {
136 if (areMockObjectStorageTestsDisabled()) return
138 before(async function () {
141 const configOverride = ObjectStorageCommand.getDefaultMockConfig()
142 await ObjectStorageCommand.prepareDefaultMockBuckets()
144 await servers[0].kill()
145 await servers[0].run(configOverride)
148 runTestSuite(true, ObjectStorageCommand.getMockPlaylistBaseUrl())
151 after(async function () {
152 await cleanupTests(servers)