1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { cleanupTests, createSingleServer, FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils'
6 import { VideoDetails, VideoPrivacy } from '@shared/models'
8 const expect = chai.expect
10 describe('Test config defaults', function () {
11 let server: PeerTubeServer
14 before(async function () {
17 const overrideConfig = {
20 comments_enabled: false,
21 download_enabled: false,
22 privacy: VideoPrivacy.INTERNAL,
28 server = await createSingleServer(1, overrideConfig)
29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
32 channelId = server.store.channel.id
35 describe('Default publish values', function () {
38 downloadEnabled: undefined,
39 commentsEnabled: undefined,
41 privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server
44 function checkVideo (video: VideoDetails) {
45 expect(video.downloadEnabled).to.be.false
46 expect(video.commentsEnabled).to.be.false
47 expect(video.licence.id).to.equal(4)
50 before(async function () {
51 await server.config.disableTranscoding()
52 await server.config.enableImports()
53 await server.config.enableLive({ allowReplay: false, transcoding: false })
56 it('Should have the correct server configuration', async function () {
57 const config = await server.config.getConfig()
59 expect(config.defaults.publish.commentsEnabled).to.be.false
60 expect(config.defaults.publish.downloadEnabled).to.be.false
61 expect(config.defaults.publish.licence).to.equal(4)
62 expect(config.defaults.publish.privacy).to.equal(VideoPrivacy.INTERNAL)
65 it('Should respect default values when uploading a video', async function () {
66 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
67 const { id } = await server.videos.upload({ attributes, mode })
69 const video = await server.videos.get({ id })
74 it('Should respect default values when importing a video using URL', async function () {
75 const { video: { id } } = await server.imports.importVideo({
79 targetUrl: FIXTURE_URLS.goodVideo
83 const video = await server.videos.get({ id })
87 it('Should respect default values when importing a video using magnet URI', async function () {
88 const { video: { id } } = await server.imports.importVideo({
92 magnetUri: FIXTURE_URLS.magnet
96 const video = await server.videos.get({ id })
100 it('Should respect default values when creating a live', async function () {
101 const { id } = await server.live.create({
108 const video = await server.videos.get({ id })
113 after(async function () {
114 await cleanupTests([ server ])