aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-files.ts
blob: fcb2ca2e4d9326c45ec50339d97cf31b5336e8e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import 'mocha'
import { expect } from 'chai'
import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'

describe('Test videos files', function () {
  let servers: PeerTubeServer[]
  let validId1: string
  let validId2: string

  // ---------------------------------------------------------------

  before(async function () {
    this.timeout(150_000)

    servers = await createMultipleServers(2)
    await setAccessTokensToServers(servers)

    await doubleFollow(servers[0], servers[1])

    await servers[0].config.enableTranscoding(true, true)

    {
      const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' })
      validId1 = uuid
    }

    {
      const { uuid } = await servers[0].videos.quickUpload({ name: 'video 2' })
      validId2 = uuid
    }

    await waitJobs(servers)
  })

  it('Should delete webtorrent files', async function () {
    this.timeout(30_000)

    await servers[0].videos.removeWebTorrentFiles({ videoId: validId1 })

    await waitJobs(servers)

    for (const server of servers) {
      const video = await server.videos.get({ id: validId1 })

      expect(video.files).to.have.lengthOf(0)
      expect(video.streamingPlaylists).to.have.lengthOf(1)
    }
  })

  it('Should delete HLS files', async function () {
    this.timeout(30_000)

    await servers[0].videos.removeHLSFiles({ videoId: validId2 })

    await waitJobs(servers)

    for (const server of servers) {
      const video = await server.videos.get({ id: validId2 })

      expect(video.files).to.have.length.above(0)
      expect(video.streamingPlaylists).to.have.lengthOf(0)
    }
  })

  after(async function () {
    await cleanupTests(servers)
  })
})