aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
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