+ await servers[0].config.updateExistingSubConfig({ newConfig: config })
+
+ const attributes = {
+ name: 'bigger resolution video',
+ targetUrl: FIXTURE_URLS.youtube,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = videoImported.uuid
+
+ await waitJobs(servers)
+
+ // test resolution
+ const video = await servers[0].videos.get({ id: videoUUID })
+ expect(video.name).to.equal('bigger resolution video')
+
+ expect(video.files).to.have.lengthOf(2)
+ expect(video.files.find(f => f.resolution.id === 240)).to.exist
+ expect(video.files.find(f => f.resolution.id === 144)).to.exist
+ })
+
+ it('Should import a peertube video', async function () {
+ this.timeout(120_000)
+
+ const toTest = [ FIXTURE_URLS.peertube_long ]
+
+ // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged
+ if (mode === 'yt-dlp') {
+ toTest.push(FIXTURE_URLS.peertube_short)
+ }
+
+ for (const targetUrl of toTest) {
+ await servers[0].config.disableTranscoding()
+
+ const attributes = {
+ targetUrl,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = video.uuid
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const video = await server.videos.get({ id: videoUUID })
+
+ expect(video.name).to.equal('E2E tests')
+ }
+ }
+ })
+
+ after(async function () {
+ await cleanupTests(servers)
+ })
+ })
+ }
+
+ runSuite('youtube-dl')
+
+ runSuite('yt-dlp')
+
+ describe('Delete/cancel an import', function () {
+ let server: PeerTubeServer
+
+ let finishedImportId: number
+ let finishedVideo: Video
+ let pendingImportId: number
+
+ async function importVideo (name: string) {
+ const attributes = { name, channelId: server.store.channel.id, targetUrl: FIXTURE_URLS.goodVideo }
+ const res = await server.imports.importVideo({ attributes })
+
+ return res.id
+ }
+
+ before(async function () {
+ this.timeout(120_000)
+
+ server = await createSingleServer(1)
+
+ await setAccessTokensToServers([ server ])
+ await setDefaultVideoChannel([ server ])
+
+ finishedImportId = await importVideo('finished')
+ await waitJobs([ server ])
+
+ await server.jobs.pauseJobQueue()
+ pendingImportId = await importVideo('pending')
+
+ const { data } = await server.imports.getMyVideoImports()
+ expect(data).to.have.lengthOf(2)
+
+ finishedVideo = data.find(i => i.id === finishedImportId).video
+ })
+
+ it('Should delete a video import', async function () {
+ await server.imports.delete({ importId: finishedImportId })
+
+ const { data } = await server.imports.getMyVideoImports()
+ expect(data).to.have.lengthOf(1)
+ expect(data[0].id).to.equal(pendingImportId)
+ expect(data[0].state.id).to.equal(VideoImportState.PENDING)
+ })
+
+ it('Should not have deleted the associated video', async function () {
+ const video = await server.videos.get({ id: finishedVideo.id, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
+ expect(video.name).to.equal('finished')
+ expect(video.state.id).to.equal(VideoState.PUBLISHED)
+ })
+
+ it('Should cancel a video import', async function () {
+ await server.imports.cancel({ importId: pendingImportId })
+
+ const { data } = await server.imports.getMyVideoImports()
+ expect(data).to.have.lengthOf(1)
+ expect(data[0].id).to.equal(pendingImportId)
+ expect(data[0].state.id).to.equal(VideoImportState.CANCELLED)
+ })
+
+ it('Should not have processed the cancelled video import', async function () {
+ this.timeout(60_000)
+
+ await server.jobs.resumeJobQueue()
+
+ await waitJobs([ server ])
+
+ const { data } = await server.imports.getMyVideoImports()
+ expect(data).to.have.lengthOf(1)
+ expect(data[0].id).to.equal(pendingImportId)
+ expect(data[0].state.id).to.equal(VideoImportState.CANCELLED)
+ expect(data[0].video.state.id).to.equal(VideoState.TO_IMPORT)
+ })
+
+ it('Should delete the cancelled video import', async function () {
+ await server.imports.delete({ importId: pendingImportId })
+ const { data } = await server.imports.getMyVideoImports()
+ expect(data).to.have.lengthOf(0)
+ })
+
+ after(async function () {
+ await cleanupTests([ server ])
+ })
+ })
+
+ describe('Auto update', function () {
+ let server: PeerTubeServer
+
+ function quickPeerTubeImport () {
+ const attributes = {
+ targetUrl: FIXTURE_URLS.peertube_long,
+ channelId: server.store.channel.id,
+ privacy: VideoPrivacy.PUBLIC