diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/config.ts | 7 | ||||
-rw-r--r-- | server/tests/api/check-params/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 275 | ||||
-rw-r--r-- | server/tests/api/index-slow.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 9 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/handle-down.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 16 | ||||
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 161 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 188 | ||||
-rw-r--r-- | server/tests/client.ts | 58 | ||||
-rw-r--r-- | server/tests/fixtures/video_short_mp3_256k.mp4 | bin | 0 -> 194985 bytes | |||
-rw-r--r-- | server/tests/fixtures/video_short_no_audio.mp4 | bin | 0 -> 34259 bytes | |||
-rw-r--r-- | server/tests/utils/server/config.ts | 66 | ||||
-rw-r--r-- | server/tests/utils/videos/video-imports.ts | 37 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 4 |
16 files changed, 725 insertions, 103 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 03855237f..2742e26de 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -60,6 +60,13 @@ describe('Test config API validators', function () { | |||
60 | '720p': false, | 60 | '720p': false, |
61 | '1080p': false | 61 | '1080p': false |
62 | } | 62 | } |
63 | }, | ||
64 | import: { | ||
65 | videos: { | ||
66 | http: { | ||
67 | enabled: false | ||
68 | } | ||
69 | } | ||
63 | } | 70 | } |
64 | } | 71 | } |
65 | 72 | ||
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 820dde889..03fdd5c4e 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -10,4 +10,5 @@ import './video-captions' | |||
10 | import './video-channels' | 10 | import './video-channels' |
11 | import './video-comments' | 11 | import './video-comments' |
12 | import './videos' | 12 | import './videos' |
13 | import './video-imports' | ||
13 | import './search' | 14 | import './search' |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts new file mode 100644 index 000000000..0ead34a47 --- /dev/null +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -0,0 +1,275 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import { omit } from 'lodash' | ||
4 | import 'mocha' | ||
5 | import { join } from 'path' | ||
6 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
7 | import { | ||
8 | createUser, | ||
9 | flushTests, | ||
10 | getMyUserInformation, | ||
11 | immutableAssign, | ||
12 | killallServers, | ||
13 | makeGetRequest, | ||
14 | makePostBodyRequest, | ||
15 | makeUploadRequest, | ||
16 | runServer, | ||
17 | ServerInfo, | ||
18 | setAccessTokensToServers, | ||
19 | updateCustomSubConfig, | ||
20 | userLogin | ||
21 | } from '../../utils' | ||
22 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | ||
23 | import { getYoutubeVideoUrl } from '../../utils/videos/video-imports' | ||
24 | |||
25 | describe('Test video imports API validator', function () { | ||
26 | const path = '/api/v1/videos/imports' | ||
27 | let server: ServerInfo | ||
28 | let userAccessToken = '' | ||
29 | let accountName: string | ||
30 | let channelId: number | ||
31 | let channelUUID: string | ||
32 | |||
33 | // --------------------------------------------------------------- | ||
34 | |||
35 | before(async function () { | ||
36 | this.timeout(30000) | ||
37 | |||
38 | await flushTests() | ||
39 | |||
40 | server = await runServer(1) | ||
41 | |||
42 | await setAccessTokensToServers([ server ]) | ||
43 | |||
44 | const username = 'user1' | ||
45 | const password = 'my super password' | ||
46 | await createUser(server.url, server.accessToken, username, password) | ||
47 | userAccessToken = await userLogin(server, { username, password }) | ||
48 | |||
49 | { | ||
50 | const res = await getMyUserInformation(server.url, server.accessToken) | ||
51 | channelId = res.body.videoChannels[ 0 ].id | ||
52 | channelUUID = res.body.videoChannels[ 0 ].uuid | ||
53 | accountName = res.body.account.name + '@' + res.body.account.host | ||
54 | } | ||
55 | }) | ||
56 | |||
57 | describe('When listing my video imports', function () { | ||
58 | const myPath = '/api/v1/users/me/videos/imports' | ||
59 | |||
60 | it('Should fail with a bad start pagination', async function () { | ||
61 | await checkBadStartPagination(server.url, myPath, server.accessToken) | ||
62 | }) | ||
63 | |||
64 | it('Should fail with a bad count pagination', async function () { | ||
65 | await checkBadCountPagination(server.url, myPath, server.accessToken) | ||
66 | }) | ||
67 | |||
68 | it('Should fail with an incorrect sort', async function () { | ||
69 | await checkBadSortPagination(server.url, myPath, server.accessToken) | ||
70 | }) | ||
71 | |||
72 | it('Should success with the correct parameters', async function () { | ||
73 | await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: 200, token: server.accessToken }) | ||
74 | }) | ||
75 | }) | ||
76 | |||
77 | describe('When adding a video import', function () { | ||
78 | let baseCorrectParams | ||
79 | |||
80 | before(function () { | ||
81 | baseCorrectParams = { | ||
82 | targetUrl: getYoutubeVideoUrl(), | ||
83 | name: 'my super name', | ||
84 | category: 5, | ||
85 | licence: 1, | ||
86 | language: 'pt', | ||
87 | nsfw: false, | ||
88 | commentsEnabled: true, | ||
89 | waitTranscoding: true, | ||
90 | description: 'my super description', | ||
91 | support: 'my super support text', | ||
92 | tags: [ 'tag1', 'tag2' ], | ||
93 | privacy: VideoPrivacy.PUBLIC, | ||
94 | channelId: channelId | ||
95 | } | ||
96 | }) | ||
97 | |||
98 | it('Should fail with nothing', async function () { | ||
99 | const fields = {} | ||
100 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
101 | }) | ||
102 | |||
103 | it('Should fail without a target url', async function () { | ||
104 | const fields = omit(baseCorrectParams, 'targetUrl') | ||
105 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 400 }) | ||
106 | }) | ||
107 | |||
108 | it('Should fail with a bad target url', async function () { | ||
109 | const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' }) | ||
110 | |||
111 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
112 | }) | ||
113 | |||
114 | it('Should fail with a long name', async function () { | ||
115 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | ||
116 | |||
117 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
118 | }) | ||
119 | |||
120 | it('Should fail with a bad category', async function () { | ||
121 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | ||
122 | |||
123 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
124 | }) | ||
125 | |||
126 | it('Should fail with a bad licence', async function () { | ||
127 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | ||
128 | |||
129 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
130 | }) | ||
131 | |||
132 | it('Should fail with a bad language', async function () { | ||
133 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | ||
134 | |||
135 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
136 | }) | ||
137 | |||
138 | it('Should fail with a long description', async function () { | ||
139 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | ||
140 | |||
141 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
142 | }) | ||
143 | |||
144 | it('Should fail with a long support text', async function () { | ||
145 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) }) | ||
146 | |||
147 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
148 | }) | ||
149 | |||
150 | it('Should fail without a channel', async function () { | ||
151 | const fields = omit(baseCorrectParams, 'channelId') | ||
152 | |||
153 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
154 | }) | ||
155 | |||
156 | it('Should fail with a bad channel', async function () { | ||
157 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | ||
158 | |||
159 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
160 | }) | ||
161 | |||
162 | it('Should fail with another user channel', async function () { | ||
163 | const user = { | ||
164 | username: 'fake', | ||
165 | password: 'fake_password' | ||
166 | } | ||
167 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
168 | |||
169 | const accessTokenUser = await userLogin(server, user) | ||
170 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
171 | const customChannelId = res.body.videoChannels[0].id | ||
172 | |||
173 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) | ||
174 | |||
175 | await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) | ||
176 | }) | ||
177 | |||
178 | it('Should fail with too many tags', async function () { | ||
179 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | ||
180 | |||
181 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
182 | }) | ||
183 | |||
184 | it('Should fail with a tag length too low', async function () { | ||
185 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | ||
186 | |||
187 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
188 | }) | ||
189 | |||
190 | it('Should fail with a tag length too big', async function () { | ||
191 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | ||
192 | |||
193 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
194 | }) | ||
195 | |||
196 | it('Should fail with an incorrect thumbnail file', async function () { | ||
197 | const fields = baseCorrectParams | ||
198 | const attaches = { | ||
199 | 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') | ||
200 | } | ||
201 | |||
202 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
203 | }) | ||
204 | |||
205 | it('Should fail with a big thumbnail file', async function () { | ||
206 | const fields = baseCorrectParams | ||
207 | const attaches = { | ||
208 | 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') | ||
209 | } | ||
210 | |||
211 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
212 | }) | ||
213 | |||
214 | it('Should fail with an incorrect preview file', async function () { | ||
215 | const fields = baseCorrectParams | ||
216 | const attaches = { | ||
217 | 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') | ||
218 | } | ||
219 | |||
220 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
221 | }) | ||
222 | |||
223 | it('Should fail with a big preview file', async function () { | ||
224 | const fields = baseCorrectParams | ||
225 | const attaches = { | ||
226 | 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') | ||
227 | } | ||
228 | |||
229 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
230 | }) | ||
231 | |||
232 | it('Should succeed with the correct parameters', async function () { | ||
233 | this.timeout(10000) | ||
234 | |||
235 | { | ||
236 | await makePostBodyRequest({ | ||
237 | url: server.url, | ||
238 | path, | ||
239 | token: server.accessToken, | ||
240 | fields: baseCorrectParams, | ||
241 | statusCodeExpected: 200 | ||
242 | }) | ||
243 | } | ||
244 | }) | ||
245 | |||
246 | it('Should forbid to import videos', async function () { | ||
247 | await updateCustomSubConfig(server.url, server.accessToken, { | ||
248 | import: { | ||
249 | videos: { | ||
250 | http: { | ||
251 | enabled: false | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | }) | ||
256 | |||
257 | await makePostBodyRequest({ | ||
258 | url: server.url, | ||
259 | path, | ||
260 | token: server.accessToken, | ||
261 | fields: baseCorrectParams, | ||
262 | statusCodeExpected: 409 | ||
263 | }) | ||
264 | }) | ||
265 | }) | ||
266 | |||
267 | after(async function () { | ||
268 | killallServers([ server ]) | ||
269 | |||
270 | // Keep the logs if the test failed | ||
271 | if (this['ok']) { | ||
272 | await flushTests() | ||
273 | } | ||
274 | }) | ||
275 | }) | ||
diff --git a/server/tests/api/index-slow.ts b/server/tests/api/index-slow.ts index d987442b3..243c941cb 100644 --- a/server/tests/api/index-slow.ts +++ b/server/tests/api/index-slow.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './videos/video-channels' | ||
2 | import './videos/video-transcoder' | 3 | import './videos/video-transcoder' |
3 | import './videos/multiple-servers' | 4 | import './videos/multiple-servers' |
4 | import './server/follows' | 5 | import './server/follows' |
@@ -7,3 +8,4 @@ import './videos/video-comments' | |||
7 | import './users/users-multiple-servers' | 8 | import './users/users-multiple-servers' |
8 | import './server/handle-down' | 9 | import './server/handle-down' |
9 | import './videos/video-schedule-update' | 10 | import './videos/video-schedule-update' |
11 | import './videos/video-imports' | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 1782a8623..b65061a5d 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -44,6 +44,7 @@ function checkInitialConfig (data: CustomConfig) { | |||
44 | expect(data.transcoding.resolutions['480p']).to.be.true | 44 | expect(data.transcoding.resolutions['480p']).to.be.true |
45 | expect(data.transcoding.resolutions['720p']).to.be.true | 45 | expect(data.transcoding.resolutions['720p']).to.be.true |
46 | expect(data.transcoding.resolutions['1080p']).to.be.true | 46 | expect(data.transcoding.resolutions['1080p']).to.be.true |
47 | expect(data.import.videos.http.enabled).to.be.true | ||
47 | } | 48 | } |
48 | 49 | ||
49 | function checkUpdatedConfig (data: CustomConfig) { | 50 | function checkUpdatedConfig (data: CustomConfig) { |
@@ -70,6 +71,7 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
70 | expect(data.transcoding.resolutions['480p']).to.be.true | 71 | expect(data.transcoding.resolutions['480p']).to.be.true |
71 | expect(data.transcoding.resolutions['720p']).to.be.false | 72 | expect(data.transcoding.resolutions['720p']).to.be.false |
72 | expect(data.transcoding.resolutions['1080p']).to.be.false | 73 | expect(data.transcoding.resolutions['1080p']).to.be.false |
74 | expect(data.import.videos.http.enabled).to.be.false | ||
73 | } | 75 | } |
74 | 76 | ||
75 | describe('Test config', function () { | 77 | describe('Test config', function () { |
@@ -160,6 +162,13 @@ describe('Test config', function () { | |||
160 | '720p': false, | 162 | '720p': false, |
161 | '1080p': false | 163 | '1080p': false |
162 | } | 164 | } |
165 | }, | ||
166 | import: { | ||
167 | videos: { | ||
168 | http: { | ||
169 | enabled: false | ||
170 | } | ||
171 | } | ||
163 | } | 172 | } |
164 | } | 173 | } |
165 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) | 174 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index a19b47509..25c87b4dc 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -178,7 +178,7 @@ describe('Test follows', function () { | |||
178 | }) | 178 | }) |
179 | 179 | ||
180 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { | 180 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { |
181 | this.timeout(10000) | 181 | this.timeout(35000) |
182 | 182 | ||
183 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) | 183 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) |
184 | await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' }) | 184 | await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' }) |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index fb9722630..18a0d9ce3 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -176,7 +176,7 @@ describe('Test handle downs', function () { | |||
176 | }) | 176 | }) |
177 | 177 | ||
178 | it('Should re-follow server 1', async function () { | 178 | it('Should re-follow server 1', async function () { |
179 | this.timeout(15000) | 179 | this.timeout(35000) |
180 | 180 | ||
181 | await reRunServer(servers[1]) | 181 | await reRunServer(servers[1]) |
182 | await reRunServer(servers[2]) | 182 | await reRunServer(servers[2]) |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index cb18898ce..516dc5aba 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -209,19 +209,19 @@ describe('Test multiple servers', function () { | |||
209 | files: [ | 209 | files: [ |
210 | { | 210 | { |
211 | resolution: 240, | 211 | resolution: 240, |
212 | size: 190000 | 212 | size: 280000 |
213 | }, | 213 | }, |
214 | { | 214 | { |
215 | resolution: 360, | 215 | resolution: 360, |
216 | size: 280000 | 216 | size: 370000 |
217 | }, | 217 | }, |
218 | { | 218 | { |
219 | resolution: 480, | 219 | resolution: 480, |
220 | size: 390000 | 220 | size: 470000 |
221 | }, | 221 | }, |
222 | { | 222 | { |
223 | resolution: 720, | 223 | resolution: 720, |
224 | size: 710000 | 224 | size: 740000 |
225 | } | 225 | } |
226 | ], | 226 | ], |
227 | thumbnailfile: 'thumbnail', | 227 | thumbnailfile: 'thumbnail', |
@@ -975,19 +975,19 @@ describe('Test multiple servers', function () { | |||
975 | files: [ | 975 | files: [ |
976 | { | 976 | { |
977 | resolution: 720, | 977 | resolution: 720, |
978 | size: 40315 | 978 | size: 36000 |
979 | }, | 979 | }, |
980 | { | 980 | { |
981 | resolution: 480, | 981 | resolution: 480, |
982 | size: 22808 | 982 | size: 21000 |
983 | }, | 983 | }, |
984 | { | 984 | { |
985 | resolution: 360, | 985 | resolution: 360, |
986 | size: 18617 | 986 | size: 17000 |
987 | }, | 987 | }, |
988 | { | 988 | { |
989 | resolution: 240, | 989 | resolution: 240, |
990 | size: 15217 | 990 | size: 13000 |
991 | } | 991 | } |
992 | ] | 992 | ] |
993 | } | 993 | } |
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts new file mode 100644 index 000000000..f21ade5c3 --- /dev/null +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -0,0 +1,161 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' | ||
6 | import { | ||
7 | doubleFollow, | ||
8 | flushAndRunMultipleServers, | ||
9 | getMyUserInformation, | ||
10 | getMyVideos, | ||
11 | getVideo, | ||
12 | getVideosList, | ||
13 | killallServers, | ||
14 | ServerInfo, | ||
15 | setAccessTokensToServers | ||
16 | } from '../../utils' | ||
17 | import { waitJobs } from '../../utils/server/jobs' | ||
18 | import { getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports' | ||
19 | |||
20 | const expect = chai.expect | ||
21 | |||
22 | describe('Test video imports', function () { | ||
23 | let servers: ServerInfo[] = [] | ||
24 | let channelIdServer1: number | ||
25 | let channelIdServer2: number | ||
26 | |||
27 | async function checkVideoServer1 (url: string, id: number | string) { | ||
28 | const res = await getVideo(url, id) | ||
29 | const video: VideoDetails = res.body | ||
30 | |||
31 | expect(video.name).to.equal('small video - youtube') | ||
32 | expect(video.category.label).to.equal('News') | ||
33 | expect(video.licence.label).to.equal('Attribution') | ||
34 | expect(video.language.label).to.equal('Unknown') | ||
35 | expect(video.nsfw).to.be.false | ||
36 | expect(video.description).to.equal('this is a super description') | ||
37 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2' ]) | ||
38 | |||
39 | expect(video.files).to.have.lengthOf(1) | ||
40 | } | ||
41 | |||
42 | async function checkVideoServer2 (url: string, id: number | string) { | ||
43 | const res = await getVideo(url, id) | ||
44 | const video = res.body | ||
45 | |||
46 | expect(video.name).to.equal('my super name') | ||
47 | expect(video.category.label).to.equal('Entertainment') | ||
48 | expect(video.licence.label).to.equal('Public Domain Dedication') | ||
49 | expect(video.language.label).to.equal('English') | ||
50 | expect(video.nsfw).to.be.false | ||
51 | expect(video.description).to.equal('my super description') | ||
52 | expect(video.tags).to.deep.equal([ 'supertag1', 'supertag2' ]) | ||
53 | |||
54 | expect(video.files).to.have.lengthOf(1) | ||
55 | } | ||
56 | |||
57 | before(async function () { | ||
58 | this.timeout(30000) | ||
59 | |||
60 | // Run servers | ||
61 | servers = await flushAndRunMultipleServers(2) | ||
62 | |||
63 | await setAccessTokensToServers(servers) | ||
64 | |||
65 | { | ||
66 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | ||
67 | channelIdServer1 = res.body.videoChannels[ 0 ].id | ||
68 | } | ||
69 | |||
70 | { | ||
71 | const res = await getMyUserInformation(servers[1].url, servers[1].accessToken) | ||
72 | channelIdServer2 = res.body.videoChannels[ 0 ].id | ||
73 | } | ||
74 | |||
75 | await doubleFollow(servers[0], servers[1]) | ||
76 | }) | ||
77 | |||
78 | it('Should import a video on server 1', async function () { | ||
79 | this.timeout(60000) | ||
80 | |||
81 | const attributes = { | ||
82 | targetUrl: getYoutubeVideoUrl(), | ||
83 | channelId: channelIdServer1, | ||
84 | privacy: VideoPrivacy.PUBLIC | ||
85 | } | ||
86 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | ||
87 | expect(res.body.video.name).to.equal('small video - youtube') | ||
88 | }) | ||
89 | |||
90 | it('Should list the video to import in my videos on server 1', async function () { | ||
91 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) | ||
92 | |||
93 | expect(res.body.total).to.equal(1) | ||
94 | |||
95 | const videos = res.body.data | ||
96 | expect(videos).to.have.lengthOf(1) | ||
97 | expect(videos[0].name).to.equal('small video - youtube') | ||
98 | }) | ||
99 | |||
100 | it('Should list the video to import in my imports on server 1', async function () { | ||
101 | const res = await getMyVideoImports(servers[0].url, servers[0].accessToken) | ||
102 | |||
103 | expect(res.body.total).to.equal(1) | ||
104 | const videoImports = res.body.data | ||
105 | expect(videoImports).to.have.lengthOf(1) | ||
106 | |||
107 | expect(videoImports[0].targetUrl).to.equal(getYoutubeVideoUrl()) | ||
108 | expect(videoImports[0].video.name).to.equal('small video - youtube') | ||
109 | }) | ||
110 | |||
111 | it('Should have the video listed on the two instances1', async function () { | ||
112 | this.timeout(120000) | ||
113 | |||
114 | await waitJobs(servers) | ||
115 | |||
116 | for (const server of servers) { | ||
117 | const res = await getVideosList(server.url) | ||
118 | expect(res.body.total).to.equal(1) | ||
119 | expect(res.body.data).to.have.lengthOf(1) | ||
120 | |||
121 | await checkVideoServer1(server.url, res.body.data[0].uuid) | ||
122 | } | ||
123 | }) | ||
124 | |||
125 | it('Should import a video on server 2 with some fields', async function () { | ||
126 | this.timeout(60000) | ||
127 | |||
128 | const attributes = { | ||
129 | targetUrl: getYoutubeVideoUrl(), | ||
130 | channelId: channelIdServer1, | ||
131 | privacy: VideoPrivacy.PUBLIC, | ||
132 | category: 10, | ||
133 | licence: 7, | ||
134 | language: 'en', | ||
135 | name: 'my super name', | ||
136 | description: 'my super description', | ||
137 | tags: [ 'supertag1', 'supertag2' ] | ||
138 | } | ||
139 | const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) | ||
140 | expect(res.body.video.name).to.equal('my super name') | ||
141 | }) | ||
142 | |||
143 | it('Should have the video listed on the two instances', async function () { | ||
144 | this.timeout(120000) | ||
145 | |||
146 | await waitJobs(servers) | ||
147 | |||
148 | for (const server of servers) { | ||
149 | const res = await getVideosList(server.url) | ||
150 | expect(res.body.total).to.equal(2) | ||
151 | expect(res.body.data).to.have.lengthOf(2) | ||
152 | |||
153 | await checkVideoServer2(server.url, res.body.data[0].uuid) | ||
154 | await checkVideoServer1(server.url, res.body.data[1].uuid) | ||
155 | } | ||
156 | }) | ||
157 | |||
158 | after(async function () { | ||
159 | killallServers(servers) | ||
160 | }) | ||
161 | }) | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index fe750253e..0f83d4d57 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -2,9 +2,12 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { omit } from 'lodash' | ||
6 | import * as ffmpeg from 'fluent-ffmpeg' | ||
5 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' | 7 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' |
6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' | 8 | import { getVideoFileFPS, audio } from '../../../helpers/ffmpeg-utils' |
7 | import { | 9 | import { |
10 | buildAbsoluteFixturePath, | ||
8 | doubleFollow, | 11 | doubleFollow, |
9 | flushAndRunMultipleServers, | 12 | flushAndRunMultipleServers, |
10 | getMyVideos, | 13 | getMyVideos, |
@@ -32,6 +35,8 @@ describe('Test video transcoding', function () { | |||
32 | servers = await flushAndRunMultipleServers(2) | 35 | servers = await flushAndRunMultipleServers(2) |
33 | 36 | ||
34 | await setAccessTokensToServers(servers) | 37 | await setAccessTokensToServers(servers) |
38 | |||
39 | await doubleFollow(servers[0], servers[1]) | ||
35 | }) | 40 | }) |
36 | 41 | ||
37 | it('Should not transcode video on server 1', async function () { | 42 | it('Should not transcode video on server 1', async function () { |
@@ -46,20 +51,22 @@ describe('Test video transcoding', function () { | |||
46 | 51 | ||
47 | await waitJobs(servers) | 52 | await waitJobs(servers) |
48 | 53 | ||
49 | const res = await getVideosList(servers[0].url) | 54 | for (const server of servers) { |
50 | const video = res.body.data[0] | 55 | const res = await getVideosList(server.url) |
56 | const video = res.body.data[ 0 ] | ||
51 | 57 | ||
52 | const res2 = await getVideo(servers[0].url, video.id) | 58 | const res2 = await getVideo(server.url, video.id) |
53 | const videoDetails = res2.body | 59 | const videoDetails = res2.body |
54 | expect(videoDetails.files).to.have.lengthOf(1) | 60 | expect(videoDetails.files).to.have.lengthOf(1) |
55 | 61 | ||
56 | const magnetUri = videoDetails.files[0].magnetUri | 62 | const magnetUri = videoDetails.files[ 0 ].magnetUri |
57 | expect(magnetUri).to.match(/\.webm/) | 63 | expect(magnetUri).to.match(/\.webm/) |
58 | 64 | ||
59 | const torrent = await webtorrentAdd(magnetUri) | 65 | const torrent = await webtorrentAdd(magnetUri, true) |
60 | expect(torrent.files).to.be.an('array') | 66 | expect(torrent.files).to.be.an('array') |
61 | expect(torrent.files.length).to.equal(1) | 67 | expect(torrent.files.length).to.equal(1) |
62 | expect(torrent.files[0].path).match(/\.webm$/) | 68 | expect(torrent.files[ 0 ].path).match(/\.webm$/) |
69 | } | ||
63 | }) | 70 | }) |
64 | 71 | ||
65 | it('Should transcode video on server 2', async function () { | 72 | it('Should transcode video on server 2', async function () { |
@@ -74,21 +81,112 @@ describe('Test video transcoding', function () { | |||
74 | 81 | ||
75 | await waitJobs(servers) | 82 | await waitJobs(servers) |
76 | 83 | ||
77 | const res = await getVideosList(servers[1].url) | 84 | for (const server of servers) { |
85 | const res = await getVideosList(server.url) | ||
86 | |||
87 | const video = res.body.data.find(v => v.name === videoAttributes.name) | ||
88 | const res2 = await getVideo(server.url, video.id) | ||
89 | const videoDetails = res2.body | ||
90 | |||
91 | expect(videoDetails.files).to.have.lengthOf(4) | ||
92 | |||
93 | const magnetUri = videoDetails.files[ 0 ].magnetUri | ||
94 | expect(magnetUri).to.match(/\.mp4/) | ||
95 | |||
96 | const torrent = await webtorrentAdd(magnetUri, true) | ||
97 | expect(torrent.files).to.be.an('array') | ||
98 | expect(torrent.files.length).to.equal(1) | ||
99 | expect(torrent.files[ 0 ].path).match(/\.mp4$/) | ||
100 | } | ||
101 | }) | ||
102 | |||
103 | it('Should transcode high bit rate mp3 to proper bit rate', async function () { | ||
104 | this.timeout(60000) | ||
105 | |||
106 | const videoAttributes = { | ||
107 | name: 'mp3_256k', | ||
108 | fixture: 'video_short_mp3_256k.mp4' | ||
109 | } | ||
110 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | ||
111 | |||
112 | await waitJobs(servers) | ||
113 | |||
114 | for (const server of servers) { | ||
115 | const res = await getVideosList(server.url) | ||
116 | |||
117 | const video = res.body.data.find(v => v.name === videoAttributes.name) | ||
118 | const res2 = await getVideo(server.url, video.id) | ||
119 | const videoDetails: VideoDetails = res2.body | ||
120 | |||
121 | expect(videoDetails.files).to.have.lengthOf(4) | ||
122 | |||
123 | const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') | ||
124 | const probe = await audio.get(ffmpeg, path) | ||
125 | |||
126 | if (probe.audioStream) { | ||
127 | expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac') | ||
128 | expect(probe.audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000) | ||
129 | } else { | ||
130 | this.fail('Could not retrieve the audio stream on ' + probe.absolutePath) | ||
131 | } | ||
132 | } | ||
133 | }) | ||
134 | |||
135 | it('Should transcode video with no audio and have no audio itself', async function () { | ||
136 | this.timeout(60000) | ||
137 | |||
138 | const videoAttributes = { | ||
139 | name: 'no_audio', | ||
140 | fixture: 'video_short_no_audio.mp4' | ||
141 | } | ||
142 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | ||
143 | |||
144 | await waitJobs(servers) | ||
145 | |||
146 | for (const server of servers) { | ||
147 | const res = await getVideosList(server.url) | ||
148 | |||
149 | const video = res.body.data.find(v => v.name === videoAttributes.name) | ||
150 | const res2 = await getVideo(server.url, video.id) | ||
151 | const videoDetails: VideoDetails = res2.body | ||
152 | |||
153 | expect(videoDetails.files).to.have.lengthOf(4) | ||
154 | const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') | ||
155 | const probe = await audio.get(ffmpeg, path) | ||
156 | expect(probe).to.not.have.property('audioStream') | ||
157 | } | ||
158 | }) | ||
159 | |||
160 | it('Should leave the audio untouched, but properly transcode the video', async function () { | ||
161 | this.timeout(60000) | ||
162 | |||
163 | const videoAttributes = { | ||
164 | name: 'untouched_audio', | ||
165 | fixture: 'video_short.mp4' | ||
166 | } | ||
167 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | ||
78 | 168 | ||
79 | const video = res.body.data[0] | 169 | await waitJobs(servers) |
80 | const res2 = await getVideo(servers[1].url, video.id) | ||
81 | const videoDetails = res2.body | ||
82 | 170 | ||
83 | expect(videoDetails.files).to.have.lengthOf(4) | 171 | for (const server of servers) { |
172 | const res = await getVideosList(server.url) | ||
84 | 173 | ||
85 | const magnetUri = videoDetails.files[0].magnetUri | 174 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
86 | expect(magnetUri).to.match(/\.mp4/) | 175 | const res2 = await getVideo(server.url, video.id) |
176 | const videoDetails: VideoDetails = res2.body | ||
87 | 177 | ||
88 | const torrent = await webtorrentAdd(magnetUri) | 178 | expect(videoDetails.files).to.have.lengthOf(4) |
89 | expect(torrent.files).to.be.an('array') | 179 | const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) |
90 | expect(torrent.files.length).to.equal(1) | 180 | const fixtureVideoProbe = await audio.get(ffmpeg, fixturePath) |
91 | expect(torrent.files[0].path).match(/\.mp4$/) | 181 | const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') |
182 | const videoProbe = await audio.get(ffmpeg, path) | ||
183 | if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { | ||
184 | const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] | ||
185 | expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) | ||
186 | } else { | ||
187 | this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath) | ||
188 | } | ||
189 | } | ||
92 | }) | 190 | }) |
93 | 191 | ||
94 | it('Should transcode a 60 FPS video', async function () { | 192 | it('Should transcode a 60 FPS video', async function () { |
@@ -103,38 +201,36 @@ describe('Test video transcoding', function () { | |||
103 | 201 | ||
104 | await waitJobs(servers) | 202 | await waitJobs(servers) |
105 | 203 | ||
106 | const res = await getVideosList(servers[1].url) | 204 | for (const server of servers) { |
205 | const res = await getVideosList(server.url) | ||
206 | |||
207 | const video = res.body.data.find(v => v.name === videoAttributes.name) | ||
208 | const res2 = await getVideo(server.url, video.id) | ||
209 | const videoDetails: VideoDetails = res2.body | ||
210 | |||
211 | expect(videoDetails.files).to.have.lengthOf(4) | ||
212 | expect(videoDetails.files[ 0 ].fps).to.be.above(58).and.below(62) | ||
213 | expect(videoDetails.files[ 1 ].fps).to.be.below(31) | ||
214 | expect(videoDetails.files[ 2 ].fps).to.be.below(31) | ||
215 | expect(videoDetails.files[ 3 ].fps).to.be.below(31) | ||
107 | 216 | ||
108 | const video = res.body.data[0] | 217 | for (const resolution of [ '240', '360', '480' ]) { |
109 | const res2 = await getVideo(servers[1].url, video.id) | 218 | const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') |
110 | const videoDetails: VideoDetails = res2.body | 219 | const fps = await getVideoFileFPS(path) |
111 | 220 | ||
112 | expect(videoDetails.files).to.have.lengthOf(4) | 221 | expect(fps).to.be.below(31) |
113 | expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) | 222 | } |
114 | expect(videoDetails.files[1].fps).to.be.below(31) | ||
115 | expect(videoDetails.files[2].fps).to.be.below(31) | ||
116 | expect(videoDetails.files[3].fps).to.be.below(31) | ||
117 | 223 | ||
118 | for (const resolution of [ '240', '360', '480' ]) { | 224 | const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') |
119 | const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') | ||
120 | const fps = await getVideoFileFPS(path) | 225 | const fps = await getVideoFileFPS(path) |
121 | 226 | ||
122 | expect(fps).to.be.below(31) | 227 | expect(fps).to.be.above(58).and.below(62) |
123 | } | 228 | } |
124 | |||
125 | const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') | ||
126 | const fps = await getVideoFileFPS(path) | ||
127 | |||
128 | expect(fps).to.be.above(58).and.below(62) | ||
129 | }) | 229 | }) |
130 | 230 | ||
131 | it('Should wait transcoding before publishing the video', async function () { | 231 | it('Should wait transcoding before publishing the video', async function () { |
132 | this.timeout(80000) | 232 | this.timeout(80000) |
133 | 233 | ||
134 | await doubleFollow(servers[0], servers[1]) | ||
135 | |||
136 | await waitJobs(servers) | ||
137 | |||
138 | { | 234 | { |
139 | // Upload the video, but wait transcoding | 235 | // Upload the video, but wait transcoding |
140 | const videoAttributes = { | 236 | const videoAttributes = { |
@@ -154,7 +250,7 @@ describe('Test video transcoding', function () { | |||
154 | 250 | ||
155 | // Should have my video | 251 | // Should have my video |
156 | const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) | 252 | const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) |
157 | const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video') | 253 | const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name) |
158 | expect(videoToFindInMine).not.to.be.undefined | 254 | expect(videoToFindInMine).not.to.be.undefined |
159 | expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) | 255 | expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) |
160 | expect(videoToFindInMine.state.label).to.equal('To transcode') | 256 | expect(videoToFindInMine.state.label).to.equal('To transcode') |
@@ -162,7 +258,7 @@ describe('Test video transcoding', function () { | |||
162 | 258 | ||
163 | // Should not list this video | 259 | // Should not list this video |
164 | const resVideos = await getVideosList(servers[1].url) | 260 | const resVideos = await getVideosList(servers[1].url) |
165 | const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video') | 261 | const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name) |
166 | expect(videoToFindInList).to.be.undefined | 262 | expect(videoToFindInList).to.be.undefined |
167 | 263 | ||
168 | // Server 1 should not have the video yet | 264 | // Server 1 should not have the video yet |
diff --git a/server/tests/client.ts b/server/tests/client.ts index bcbac86e9..b33a653b1 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -3,17 +3,21 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | const expect = chai.expect | ||
7 | |||
8 | import { | 6 | import { |
9 | ServerInfo, | ||
10 | flushTests, | 7 | flushTests, |
8 | getCustomConfig, | ||
9 | getVideosList, | ||
10 | killallServers, | ||
11 | makeHTMLRequest, | ||
11 | runServer, | 12 | runServer, |
13 | ServerInfo, | ||
12 | serverLogin, | 14 | serverLogin, |
13 | uploadVideo, | 15 | updateCustomConfig, |
14 | getVideosList, updateCustomConfig, getCustomConfig, killallServers, makeHTMLRequest | 16 | updateCustomSubConfig, |
17 | uploadVideo | ||
15 | } from './utils' | 18 | } from './utils' |
16 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 19 | |
20 | const expect = chai.expect | ||
17 | 21 | ||
18 | function checkIndexTags (html: string, title: string, description: string, css: string) { | 22 | function checkIndexTags (html: string, title: string, description: string, css: string) { |
19 | expect(html).to.contain('<title>' + title + '</title>') | 23 | expect(html).to.contain('<title>' + title + '</title>') |
@@ -117,56 +121,20 @@ describe('Test a client controllers', function () { | |||
117 | }) | 121 | }) |
118 | 122 | ||
119 | it('Should update the customized configuration and have the correct index html tags', async function () { | 123 | it('Should update the customized configuration and have the correct index html tags', async function () { |
120 | const newCustomConfig: CustomConfig = { | 124 | await updateCustomSubConfig(server.url, server.accessToken, { |
121 | instance: { | 125 | instance: { |
122 | name: 'PeerTube updated', | 126 | name: 'PeerTube updated', |
123 | shortDescription: 'my short description', | 127 | shortDescription: 'my short description', |
124 | description: 'my super description', | 128 | description: 'my super description', |
125 | terms: 'my super terms', | 129 | terms: 'my super terms', |
126 | defaultClientRoute: '/videos/recently-added', | 130 | defaultClientRoute: '/videos/recently-added', |
127 | defaultNSFWPolicy: 'blur' as 'blur', | 131 | defaultNSFWPolicy: 'blur', |
128 | customizations: { | 132 | customizations: { |
129 | javascript: 'alert("coucou")', | 133 | javascript: 'alert("coucou")', |
130 | css: 'body { background-color: red; }' | 134 | css: 'body { background-color: red; }' |
131 | } | 135 | } |
132 | }, | ||
133 | services: { | ||
134 | twitter: { | ||
135 | username: '@Kuja', | ||
136 | whitelisted: true | ||
137 | } | ||
138 | }, | ||
139 | cache: { | ||
140 | previews: { | ||
141 | size: 2 | ||
142 | }, | ||
143 | captions: { | ||
144 | size: 3 | ||
145 | } | ||
146 | }, | ||
147 | signup: { | ||
148 | enabled: false, | ||
149 | limit: 5 | ||
150 | }, | ||
151 | admin: { | ||
152 | email: 'superadmin1@example.com' | ||
153 | }, | ||
154 | user: { | ||
155 | videoQuota: 5242881 | ||
156 | }, | ||
157 | transcoding: { | ||
158 | enabled: true, | ||
159 | threads: 1, | ||
160 | resolutions: { | ||
161 | '240p': false, | ||
162 | '360p': true, | ||
163 | '480p': true, | ||
164 | '720p': false, | ||
165 | '1080p': false | ||
166 | } | ||
167 | } | 136 | } |
168 | } | 137 | }) |
169 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) | ||
170 | 138 | ||
171 | const res = await makeHTMLRequest(server.url, '/videos/trending') | 139 | const res = await makeHTMLRequest(server.url, '/videos/trending') |
172 | 140 | ||
diff --git a/server/tests/fixtures/video_short_mp3_256k.mp4 b/server/tests/fixtures/video_short_mp3_256k.mp4 new file mode 100644 index 000000000..4c1c7b45e --- /dev/null +++ b/server/tests/fixtures/video_short_mp3_256k.mp4 | |||
Binary files differ | |||
diff --git a/server/tests/fixtures/video_short_no_audio.mp4 b/server/tests/fixtures/video_short_no_audio.mp4 new file mode 100644 index 000000000..329d20fba --- /dev/null +++ b/server/tests/fixtures/video_short_no_audio.mp4 | |||
Binary files differ | |||
diff --git a/server/tests/utils/server/config.ts b/server/tests/utils/server/config.ts index 57f95a603..e21614282 100644 --- a/server/tests/utils/server/config.ts +++ b/server/tests/utils/server/config.ts | |||
@@ -44,6 +44,69 @@ function updateCustomConfig (url: string, token: string, newCustomConfig: Custom | |||
44 | }) | 44 | }) |
45 | } | 45 | } |
46 | 46 | ||
47 | function updateCustomSubConfig (url: string, token: string, newConfig: any) { | ||
48 | const updateParams: CustomConfig = { | ||
49 | instance: { | ||
50 | name: 'PeerTube updated', | ||
51 | shortDescription: 'my short description', | ||
52 | description: 'my super description', | ||
53 | terms: 'my super terms', | ||
54 | defaultClientRoute: '/videos/recently-added', | ||
55 | defaultNSFWPolicy: 'blur', | ||
56 | customizations: { | ||
57 | javascript: 'alert("coucou")', | ||
58 | css: 'body { background-color: red; }' | ||
59 | } | ||
60 | }, | ||
61 | services: { | ||
62 | twitter: { | ||
63 | username: '@MySuperUsername', | ||
64 | whitelisted: true | ||
65 | } | ||
66 | }, | ||
67 | cache: { | ||
68 | previews: { | ||
69 | size: 2 | ||
70 | }, | ||
71 | captions: { | ||
72 | size: 3 | ||
73 | } | ||
74 | }, | ||
75 | signup: { | ||
76 | enabled: false, | ||
77 | limit: 5 | ||
78 | }, | ||
79 | admin: { | ||
80 | email: 'superadmin1@example.com' | ||
81 | }, | ||
82 | user: { | ||
83 | videoQuota: 5242881 | ||
84 | }, | ||
85 | transcoding: { | ||
86 | enabled: true, | ||
87 | threads: 1, | ||
88 | resolutions: { | ||
89 | '240p': false, | ||
90 | '360p': true, | ||
91 | '480p': true, | ||
92 | '720p': false, | ||
93 | '1080p': false | ||
94 | } | ||
95 | }, | ||
96 | import: { | ||
97 | videos: { | ||
98 | http: { | ||
99 | enabled: false | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | Object.assign(updateParams, newConfig) | ||
106 | |||
107 | return updateCustomConfig(url, token, updateParams) | ||
108 | } | ||
109 | |||
47 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { | 110 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
48 | const path = '/api/v1/config/custom' | 111 | const path = '/api/v1/config/custom' |
49 | 112 | ||
@@ -62,5 +125,6 @@ export { | |||
62 | getCustomConfig, | 125 | getCustomConfig, |
63 | updateCustomConfig, | 126 | updateCustomConfig, |
64 | getAbout, | 127 | getAbout, |
65 | deleteCustomConfig | 128 | deleteCustomConfig, |
129 | updateCustomSubConfig | ||
66 | } | 130 | } |
diff --git a/server/tests/utils/videos/video-imports.ts b/server/tests/utils/videos/video-imports.ts new file mode 100644 index 000000000..e0f916990 --- /dev/null +++ b/server/tests/utils/videos/video-imports.ts | |||
@@ -0,0 +1,37 @@ | |||
1 | import { VideoImportCreate } from '../../../../shared/models/videos' | ||
2 | import { makeGetRequest, makePostBodyRequest } from '..' | ||
3 | |||
4 | function getYoutubeVideoUrl () { | ||
5 | return 'https://youtu.be/msX3jv1XdvM' | ||
6 | } | ||
7 | |||
8 | function importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
9 | const path = '/api/v1/videos/imports' | ||
10 | |||
11 | return makePostBodyRequest({ | ||
12 | url, | ||
13 | path, | ||
14 | token, | ||
15 | fields: attributes, | ||
16 | statusCodeExpected: 200 | ||
17 | }) | ||
18 | } | ||
19 | |||
20 | function getMyVideoImports (url: string, token: string) { | ||
21 | const path = '/api/v1/users/me/videos/imports' | ||
22 | |||
23 | return makeGetRequest({ | ||
24 | url, | ||
25 | path, | ||
26 | token, | ||
27 | statusCodeExpected: 200 | ||
28 | }) | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------------------- | ||
32 | |||
33 | export { | ||
34 | getYoutubeVideoUrl, | ||
35 | importVideo, | ||
36 | getMyVideoImports | ||
37 | } | ||
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 8c49eb02b..b280cccda 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -522,7 +522,9 @@ async function completeVideoCheck ( | |||
522 | 522 | ||
523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | 523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) |
524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
525 | expect(file.size).to.be.above(minSize).and.below(maxSize) | 525 | expect(file.size, |
526 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') | ||
527 | .to.be.above(minSize).and.below(maxSize) | ||
526 | 528 | ||
527 | { | 529 | { |
528 | await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) | 530 | await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) |