diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-12 20:04:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-12 20:37:51 +0200 |
commit | 2186386cca113506791583cb07d6ccacba7af4e0 (patch) | |
tree | 3c214c0b5fbd64332624267fa6e51fd4a9cf6474 /server/tests/api/videos | |
parent | 6ccdf3a23ecec5ba2eeaf487fd1fafdc7606b4bf (diff) | |
download | PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.gz PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.zst PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.zip |
Add concept of video state, and add ability to wait transcoding before
publishing a video
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 8 | ||||
-rw-r--r-- | server/tests/api/videos/services.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 74 |
3 files changed, 76 insertions, 9 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 5f9a76621..edc46a644 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -924,7 +924,7 @@ describe('Test multiple servers', function () { | |||
924 | 924 | ||
925 | describe('With minimum parameters', function () { | 925 | describe('With minimum parameters', function () { |
926 | it('Should upload and propagate the video', async function () { | 926 | it('Should upload and propagate the video', async function () { |
927 | this.timeout(50000) | 927 | this.timeout(60000) |
928 | 928 | ||
929 | const path = '/api/v1/videos/upload' | 929 | const path = '/api/v1/videos/upload' |
930 | 930 | ||
@@ -934,16 +934,14 @@ describe('Test multiple servers', function () { | |||
934 | .set('Authorization', 'Bearer ' + servers[1].accessToken) | 934 | .set('Authorization', 'Bearer ' + servers[1].accessToken) |
935 | .field('name', 'minimum parameters') | 935 | .field('name', 'minimum parameters') |
936 | .field('privacy', '1') | 936 | .field('privacy', '1') |
937 | .field('nsfw', 'false') | ||
938 | .field('channelId', '1') | 937 | .field('channelId', '1') |
939 | .field('commentsEnabled', 'true') | ||
940 | 938 | ||
941 | const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') | 939 | const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') |
942 | 940 | ||
943 | await req.attach('videofile', filePath) | 941 | await req.attach('videofile', filePath) |
944 | .expect(200) | 942 | .expect(200) |
945 | 943 | ||
946 | await wait(25000) | 944 | await wait(40000) |
947 | 945 | ||
948 | for (const server of servers) { | 946 | for (const server of servers) { |
949 | const res = await getVideosList(server.url) | 947 | const res = await getVideosList(server.url) |
@@ -964,7 +962,7 @@ describe('Test multiple servers', function () { | |||
964 | }, | 962 | }, |
965 | isLocal, | 963 | isLocal, |
966 | duration: 5, | 964 | duration: 5, |
967 | commentsEnabled: true, | 965 | commentsEnabled: false, |
968 | tags: [ ], | 966 | tags: [ ], |
969 | privacy: VideoPrivacy.PUBLIC, | 967 | privacy: VideoPrivacy.PUBLIC, |
970 | channel: { | 968 | channel: { |
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index 45b4a1a81..51db000a2 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts | |||
@@ -32,7 +32,8 @@ describe('Test services', function () { | |||
32 | const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid | 32 | const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid |
33 | 33 | ||
34 | const res = await getOEmbed(server.url, oembedUrl) | 34 | const res = await getOEmbed(server.url, oembedUrl) |
35 | const expectedHtml = `<iframe width="560" height="315" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + | 35 | const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + |
36 | `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + | ||
36 | 'frameborder="0" allowfullscreen></iframe>' | 37 | 'frameborder="0" allowfullscreen></iframe>' |
37 | const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' | 38 | const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' |
38 | 39 | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index ef929960d..1eace6491 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -2,11 +2,22 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { VideoDetails } from '../../../../shared/models/videos' | 5 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' |
6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' | 6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' |
7 | import { | 7 | import { |
8 | flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, | 8 | doubleFollow, |
9 | wait, webtorrentAdd | 9 | flushAndRunMultipleServers, |
10 | flushTests, | ||
11 | getMyVideos, | ||
12 | getVideo, | ||
13 | getVideosList, | ||
14 | killallServers, | ||
15 | root, | ||
16 | ServerInfo, | ||
17 | setAccessTokensToServers, | ||
18 | uploadVideo, | ||
19 | wait, | ||
20 | webtorrentAdd | ||
10 | } from '../../utils' | 21 | } from '../../utils' |
11 | import { join } from 'path' | 22 | import { join } from 'path' |
12 | 23 | ||
@@ -109,6 +120,63 @@ describe('Test video transcoding', function () { | |||
109 | } | 120 | } |
110 | }) | 121 | }) |
111 | 122 | ||
123 | it('Should wait transcoding before publishing the video', async function () { | ||
124 | this.timeout(80000) | ||
125 | |||
126 | await doubleFollow(servers[0], servers[1]) | ||
127 | |||
128 | await wait(15000) | ||
129 | |||
130 | { | ||
131 | // Upload the video, but wait transcoding | ||
132 | const videoAttributes = { | ||
133 | name: 'waiting video', | ||
134 | fixture: 'video_short1.webm', | ||
135 | waitTranscoding: true | ||
136 | } | ||
137 | const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes) | ||
138 | const videoId = resVideo.body.video.uuid | ||
139 | |||
140 | // Should be in transcode state | ||
141 | const { body } = await getVideo(servers[ 1 ].url, videoId) | ||
142 | expect(body.name).to.equal('waiting video') | ||
143 | expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) | ||
144 | expect(body.state.label).to.equal('To transcode') | ||
145 | expect(body.waitTranscoding).to.be.true | ||
146 | |||
147 | // Should have my video | ||
148 | const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) | ||
149 | const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video') | ||
150 | expect(videoToFindInMine).not.to.be.undefined | ||
151 | expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) | ||
152 | expect(videoToFindInMine.state.label).to.equal('To transcode') | ||
153 | expect(videoToFindInMine.waitTranscoding).to.be.true | ||
154 | |||
155 | // Should not list this video | ||
156 | const resVideos = await getVideosList(servers[1].url) | ||
157 | const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video') | ||
158 | expect(videoToFindInList).to.be.undefined | ||
159 | |||
160 | // Server 1 should not have the video yet | ||
161 | await getVideo(servers[0].url, videoId, 404) | ||
162 | } | ||
163 | |||
164 | await wait(30000) | ||
165 | |||
166 | for (const server of servers) { | ||
167 | const res = await getVideosList(server.url) | ||
168 | const videoToFind = res.body.data.find(v => v.name === 'waiting video') | ||
169 | expect(videoToFind).not.to.be.undefined | ||
170 | |||
171 | const res2 = await getVideo(server.url, videoToFind.id) | ||
172 | const videoDetails: VideoDetails = res2.body | ||
173 | |||
174 | expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) | ||
175 | expect(videoDetails.state.label).to.equal('Published') | ||
176 | expect(videoDetails.waitTranscoding).to.be.true | ||
177 | } | ||
178 | }) | ||
179 | |||
112 | after(async function () { | 180 | after(async function () { |
113 | killallServers(servers) | 181 | killallServers(servers) |
114 | 182 | ||