aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-01-19 14:23:00 +0100
committerChocobozzz <me@florianbigard.com>2022-01-19 14:31:05 +0100
commit419b520ca4434d17f3505013174e195c3a316716 (patch)
tree24dbf663c4e11e970cb780f96e6eb3efe023b222 /server/tests/api/videos
parent52435e467a0b30175a10af1dd3ae10d7d564d8ae (diff)
downloadPeerTube-419b520ca4434d17f3505013174e195c3a316716.tar.gz
PeerTube-419b520ca4434d17f3505013174e195c3a316716.tar.zst
PeerTube-419b520ca4434d17f3505013174e195c3a316716.zip
Add ability to cancel & delete video imports
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-imports.ts81
1 files changed, 80 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index e8e0f01f1..ba21ab17a 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -6,7 +6,7 @@ import { pathExists, readdir, remove } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared' 7import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared'
8import { areHttpImportTestsDisabled } from '@shared/core-utils' 8import { areHttpImportTestsDisabled } from '@shared/core-utils'
9import { VideoPrivacy, VideoResolution } from '@shared/models' 9import { HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@shared/models'
10import { 10import {
11 cleanupTests, 11 cleanupTests,
12 createMultipleServers, 12 createMultipleServers,
@@ -382,6 +382,85 @@ describe('Test video imports', function () {
382 382
383 runSuite('yt-dlp') 383 runSuite('yt-dlp')
384 384
385 describe('Delete/cancel an import', function () {
386 let server: PeerTubeServer
387
388 let finishedImportId: number
389 let finishedVideo: Video
390 let pendingImportId: number
391
392 async function importVideo (name: string) {
393 const attributes = { name, channelId: server.store.channel.id, targetUrl: FIXTURE_URLS.goodVideo }
394 const res = await server.imports.importVideo({ attributes })
395
396 return res.id
397 }
398
399 before(async function () {
400 this.timeout(120_000)
401
402 server = await createSingleServer(1)
403
404 await setAccessTokensToServers([ server ])
405 await setDefaultVideoChannel([ server ])
406
407 finishedImportId = await importVideo('finished')
408 await waitJobs([ server ])
409
410 await server.jobs.pauseJobQueue()
411 pendingImportId = await importVideo('pending')
412
413 const { data } = await server.imports.getMyVideoImports()
414 expect(data).to.have.lengthOf(2)
415
416 finishedVideo = data.find(i => i.id === finishedImportId).video
417 })
418
419 it('Should delete a video import', async function () {
420 await server.imports.delete({ importId: finishedImportId })
421
422 const { data } = await server.imports.getMyVideoImports()
423 expect(data).to.have.lengthOf(1)
424 expect(data[0].id).to.equal(pendingImportId)
425 expect(data[0].state.id).to.equal(VideoImportState.PENDING)
426 })
427
428 it('Should not have deleted the associated video', async function () {
429 const video = await server.videos.get({ id: finishedVideo.id, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
430 expect(video.name).to.equal('finished')
431 expect(video.state.id).to.equal(VideoState.PUBLISHED)
432 })
433
434 it('Should cancel a video import', async function () {
435 await server.imports.cancel({ importId: pendingImportId })
436
437 const { data } = await server.imports.getMyVideoImports()
438 expect(data).to.have.lengthOf(1)
439 expect(data[0].id).to.equal(pendingImportId)
440 expect(data[0].state.id).to.equal(VideoImportState.CANCELLED)
441 })
442
443 it('Should not have processed the cancelled video import', async function () {
444 this.timeout(60_000)
445
446 await server.jobs.resumeJobQueue()
447
448 await waitJobs([ server ])
449
450 const { data } = await server.imports.getMyVideoImports()
451 expect(data).to.have.lengthOf(1)
452 expect(data[0].id).to.equal(pendingImportId)
453 expect(data[0].state.id).to.equal(VideoImportState.CANCELLED)
454 expect(data[0].video.state.id).to.equal(VideoState.TO_IMPORT)
455 })
456
457 it('Should delete the cancelled video import', async function () {
458 await server.imports.delete({ importId: pendingImportId })
459 const { data } = await server.imports.getMyVideoImports()
460 expect(data).to.have.lengthOf(0)
461 })
462 })
463
385 describe('Auto update', function () { 464 describe('Auto update', function () {
386 let server: PeerTubeServer 465 let server: PeerTubeServer
387 466