aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/channel-import-videos.ts
blob: f7540e1ba1d25902aca1cb63e8d3f2da08add5ed (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
import { expect } from 'chai'
import { FIXTURE_URLS } from '@server/tests/shared'
import { areHttpImportTestsDisabled } from '@shared/core-utils'
import {
  createSingleServer,
  getServerImportConfig,
  PeerTubeServer,
  setAccessTokensToServers,
  setDefaultVideoChannel,
  waitJobs
} from '@shared/server-commands'

describe('Test videos import in a channel', function () {
  if (areHttpImportTestsDisabled()) return

  function runSuite (mode: 'youtube-dl' | 'yt-dlp') {

    describe('Import using ' + mode, function () {
      let server: PeerTubeServer

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

        server = await createSingleServer(1, getServerImportConfig(mode))

        await setAccessTokensToServers([ server ])
        await setDefaultVideoChannel([ server ])

        await server.config.enableChannelSync()
      })

      it('Should import a whole channel', async function () {
        this.timeout(240_000)

        await server.channels.importVideos({ channelName: server.store.channel.name, externalChannelUrl: FIXTURE_URLS.youtubeChannel })
        await waitJobs(server)

        const videos = await server.videos.listByChannel({ handle: server.store.channel.name })
        expect(videos.total).to.equal(2)
      })

      after(async function () {
        await server?.kill()
      })
    })
  }

  runSuite('yt-dlp')
  runSuite('youtube-dl')
})