aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-18 14:06:12 +0100
committerChocobozzz <me@florianbigard.com>2021-02-18 14:08:16 +0100
commit53c06121a45a2ec943002833a0152bbfd4856ee4 (patch)
treee934d6ac102d5f7b29fe3316f57d6d2164aceeb9 /server
parent8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769 (diff)
downloadPeerTube-53c06121a45a2ec943002833a0152bbfd4856ee4.tar.gz
PeerTube-53c06121a45a2ec943002833a0152bbfd4856ee4.tar.zst
PeerTube-53c06121a45a2ec943002833a0152bbfd4856ee4.zip
Fix import tests
Diffstat (limited to 'server')
-rw-r--r--server/controllers/static.ts1
-rw-r--r--server/lib/thumbnail.ts2
-rw-r--r--server/lib/video-paths.ts4
-rw-r--r--server/tests/api/videos/video-imports.ts10
-rw-r--r--server/tests/fixtures/video_import_preview.jpgbin37360 -> 9551 bytes
5 files changed, 10 insertions, 7 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 7cc7f2c62..4baa31117 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -34,6 +34,7 @@ staticRouter.use(cors())
34*/ 34*/
35 35
36// FIXME: deprecated in 3.2, use lazy-statics instead 36// FIXME: deprecated in 3.2, use lazy-statics instead
37// Due to historical reasons, we can't really remove this controller
37const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR 38const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR
38staticRouter.use( 39staticRouter.use(
39 STATIC_PATHS.TORRENTS, 40 STATIC_PATHS.TORRENTS,
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts
index e37aefc85..06066f910 100644
--- a/server/lib/thumbnail.ts
+++ b/server/lib/thumbnail.ts
@@ -74,7 +74,7 @@ function createVideoMiniatureFromUrl (options: {
74 ? existingThumbnail.fileUrl 74 ? existingThumbnail.fileUrl
75 : null 75 : null
76 76
77 // If the thumbnail URL did not change and has a unique filename (introduced in 3.2), avoid thumbnail processing 77 // If the thumbnail URL did not change and has a unique filename (introduced in 3.1), avoid thumbnail processing
78 const thumbnailUrlChanged = !existingUrl || existingUrl !== downloadUrl || downloadUrl.endsWith(`${video.uuid}.jpg`) 78 const thumbnailUrlChanged = !existingUrl || existingUrl !== downloadUrl || downloadUrl.endsWith(`${video.uuid}.jpg`)
79 79
80 // Do not change the thumbnail filename if the file did not change 80 // Do not change the thumbnail filename if the file did not change
diff --git a/server/lib/video-paths.ts b/server/lib/video-paths.ts
index 0385e89cc..1708c479a 100644
--- a/server/lib/video-paths.ts
+++ b/server/lib/video-paths.ts
@@ -9,7 +9,7 @@ import { isStreamingPlaylist, MStreamingPlaylist, MStreamingPlaylistVideo, MVide
9function generateVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, isHls: boolean, resolution: number, extname: string) { 9function generateVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, isHls: boolean, resolution: number, extname: string) {
10 const video = extractVideo(videoOrPlaylist) 10 const video = extractVideo(videoOrPlaylist)
11 11
12 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.2 12 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.1
13 // const uuid = uuidv4() 13 // const uuid = uuidv4()
14 const uuid = video.uuid 14 const uuid = video.uuid
15 15
@@ -69,7 +69,7 @@ function generateTorrentFileName (videoOrPlaylist: MVideo | MStreamingPlaylistVi
69 const video = extractVideo(videoOrPlaylist) 69 const video = extractVideo(videoOrPlaylist)
70 const extension = '.torrent' 70 const extension = '.torrent'
71 71
72 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.2 72 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.1
73 // const uuid = uuidv4() 73 // const uuid = uuidv4()
74 const uuid = video.uuid 74 const uuid = video.uuid
75 75
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 61e7a81ee..80834ca86 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -129,8 +129,10 @@ describe('Test video imports', function () {
129 const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }) 129 const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })
130 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) 130 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
131 expect(res.body.video.name).to.equal('small video - youtube') 131 expect(res.body.video.name).to.equal('small video - youtube')
132 expect(res.body.video.thumbnailPath).to.equal(`/static/thumbnails/${res.body.video.uuid}.jpg`) 132
133 expect(res.body.video.previewPath).to.equal(`/lazy-static/previews/${res.body.video.uuid}.jpg`) 133 expect(res.body.video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
134 expect(res.body.video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`))
135
134 await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath) 136 await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath)
135 await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath) 137 await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath)
136 138
@@ -141,7 +143,7 @@ describe('Test video imports', function () {
141 const enCaption = videoCaptions.find(caption => caption.language.id === 'en') 143 const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
142 expect(enCaption).to.exist 144 expect(enCaption).to.exist
143 expect(enCaption.language.label).to.equal('English') 145 expect(enCaption.language.label).to.equal('English')
144 expect(enCaption.captionPath).to.equal(`/lazy-static/video-captions/${res.body.video.uuid}-en.vtt`) 146 expect(enCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-en.vtt$`))
145 await testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT 147 await testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT
146Kind: captions 148Kind: captions
147Language: en 149Language: en
@@ -158,7 +160,7 @@ Adding subtitles is very easy to do`)
158 const frCaption = videoCaptions.find(caption => caption.language.id === 'fr') 160 const frCaption = videoCaptions.find(caption => caption.language.id === 'fr')
159 expect(frCaption).to.exist 161 expect(frCaption).to.exist
160 expect(frCaption.language.label).to.equal('French') 162 expect(frCaption.language.label).to.equal('French')
161 expect(frCaption.captionPath).to.equal(`/lazy-static/video-captions/${res.body.video.uuid}-fr.vtt`) 163 expect(frCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-fr.vtt`))
162 await testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT 164 await testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT
163Kind: captions 165Kind: captions
164Language: fr 166Language: fr
diff --git a/server/tests/fixtures/video_import_preview.jpg b/server/tests/fixtures/video_import_preview.jpg
index 1f8d1d91d..a98da178f 100644
--- a/server/tests/fixtures/video_import_preview.jpg
+++ b/server/tests/fixtures/video_import_preview.jpg
Binary files differ