diff options
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 14aed604f..4f9ecbe8e 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | areHttpImportTestsDisabled, | ||
6 | cleanupTests, | 7 | cleanupTests, |
7 | doubleFollow, | 8 | doubleFollow, |
8 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
@@ -11,20 +12,14 @@ import { | |||
11 | getVideo, | 12 | getVideo, |
12 | getVideosList, | 13 | getVideosList, |
13 | immutableAssign, | 14 | immutableAssign, |
15 | ImportsCommand, | ||
14 | ServerInfo, | 16 | ServerInfo, |
15 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
16 | testCaptionFile | 18 | testCaptionFile, |
17 | } from '../../../../shared/extra-utils' | 19 | testImage, |
18 | import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs' | 20 | waitJobs |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | } from '@shared/extra-utils' |
20 | import { | 22 | import { VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' |
21 | getMagnetURI, | ||
22 | getMyVideoImports, | ||
23 | getYoutubeHDRVideoUrl, | ||
24 | getYoutubeVideoUrl, | ||
25 | importVideo | ||
26 | } from '../../../../shared/extra-utils/videos/video-imports' | ||
27 | import { VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos' | ||
28 | 23 | ||
29 | const expect = chai.expect | 24 | const expect = chai.expect |
30 | 25 | ||
@@ -124,17 +119,17 @@ describe('Test video imports', function () { | |||
124 | } | 119 | } |
125 | 120 | ||
126 | { | 121 | { |
127 | const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) | 122 | const attributes = immutableAssign(baseAttributes, { targetUrl: ImportsCommand.getYoutubeVideoUrl() }) |
128 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 123 | const { video } = await servers[0].importsCommand.importVideo({ attributes }) |
129 | expect(res.body.video.name).to.equal('small video - youtube') | 124 | expect(video.name).to.equal('small video - youtube') |
130 | 125 | ||
131 | expect(res.body.video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`)) | 126 | expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`)) |
132 | expect(res.body.video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`)) | 127 | expect(video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`)) |
133 | 128 | ||
134 | await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath) | 129 | await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath) |
135 | await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath) | 130 | await testImage(servers[0].url, 'video_import_preview', video.previewPath) |
136 | 131 | ||
137 | const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: res.body.video.id }) | 132 | const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: video.id }) |
138 | const videoCaptions = bodyCaptions.data | 133 | const videoCaptions = bodyCaptions.data |
139 | expect(videoCaptions).to.have.lengthOf(2) | 134 | expect(videoCaptions).to.have.lengthOf(2) |
140 | 135 | ||
@@ -175,12 +170,12 @@ Ajouter un sous-titre est vraiment facile`) | |||
175 | 170 | ||
176 | { | 171 | { |
177 | const attributes = immutableAssign(baseAttributes, { | 172 | const attributes = immutableAssign(baseAttributes, { |
178 | magnetUri: getMagnetURI(), | 173 | magnetUri: ImportsCommand.getMagnetURI(), |
179 | description: 'this is a super torrent description', | 174 | description: 'this is a super torrent description', |
180 | tags: [ 'tag_torrent1', 'tag_torrent2' ] | 175 | tags: [ 'tag_torrent1', 'tag_torrent2' ] |
181 | }) | 176 | }) |
182 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 177 | const { video } = await servers[0].importsCommand.importVideo({ attributes }) |
183 | expect(res.body.video.name).to.equal('super peertube2 video') | 178 | expect(video.name).to.equal('super peertube2 video') |
184 | } | 179 | } |
185 | 180 | ||
186 | { | 181 | { |
@@ -189,8 +184,8 @@ Ajouter un sous-titre est vraiment facile`) | |||
189 | description: 'this is a super torrent description', | 184 | description: 'this is a super torrent description', |
190 | tags: [ 'tag_torrent1', 'tag_torrent2' ] | 185 | tags: [ 'tag_torrent1', 'tag_torrent2' ] |
191 | }) | 186 | }) |
192 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 187 | const { video } = await servers[0].importsCommand.importVideo({ attributes }) |
193 | expect(res.body.video.name).to.equal('你好 世界 720p.mp4') | 188 | expect(video.name).to.equal('你好 世界 720p.mp4') |
194 | } | 189 | } |
195 | }) | 190 | }) |
196 | 191 | ||
@@ -207,19 +202,18 @@ Ajouter un sous-titre est vraiment facile`) | |||
207 | }) | 202 | }) |
208 | 203 | ||
209 | it('Should list the videos to import in my imports on server 1', async function () { | 204 | it('Should list the videos to import in my imports on server 1', async function () { |
210 | const res = await getMyVideoImports(servers[0].url, servers[0].accessToken, '-createdAt') | 205 | const { total, data: videoImports } = await servers[0].importsCommand.getMyVideoImports({ sort: '-createdAt' }) |
206 | expect(total).to.equal(3) | ||
211 | 207 | ||
212 | expect(res.body.total).to.equal(3) | ||
213 | const videoImports: VideoImport[] = res.body.data | ||
214 | expect(videoImports).to.have.lengthOf(3) | 208 | expect(videoImports).to.have.lengthOf(3) |
215 | 209 | ||
216 | expect(videoImports[2].targetUrl).to.equal(getYoutubeVideoUrl()) | 210 | expect(videoImports[2].targetUrl).to.equal(ImportsCommand.getYoutubeVideoUrl()) |
217 | expect(videoImports[2].magnetUri).to.be.null | 211 | expect(videoImports[2].magnetUri).to.be.null |
218 | expect(videoImports[2].torrentName).to.be.null | 212 | expect(videoImports[2].torrentName).to.be.null |
219 | expect(videoImports[2].video.name).to.equal('small video - youtube') | 213 | expect(videoImports[2].video.name).to.equal('small video - youtube') |
220 | 214 | ||
221 | expect(videoImports[1].targetUrl).to.be.null | 215 | expect(videoImports[1].targetUrl).to.be.null |
222 | expect(videoImports[1].magnetUri).to.equal(getMagnetURI()) | 216 | expect(videoImports[1].magnetUri).to.equal(ImportsCommand.getMagnetURI()) |
223 | expect(videoImports[1].torrentName).to.be.null | 217 | expect(videoImports[1].torrentName).to.be.null |
224 | expect(videoImports[1].video.name).to.equal('super peertube2 video') | 218 | expect(videoImports[1].video.name).to.equal('super peertube2 video') |
225 | 219 | ||
@@ -248,7 +242,7 @@ Ajouter un sous-titre est vraiment facile`) | |||
248 | this.timeout(60_000) | 242 | this.timeout(60_000) |
249 | 243 | ||
250 | const attributes = { | 244 | const attributes = { |
251 | targetUrl: getYoutubeVideoUrl(), | 245 | targetUrl: ImportsCommand.getYoutubeVideoUrl(), |
252 | channelId: channelIdServer2, | 246 | channelId: channelIdServer2, |
253 | privacy: VideoPrivacy.PUBLIC, | 247 | privacy: VideoPrivacy.PUBLIC, |
254 | category: 10, | 248 | category: 10, |
@@ -258,8 +252,8 @@ Ajouter un sous-titre est vraiment facile`) | |||
258 | description: 'my super description', | 252 | description: 'my super description', |
259 | tags: [ 'supertag1', 'supertag2' ] | 253 | tags: [ 'supertag1', 'supertag2' ] |
260 | } | 254 | } |
261 | const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) | 255 | const { video } = await servers[1].importsCommand.importVideo({ attributes }) |
262 | expect(res.body.video.name).to.equal('my super name') | 256 | expect(video.name).to.equal('my super name') |
263 | }) | 257 | }) |
264 | 258 | ||
265 | it('Should have the videos listed on the two instances', async function () { | 259 | it('Should have the videos listed on the two instances', async function () { |
@@ -284,12 +278,12 @@ Ajouter un sous-titre est vraiment facile`) | |||
284 | 278 | ||
285 | const attributes = { | 279 | const attributes = { |
286 | name: 'transcoded video', | 280 | name: 'transcoded video', |
287 | magnetUri: getMagnetURI(), | 281 | magnetUri: ImportsCommand.getMagnetURI(), |
288 | channelId: channelIdServer2, | 282 | channelId: channelIdServer2, |
289 | privacy: VideoPrivacy.PUBLIC | 283 | privacy: VideoPrivacy.PUBLIC |
290 | } | 284 | } |
291 | const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) | 285 | const { video } = await servers[1].importsCommand.importVideo({ attributes }) |
292 | const videoUUID = res.body.video.uuid | 286 | const videoUUID = video.uuid |
293 | 287 | ||
294 | await waitJobs(servers) | 288 | await waitJobs(servers) |
295 | 289 | ||
@@ -335,12 +329,12 @@ Ajouter un sous-titre est vraiment facile`) | |||
335 | 329 | ||
336 | const attributes = { | 330 | const attributes = { |
337 | name: 'hdr video', | 331 | name: 'hdr video', |
338 | targetUrl: getYoutubeHDRVideoUrl(), | 332 | targetUrl: ImportsCommand.getYoutubeHDRVideoUrl(), |
339 | channelId: channelIdServer1, | 333 | channelId: channelIdServer1, |
340 | privacy: VideoPrivacy.PUBLIC | 334 | privacy: VideoPrivacy.PUBLIC |
341 | } | 335 | } |
342 | const res1 = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 336 | const { video: videoImported } = await servers[0].importsCommand.importVideo({ attributes }) |
343 | const videoUUID = res1.body.video.uuid | 337 | const videoUUID = videoImported.uuid |
344 | 338 | ||
345 | await waitJobs(servers) | 339 | await waitJobs(servers) |
346 | 340 | ||