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 server = await createSingleServer(1)
25 await setAccessTokensToServers([ server ])
26 await setDefaultVideoChannel([ server ])
28 channelId = server.store.channel.id
31 describe('Default publish values', function () {
33 before(async function () {
34 const overrideConfig = {
37 comments_enabled: false,
38 download_enabled: false,
39 privacy: VideoPrivacy.INTERNAL,
46 await server.run(overrideConfig)
51 downloadEnabled: undefined,
52 commentsEnabled: undefined,
54 privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server
57 function checkVideo (video: VideoDetails) {
58 expect(video.downloadEnabled).to.be.false
59 expect(video.commentsEnabled).to.be.false
60 expect(video.licence.id).to.equal(4)
63 before(async function () {
64 await server.config.disableTranscoding()
65 await server.config.enableImports()
66 await server.config.enableLive({ allowReplay: false, transcoding: false })
69 it('Should have the correct server configuration', async function () {
70 const config = await server.config.getConfig()
72 expect(config.defaults.publish.commentsEnabled).to.be.false
73 expect(config.defaults.publish.downloadEnabled).to.be.false
74 expect(config.defaults.publish.licence).to.equal(4)
75 expect(config.defaults.publish.privacy).to.equal(VideoPrivacy.INTERNAL)
78 it('Should respect default values when uploading a video', async function () {
79 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
80 const { id } = await server.videos.upload({ attributes, mode })
82 const video = await server.videos.get({ id })
87 it('Should respect default values when importing a video using URL', async function () {
88 const { video: { id } } = await server.imports.importVideo({
92 targetUrl: FIXTURE_URLS.goodVideo
96 const video = await server.videos.get({ id })
100 it('Should respect default values when importing a video using magnet URI', async function () {
101 const { video: { id } } = await server.imports.importVideo({
105 magnetUri: FIXTURE_URLS.magnet
109 const video = await server.videos.get({ id })
113 it('Should respect default values when creating a live', async function () {
114 const { id } = await server.live.create({
121 const video = await server.videos.get({ id })
126 describe('Default P2P values', function () {
128 before(async function () {
129 const overrideConfig = {
138 await server.run(overrideConfig)
141 it('Should not have P2P enabled', async function () {
142 const config = await server.config.getConfig()
144 expect(config.defaults.p2p.enabled).to.be.false
147 it('Should create a user with this default setting', async function () {
148 await server.users.create({ username: 'user_p2p_1' })
149 const userToken = await server.login.getAccessToken('user_p2p_1')
151 const { p2pEnabled } = await server.users.getMyInfo({ token: userToken })
152 expect(p2pEnabled).to.be.false
155 it('Should register a user with this default setting', async function () {
156 await server.users.register({ username: 'user_p2p_2' })
158 const userToken = await server.login.getAccessToken('user_p2p_2')
160 const { p2pEnabled } = await server.users.getMyInfo({ token: userToken })
161 expect(p2pEnabled).to.be.false
165 after(async function () {
166 await cleanupTests([ server ])