diff options
Diffstat (limited to 'server/tests/api/videos/video-files.ts')
-rw-r--r-- | server/tests/api/videos/video-files.ts | 202 |
1 files changed, 0 insertions, 202 deletions
diff --git a/server/tests/api/videos/video-files.ts b/server/tests/api/videos/video-files.ts deleted file mode 100644 index 4f75cd106..000000000 --- a/server/tests/api/videos/video-files.ts +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { HttpStatusCode } from '@shared/models' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | makeRawRequest, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
14 | |||
15 | describe('Test videos files', function () { | ||
16 | let servers: PeerTubeServer[] | ||
17 | |||
18 | // --------------------------------------------------------------- | ||
19 | |||
20 | before(async function () { | ||
21 | this.timeout(150_000) | ||
22 | |||
23 | servers = await createMultipleServers(2) | ||
24 | await setAccessTokensToServers(servers) | ||
25 | |||
26 | await doubleFollow(servers[0], servers[1]) | ||
27 | |||
28 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true }) | ||
29 | }) | ||
30 | |||
31 | describe('When deleting all files', function () { | ||
32 | let validId1: string | ||
33 | let validId2: string | ||
34 | |||
35 | before(async function () { | ||
36 | this.timeout(360_000) | ||
37 | |||
38 | { | ||
39 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' }) | ||
40 | validId1 = uuid | ||
41 | } | ||
42 | |||
43 | { | ||
44 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 2' }) | ||
45 | validId2 = uuid | ||
46 | } | ||
47 | |||
48 | await waitJobs(servers) | ||
49 | }) | ||
50 | |||
51 | it('Should delete web video files', async function () { | ||
52 | this.timeout(30_000) | ||
53 | |||
54 | await servers[0].videos.removeAllWebVideoFiles({ videoId: validId1 }) | ||
55 | |||
56 | await waitJobs(servers) | ||
57 | |||
58 | for (const server of servers) { | ||
59 | const video = await server.videos.get({ id: validId1 }) | ||
60 | |||
61 | expect(video.files).to.have.lengthOf(0) | ||
62 | expect(video.streamingPlaylists).to.have.lengthOf(1) | ||
63 | } | ||
64 | }) | ||
65 | |||
66 | it('Should delete HLS files', async function () { | ||
67 | this.timeout(30_000) | ||
68 | |||
69 | await servers[0].videos.removeHLSPlaylist({ videoId: validId2 }) | ||
70 | |||
71 | await waitJobs(servers) | ||
72 | |||
73 | for (const server of servers) { | ||
74 | const video = await server.videos.get({ id: validId2 }) | ||
75 | |||
76 | expect(video.files).to.have.length.above(0) | ||
77 | expect(video.streamingPlaylists).to.have.lengthOf(0) | ||
78 | } | ||
79 | }) | ||
80 | }) | ||
81 | |||
82 | describe('When deleting a specific file', function () { | ||
83 | let webVideoId: string | ||
84 | let hlsId: string | ||
85 | |||
86 | before(async function () { | ||
87 | this.timeout(120_000) | ||
88 | |||
89 | { | ||
90 | const { uuid } = await servers[0].videos.quickUpload({ name: 'web-video' }) | ||
91 | webVideoId = uuid | ||
92 | } | ||
93 | |||
94 | { | ||
95 | const { uuid } = await servers[0].videos.quickUpload({ name: 'hls' }) | ||
96 | hlsId = uuid | ||
97 | } | ||
98 | |||
99 | await waitJobs(servers) | ||
100 | }) | ||
101 | |||
102 | it('Shoulde delete a web video file', async function () { | ||
103 | this.timeout(30_000) | ||
104 | |||
105 | const video = await servers[0].videos.get({ id: webVideoId }) | ||
106 | const files = video.files | ||
107 | |||
108 | await servers[0].videos.removeWebVideoFile({ videoId: webVideoId, fileId: files[0].id }) | ||
109 | |||
110 | await waitJobs(servers) | ||
111 | |||
112 | for (const server of servers) { | ||
113 | const video = await server.videos.get({ id: webVideoId }) | ||
114 | |||
115 | expect(video.files).to.have.lengthOf(files.length - 1) | ||
116 | expect(video.files.find(f => f.id === files[0].id)).to.not.exist | ||
117 | } | ||
118 | }) | ||
119 | |||
120 | it('Should delete all web video files', async function () { | ||
121 | this.timeout(30_000) | ||
122 | |||
123 | const video = await servers[0].videos.get({ id: webVideoId }) | ||
124 | const files = video.files | ||
125 | |||
126 | for (const file of files) { | ||
127 | await servers[0].videos.removeWebVideoFile({ videoId: webVideoId, fileId: file.id }) | ||
128 | } | ||
129 | |||
130 | await waitJobs(servers) | ||
131 | |||
132 | for (const server of servers) { | ||
133 | const video = await server.videos.get({ id: webVideoId }) | ||
134 | |||
135 | expect(video.files).to.have.lengthOf(0) | ||
136 | } | ||
137 | }) | ||
138 | |||
139 | it('Should delete a hls file', async function () { | ||
140 | this.timeout(30_000) | ||
141 | |||
142 | const video = await servers[0].videos.get({ id: hlsId }) | ||
143 | const files = video.streamingPlaylists[0].files | ||
144 | const toDelete = files[0] | ||
145 | |||
146 | await servers[0].videos.removeHLSFile({ videoId: hlsId, fileId: toDelete.id }) | ||
147 | |||
148 | await waitJobs(servers) | ||
149 | |||
150 | for (const server of servers) { | ||
151 | const video = await server.videos.get({ id: hlsId }) | ||
152 | |||
153 | expect(video.streamingPlaylists[0].files).to.have.lengthOf(files.length - 1) | ||
154 | expect(video.streamingPlaylists[0].files.find(f => f.id === toDelete.id)).to.not.exist | ||
155 | |||
156 | const { text } = await makeRawRequest({ url: video.streamingPlaylists[0].playlistUrl, expectedStatus: HttpStatusCode.OK_200 }) | ||
157 | |||
158 | expect(text.includes(`-${toDelete.resolution.id}.m3u8`)).to.be.false | ||
159 | expect(text.includes(`-${video.streamingPlaylists[0].files[0].resolution.id}.m3u8`)).to.be.true | ||
160 | } | ||
161 | }) | ||
162 | |||
163 | it('Should delete all hls files', async function () { | ||
164 | this.timeout(30_000) | ||
165 | |||
166 | const video = await servers[0].videos.get({ id: hlsId }) | ||
167 | const files = video.streamingPlaylists[0].files | ||
168 | |||
169 | for (const file of files) { | ||
170 | await servers[0].videos.removeHLSFile({ videoId: hlsId, fileId: file.id }) | ||
171 | } | ||
172 | |||
173 | await waitJobs(servers) | ||
174 | |||
175 | for (const server of servers) { | ||
176 | const video = await server.videos.get({ id: hlsId }) | ||
177 | |||
178 | expect(video.streamingPlaylists).to.have.lengthOf(0) | ||
179 | } | ||
180 | }) | ||
181 | |||
182 | it('Should not delete last file of a video', async function () { | ||
183 | this.timeout(60_000) | ||
184 | |||
185 | const webVideoOnly = await servers[0].videos.get({ id: hlsId }) | ||
186 | const hlsOnly = await servers[0].videos.get({ id: webVideoId }) | ||
187 | |||
188 | for (let i = 0; i < 4; i++) { | ||
189 | await servers[0].videos.removeWebVideoFile({ videoId: webVideoOnly.id, fileId: webVideoOnly.files[i].id }) | ||
190 | await servers[0].videos.removeHLSFile({ videoId: hlsOnly.id, fileId: hlsOnly.streamingPlaylists[0].files[i].id }) | ||
191 | } | ||
192 | |||
193 | const expectedStatus = HttpStatusCode.BAD_REQUEST_400 | ||
194 | await servers[0].videos.removeWebVideoFile({ videoId: webVideoOnly.id, fileId: webVideoOnly.files[4].id, expectedStatus }) | ||
195 | await servers[0].videos.removeHLSFile({ videoId: hlsOnly.id, fileId: hlsOnly.streamingPlaylists[0].files[4].id, expectedStatus }) | ||
196 | }) | ||
197 | }) | ||
198 | |||
199 | after(async function () { | ||
200 | await cleanupTests(servers) | ||
201 | }) | ||
202 | }) | ||