diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 09:04:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 89d241a79c262b9775c233b73cff080043ebb5e6 (patch) | |
tree | cb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/api/videos/single-server.ts | |
parent | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff) | |
download | PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip |
Shorter server command names
Diffstat (limited to 'server/tests/api/videos/single-server.ts')
-rw-r--r-- | server/tests/api/videos/single-server.ts | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index da0b2011e..12c1f7b2f 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -100,35 +100,35 @@ describe('Test a single server', function () { | |||
100 | }) | 100 | }) |
101 | 101 | ||
102 | it('Should list video categories', async function () { | 102 | it('Should list video categories', async function () { |
103 | const categories = await server.videosCommand.getCategories() | 103 | const categories = await server.videos.getCategories() |
104 | expect(Object.keys(categories)).to.have.length.above(10) | 104 | expect(Object.keys(categories)).to.have.length.above(10) |
105 | 105 | ||
106 | expect(categories[11]).to.equal('News & Politics') | 106 | expect(categories[11]).to.equal('News & Politics') |
107 | }) | 107 | }) |
108 | 108 | ||
109 | it('Should list video licences', async function () { | 109 | it('Should list video licences', async function () { |
110 | const licences = await server.videosCommand.getLicences() | 110 | const licences = await server.videos.getLicences() |
111 | expect(Object.keys(licences)).to.have.length.above(5) | 111 | expect(Object.keys(licences)).to.have.length.above(5) |
112 | 112 | ||
113 | expect(licences[3]).to.equal('Attribution - No Derivatives') | 113 | expect(licences[3]).to.equal('Attribution - No Derivatives') |
114 | }) | 114 | }) |
115 | 115 | ||
116 | it('Should list video languages', async function () { | 116 | it('Should list video languages', async function () { |
117 | const languages = await server.videosCommand.getLanguages() | 117 | const languages = await server.videos.getLanguages() |
118 | expect(Object.keys(languages)).to.have.length.above(5) | 118 | expect(Object.keys(languages)).to.have.length.above(5) |
119 | 119 | ||
120 | expect(languages['ru']).to.equal('Russian') | 120 | expect(languages['ru']).to.equal('Russian') |
121 | }) | 121 | }) |
122 | 122 | ||
123 | it('Should list video privacies', async function () { | 123 | it('Should list video privacies', async function () { |
124 | const privacies = await server.videosCommand.getPrivacies() | 124 | const privacies = await server.videos.getPrivacies() |
125 | expect(Object.keys(privacies)).to.have.length.at.least(3) | 125 | expect(Object.keys(privacies)).to.have.length.at.least(3) |
126 | 126 | ||
127 | expect(privacies[3]).to.equal('Private') | 127 | expect(privacies[3]).to.equal('Private') |
128 | }) | 128 | }) |
129 | 129 | ||
130 | it('Should not have videos', async function () { | 130 | it('Should not have videos', async function () { |
131 | const { data, total } = await server.videosCommand.list() | 131 | const { data, total } = await server.videos.list() |
132 | 132 | ||
133 | expect(total).to.equal(0) | 133 | expect(total).to.equal(0) |
134 | expect(data).to.be.an('array') | 134 | expect(data).to.be.an('array') |
@@ -145,7 +145,7 @@ describe('Test a single server', function () { | |||
145 | licence: 6, | 145 | licence: 6, |
146 | tags: [ 'tag1', 'tag2', 'tag3' ] | 146 | tags: [ 'tag1', 'tag2', 'tag3' ] |
147 | } | 147 | } |
148 | const video = await server.videosCommand.upload({ attributes, mode }) | 148 | const video = await server.videos.upload({ attributes, mode }) |
149 | expect(video).to.not.be.undefined | 149 | expect(video).to.not.be.undefined |
150 | expect(video.id).to.equal(1) | 150 | expect(video.id).to.equal(1) |
151 | expect(video.uuid).to.have.length.above(5) | 151 | expect(video.uuid).to.have.length.above(5) |
@@ -157,7 +157,7 @@ describe('Test a single server', function () { | |||
157 | it('Should get and seed the uploaded video', async function () { | 157 | it('Should get and seed the uploaded video', async function () { |
158 | this.timeout(5000) | 158 | this.timeout(5000) |
159 | 159 | ||
160 | const { data, total } = await server.videosCommand.list() | 160 | const { data, total } = await server.videos.list() |
161 | 161 | ||
162 | expect(total).to.equal(1) | 162 | expect(total).to.equal(1) |
163 | expect(data).to.be.an('array') | 163 | expect(data).to.be.an('array') |
@@ -170,42 +170,42 @@ describe('Test a single server', function () { | |||
170 | it('Should get the video by UUID', async function () { | 170 | it('Should get the video by UUID', async function () { |
171 | this.timeout(5000) | 171 | this.timeout(5000) |
172 | 172 | ||
173 | const video = await server.videosCommand.get({ id: videoUUID }) | 173 | const video = await server.videos.get({ id: videoUUID }) |
174 | await completeVideoCheck(server, video, getCheckAttributes()) | 174 | await completeVideoCheck(server, video, getCheckAttributes()) |
175 | }) | 175 | }) |
176 | 176 | ||
177 | it('Should have the views updated', async function () { | 177 | it('Should have the views updated', async function () { |
178 | this.timeout(20000) | 178 | this.timeout(20000) |
179 | 179 | ||
180 | await server.videosCommand.view({ id: videoId }) | 180 | await server.videos.view({ id: videoId }) |
181 | await server.videosCommand.view({ id: videoId }) | 181 | await server.videos.view({ id: videoId }) |
182 | await server.videosCommand.view({ id: videoId }) | 182 | await server.videos.view({ id: videoId }) |
183 | 183 | ||
184 | await wait(1500) | 184 | await wait(1500) |
185 | 185 | ||
186 | await server.videosCommand.view({ id: videoId }) | 186 | await server.videos.view({ id: videoId }) |
187 | await server.videosCommand.view({ id: videoId }) | 187 | await server.videos.view({ id: videoId }) |
188 | 188 | ||
189 | await wait(1500) | 189 | await wait(1500) |
190 | 190 | ||
191 | await server.videosCommand.view({ id: videoId }) | 191 | await server.videos.view({ id: videoId }) |
192 | await server.videosCommand.view({ id: videoId }) | 192 | await server.videos.view({ id: videoId }) |
193 | 193 | ||
194 | // Wait the repeatable job | 194 | // Wait the repeatable job |
195 | await wait(8000) | 195 | await wait(8000) |
196 | 196 | ||
197 | const video = await server.videosCommand.get({ id: videoId }) | 197 | const video = await server.videos.get({ id: videoId }) |
198 | expect(video.views).to.equal(3) | 198 | expect(video.views).to.equal(3) |
199 | }) | 199 | }) |
200 | 200 | ||
201 | it('Should remove the video', async function () { | 201 | it('Should remove the video', async function () { |
202 | await server.videosCommand.remove({ id: videoId }) | 202 | await server.videos.remove({ id: videoId }) |
203 | 203 | ||
204 | await checkVideoFilesWereRemoved(videoUUID, server) | 204 | await checkVideoFilesWereRemoved(videoUUID, server) |
205 | }) | 205 | }) |
206 | 206 | ||
207 | it('Should not have videos', async function () { | 207 | it('Should not have videos', async function () { |
208 | const { total, data } = await server.videosCommand.list() | 208 | const { total, data } = await server.videos.list() |
209 | 209 | ||
210 | expect(total).to.equal(0) | 210 | expect(total).to.equal(0) |
211 | expect(data).to.be.an('array') | 211 | expect(data).to.be.an('array') |
@@ -232,12 +232,12 @@ describe('Test a single server', function () { | |||
232 | fixture: video | 232 | fixture: video |
233 | } | 233 | } |
234 | 234 | ||
235 | await server.videosCommand.upload({ attributes, mode }) | 235 | await server.videos.upload({ attributes, mode }) |
236 | } | 236 | } |
237 | }) | 237 | }) |
238 | 238 | ||
239 | it('Should have the correct durations', async function () { | 239 | it('Should have the correct durations', async function () { |
240 | const { total, data } = await server.videosCommand.list() | 240 | const { total, data } = await server.videos.list() |
241 | 241 | ||
242 | expect(total).to.equal(6) | 242 | expect(total).to.equal(6) |
243 | expect(data).to.be.an('array') | 243 | expect(data).to.be.an('array') |
@@ -255,7 +255,7 @@ describe('Test a single server', function () { | |||
255 | }) | 255 | }) |
256 | 256 | ||
257 | it('Should have the correct thumbnails', async function () { | 257 | it('Should have the correct thumbnails', async function () { |
258 | const { data } = await server.videosCommand.list() | 258 | const { data } = await server.videos.list() |
259 | 259 | ||
260 | // For the next test | 260 | // For the next test |
261 | videosListBase = data | 261 | videosListBase = data |
@@ -267,7 +267,7 @@ describe('Test a single server', function () { | |||
267 | }) | 267 | }) |
268 | 268 | ||
269 | it('Should list only the two first videos', async function () { | 269 | it('Should list only the two first videos', async function () { |
270 | const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' }) | 270 | const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' }) |
271 | 271 | ||
272 | expect(total).to.equal(6) | 272 | expect(total).to.equal(6) |
273 | expect(data.length).to.equal(2) | 273 | expect(data.length).to.equal(2) |
@@ -276,7 +276,7 @@ describe('Test a single server', function () { | |||
276 | }) | 276 | }) |
277 | 277 | ||
278 | it('Should list only the next three videos', async function () { | 278 | it('Should list only the next three videos', async function () { |
279 | const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' }) | 279 | const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' }) |
280 | 280 | ||
281 | expect(total).to.equal(6) | 281 | expect(total).to.equal(6) |
282 | expect(data.length).to.equal(3) | 282 | expect(data.length).to.equal(3) |
@@ -286,7 +286,7 @@ describe('Test a single server', function () { | |||
286 | }) | 286 | }) |
287 | 287 | ||
288 | it('Should list the last video', async function () { | 288 | it('Should list the last video', async function () { |
289 | const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' }) | 289 | const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' }) |
290 | 290 | ||
291 | expect(total).to.equal(6) | 291 | expect(total).to.equal(6) |
292 | expect(data.length).to.equal(1) | 292 | expect(data.length).to.equal(1) |
@@ -294,7 +294,7 @@ describe('Test a single server', function () { | |||
294 | }) | 294 | }) |
295 | 295 | ||
296 | it('Should not have the total field', async function () { | 296 | it('Should not have the total field', async function () { |
297 | const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true }) | 297 | const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true }) |
298 | 298 | ||
299 | expect(total).to.not.exist | 299 | expect(total).to.not.exist |
300 | expect(data.length).to.equal(1) | 300 | expect(data.length).to.equal(1) |
@@ -302,7 +302,7 @@ describe('Test a single server', function () { | |||
302 | }) | 302 | }) |
303 | 303 | ||
304 | it('Should list and sort by name in descending order', async function () { | 304 | it('Should list and sort by name in descending order', async function () { |
305 | const { total, data } = await server.videosCommand.list({ sort: '-name' }) | 305 | const { total, data } = await server.videos.list({ sort: '-name' }) |
306 | 306 | ||
307 | expect(total).to.equal(6) | 307 | expect(total).to.equal(6) |
308 | expect(data.length).to.equal(6) | 308 | expect(data.length).to.equal(6) |
@@ -318,21 +318,21 @@ describe('Test a single server', function () { | |||
318 | }) | 318 | }) |
319 | 319 | ||
320 | it('Should list and sort by trending in descending order', async function () { | 320 | it('Should list and sort by trending in descending order', async function () { |
321 | const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' }) | 321 | const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-trending' }) |
322 | 322 | ||
323 | expect(total).to.equal(6) | 323 | expect(total).to.equal(6) |
324 | expect(data.length).to.equal(2) | 324 | expect(data.length).to.equal(2) |
325 | }) | 325 | }) |
326 | 326 | ||
327 | it('Should list and sort by hotness in descending order', async function () { | 327 | it('Should list and sort by hotness in descending order', async function () { |
328 | const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-hot' }) | 328 | const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-hot' }) |
329 | 329 | ||
330 | expect(total).to.equal(6) | 330 | expect(total).to.equal(6) |
331 | expect(data.length).to.equal(2) | 331 | expect(data.length).to.equal(2) |
332 | }) | 332 | }) |
333 | 333 | ||
334 | it('Should list and sort by best in descending order', async function () { | 334 | it('Should list and sort by best in descending order', async function () { |
335 | const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-best' }) | 335 | const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' }) |
336 | 336 | ||
337 | expect(total).to.equal(6) | 337 | expect(total).to.equal(6) |
338 | expect(data.length).to.equal(2) | 338 | expect(data.length).to.equal(2) |
@@ -350,18 +350,18 @@ describe('Test a single server', function () { | |||
350 | downloadEnabled: false, | 350 | downloadEnabled: false, |
351 | tags: [ 'tagup1', 'tagup2' ] | 351 | tags: [ 'tagup1', 'tagup2' ] |
352 | } | 352 | } |
353 | await server.videosCommand.update({ id: videoId, attributes }) | 353 | await server.videos.update({ id: videoId, attributes }) |
354 | }) | 354 | }) |
355 | 355 | ||
356 | it('Should filter by tags and category', async function () { | 356 | it('Should filter by tags and category', async function () { |
357 | { | 357 | { |
358 | const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) | 358 | const { data, total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) |
359 | expect(total).to.equal(1) | 359 | expect(total).to.equal(1) |
360 | expect(data[0].name).to.equal('my super video updated') | 360 | expect(data[0].name).to.equal('my super video updated') |
361 | } | 361 | } |
362 | 362 | ||
363 | { | 363 | { |
364 | const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) | 364 | const { total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) |
365 | expect(total).to.equal(0) | 365 | expect(total).to.equal(0) |
366 | } | 366 | } |
367 | }) | 367 | }) |
@@ -369,7 +369,7 @@ describe('Test a single server', function () { | |||
369 | it('Should have the video updated', async function () { | 369 | it('Should have the video updated', async function () { |
370 | this.timeout(60000) | 370 | this.timeout(60000) |
371 | 371 | ||
372 | const video = await server.videosCommand.get({ id: videoId }) | 372 | const video = await server.videos.get({ id: videoId }) |
373 | 373 | ||
374 | await completeVideoCheck(server, video, updateCheckAttributes()) | 374 | await completeVideoCheck(server, video, updateCheckAttributes()) |
375 | }) | 375 | }) |
@@ -378,9 +378,9 @@ describe('Test a single server', function () { | |||
378 | const attributes = { | 378 | const attributes = { |
379 | tags: [ 'supertag', 'tag1', 'tag2' ] | 379 | tags: [ 'supertag', 'tag1', 'tag2' ] |
380 | } | 380 | } |
381 | await server.videosCommand.update({ id: videoId, attributes }) | 381 | await server.videos.update({ id: videoId, attributes }) |
382 | 382 | ||
383 | const video = await server.videosCommand.get({ id: videoId }) | 383 | const video = await server.videos.get({ id: videoId }) |
384 | 384 | ||
385 | await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)) | 385 | await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)) |
386 | }) | 386 | }) |
@@ -389,27 +389,27 @@ describe('Test a single server', function () { | |||
389 | const attributes = { | 389 | const attributes = { |
390 | description: 'hello everybody' | 390 | description: 'hello everybody' |
391 | } | 391 | } |
392 | await server.videosCommand.update({ id: videoId, attributes }) | 392 | await server.videos.update({ id: videoId, attributes }) |
393 | 393 | ||
394 | const video = await server.videosCommand.get({ id: videoId }) | 394 | const video = await server.videos.get({ id: videoId }) |
395 | 395 | ||
396 | const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) | 396 | const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) |
397 | await completeVideoCheck(server, video, expectedAttributes) | 397 | await completeVideoCheck(server, video, expectedAttributes) |
398 | }) | 398 | }) |
399 | 399 | ||
400 | it('Should like a video', async function () { | 400 | it('Should like a video', async function () { |
401 | await server.videosCommand.rate({ id: videoId, rating: 'like' }) | 401 | await server.videos.rate({ id: videoId, rating: 'like' }) |
402 | 402 | ||
403 | const video = await server.videosCommand.get({ id: videoId }) | 403 | const video = await server.videos.get({ id: videoId }) |
404 | 404 | ||
405 | expect(video.likes).to.equal(1) | 405 | expect(video.likes).to.equal(1) |
406 | expect(video.dislikes).to.equal(0) | 406 | expect(video.dislikes).to.equal(0) |
407 | }) | 407 | }) |
408 | 408 | ||
409 | it('Should dislike the same video', async function () { | 409 | it('Should dislike the same video', async function () { |
410 | await server.videosCommand.rate({ id: videoId, rating: 'dislike' }) | 410 | await server.videos.rate({ id: videoId, rating: 'dislike' }) |
411 | 411 | ||
412 | const video = await server.videosCommand.get({ id: videoId }) | 412 | const video = await server.videos.get({ id: videoId }) |
413 | 413 | ||
414 | expect(video.likes).to.equal(0) | 414 | expect(video.likes).to.equal(0) |
415 | expect(video.dislikes).to.equal(1) | 415 | expect(video.dislikes).to.equal(1) |
@@ -419,9 +419,9 @@ describe('Test a single server', function () { | |||
419 | { | 419 | { |
420 | const now = new Date() | 420 | const now = new Date() |
421 | const attributes = { originallyPublishedAt: now.toISOString() } | 421 | const attributes = { originallyPublishedAt: now.toISOString() } |
422 | await server.videosCommand.update({ id: videoId, attributes }) | 422 | await server.videos.update({ id: videoId, attributes }) |
423 | 423 | ||
424 | const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) | 424 | const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) |
425 | const names = data.map(v => v.name) | 425 | const names = data.map(v => v.name) |
426 | 426 | ||
427 | expect(names[0]).to.equal('my super video updated') | 427 | expect(names[0]).to.equal('my super video updated') |
@@ -435,9 +435,9 @@ describe('Test a single server', function () { | |||
435 | { | 435 | { |
436 | const now = new Date() | 436 | const now = new Date() |
437 | const attributes = { originallyPublishedAt: now.toISOString() } | 437 | const attributes = { originallyPublishedAt: now.toISOString() } |
438 | await server.videosCommand.update({ id: videoId2, attributes }) | 438 | await server.videos.update({ id: videoId2, attributes }) |
439 | 439 | ||
440 | const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) | 440 | const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) |
441 | const names = data.map(v => v.name) | 441 | const names = data.map(v => v.name) |
442 | 442 | ||
443 | expect(names[0]).to.equal('video_short1.webm name') | 443 | expect(names[0]).to.equal('video_short1.webm name') |