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 () {
44 name: 'quick update 2',
45 privacy: VideoPrivacy.PRIVATE
48 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
49 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
52 await waitJobs(servers)
54 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
58 it('Should not have an error while quickly updating a private video to public after upload #3', async function () {
60 name: 'quick update 3',
61 privacy: VideoPrivacy.PRIVATE
64 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
66 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
69 await waitJobs(servers)
71 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
75 before(async function () {
78 const configOverride = {
81 allow_audio_files: true,
87 servers = await createMultipleServers(2, configOverride)
89 // Get the access tokens
90 await setAccessTokensToServers(servers)
92 // Server 1 and server 2 follow each other
93 await doubleFollow(servers[0], servers[1])
96 describe('With WebTorrent & HLS enabled', function () {
100 describe('With only HLS enabled', function () {
102 before(async function () {
103 await servers[0].config.updateCustomSubConfig({
107 allowAudioFiles: true,
132 describe('With object storage enabled', function () {
133 if (areMockObjectStorageTestsDisabled()) return
135 before(async function () {
138 const configOverride = ObjectStorageCommand.getDefaultMockConfig()
139 await ObjectStorageCommand.prepareDefaultMockBuckets()
141 await servers[0].kill()
142 await servers[0].run(configOverride)
145 runTestSuite(true, ObjectStorageCommand.getMockPlaylistBaseUrl())
148 after(async function () {
149 await cleanupTests(servers)