]>
Commit | Line | Data |
---|---|---|
3cf68b86 C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
854f533c C |
5 | import { |
6 | cleanupTests, | |
7 | createSingleServer, | |
8 | FIXTURE_URLS, | |
9 | PeerTubeServer, | |
10 | setAccessTokensToServers, | |
11 | setDefaultVideoChannel | |
12 | } from '@shared/extra-utils' | |
3cf68b86 C |
13 | import { VideoDetails, VideoPrivacy } from '@shared/models' |
14 | ||
15 | const expect = chai.expect | |
16 | ||
17 | describe('Test config defaults', function () { | |
18 | let server: PeerTubeServer | |
19 | let channelId: number | |
20 | ||
21 | before(async function () { | |
22 | this.timeout(30000) | |
23 | ||
24 | const overrideConfig = { | |
25 | defaults: { | |
26 | publish: { | |
27 | comments_enabled: false, | |
28 | download_enabled: false, | |
29 | privacy: VideoPrivacy.INTERNAL, | |
30 | licence: 4 | |
31 | } | |
32 | } | |
33 | } | |
34 | ||
35 | server = await createSingleServer(1, overrideConfig) | |
36 | await setAccessTokensToServers([ server ]) | |
37 | await setDefaultVideoChannel([ server ]) | |
38 | ||
39 | channelId = server.store.channel.id | |
40 | }) | |
41 | ||
42 | describe('Default publish values', function () { | |
43 | const attributes = { | |
44 | name: 'video', | |
45 | downloadEnabled: undefined, | |
46 | commentsEnabled: undefined, | |
47 | licence: undefined, | |
48 | privacy: VideoPrivacy.PUBLIC // Privacy is mandatory for server | |
49 | } | |
50 | ||
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) | |
55 | } | |
56 | ||
57 | before(async function () { | |
58 | await server.config.disableTranscoding() | |
59 | await server.config.enableImports() | |
60 | await server.config.enableLive({ allowReplay: false, transcoding: false }) | |
61 | }) | |
62 | ||
63 | it('Should have the correct server configuration', async function () { | |
64 | const config = await server.config.getConfig() | |
65 | ||
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) | |
70 | }) | |
71 | ||
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 }) | |
75 | ||
76 | const video = await server.videos.get({ id }) | |
77 | checkVideo(video) | |
78 | } | |
79 | }) | |
80 | ||
81 | it('Should respect default values when importing a video using URL', async function () { | |
82 | const { video: { id } } = await server.imports.importVideo({ | |
83 | attributes: { | |
84 | ...attributes, | |
85 | channelId, | |
86 | targetUrl: FIXTURE_URLS.goodVideo | |
87 | } | |
88 | }) | |
89 | ||
90 | const video = await server.videos.get({ id }) | |
91 | checkVideo(video) | |
92 | }) | |
93 | ||
94 | it('Should respect default values when importing a video using magnet URI', async function () { | |
95 | const { video: { id } } = await server.imports.importVideo({ | |
96 | attributes: { | |
97 | ...attributes, | |
98 | channelId, | |
99 | magnetUri: FIXTURE_URLS.magnet | |
100 | } | |
101 | }) | |
102 | ||
103 | const video = await server.videos.get({ id }) | |
104 | checkVideo(video) | |
105 | }) | |
106 | ||
107 | it('Should respect default values when creating a live', async function () { | |
108 | const { id } = await server.live.create({ | |
109 | fields: { | |
110 | ...attributes, | |
111 | channelId | |
112 | } | |
113 | }) | |
114 | ||
115 | const video = await server.videos.get({ id }) | |
116 | checkVideo(video) | |
117 | }) | |
118 | }) | |
119 | ||
120 | after(async function () { | |
121 | await cleanupTests([ server ]) | |
122 | }) | |
123 | }) |