1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
10 setAccessTokensToServers,
11 setDefaultVideoChannel
12 } from '@shared/extra-utils'
13 import { VideoDetails, VideoPrivacy } from '@shared/models'
15 const expect = chai.expect
17 describe('Test config defaults', function () {
18 let server: PeerTubeServer
21 before(async function () {
24 const overrideConfig = {
27 comments_enabled: false,
28 download_enabled: false,
29 privacy: VideoPrivacy.INTERNAL,
35 server = await createSingleServer(1, overrideConfig)
36 await setAccessTokensToServers([ server ])
37 await setDefaultVideoChannel([ server ])
39 channelId = server.store.channel.id
42 describe('Default publish values', function () {
45 downloadEnabled: undefined,
46 commentsEnabled: undefined,
48 privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server
51 function checkVideo (video: VideoDetails) {
52 expect(video.downloadEnabled).to.be.false
53 expect(video.commentsEnabled).to.be.false
54 expect(video.licence.id).to.equal(4)
57 before(async function () {
58 await server.config.disableTranscoding()
59 await server.config.enableImports()
60 await server.config.enableLive({ allowReplay: false, transcoding: false })
63 it('Should have the correct server configuration', async function () {
64 const config = await server.config.getConfig()
66 expect(config.defaults.publish.commentsEnabled).to.be.false
67 expect(config.defaults.publish.downloadEnabled).to.be.false
68 expect(config.defaults.publish.licence).to.equal(4)
69 expect(config.defaults.publish.privacy).to.equal(VideoPrivacy.INTERNAL)
72 it('Should respect default values when uploading a video', async function () {
73 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
74 const { id } = await server.videos.upload({ attributes, mode })
76 const video = await server.videos.get({ id })
81 it('Should respect default values when importing a video using URL', async function () {
82 const { video: { id } } = await server.imports.importVideo({
86 targetUrl: FIXTURE_URLS.goodVideo
90 const video = await server.videos.get({ id })
94 it('Should respect default values when importing a video using magnet URI', async function () {
95 const { video: { id } } = await server.imports.importVideo({
99 magnetUri: FIXTURE_URLS.magnet
103 const video = await server.videos.get({ id })
107 it('Should respect default values when creating a live', async function () {
108 const { id } = await server.live.create({
115 const video = await server.videos.get({ id })
120 after(async function () {
121 await cleanupTests([ server ])