diff options
Diffstat (limited to 'server/tests/api/videos/channel-import-videos.ts')
-rw-r--r-- | server/tests/api/videos/channel-import-videos.ts | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/server/tests/api/videos/channel-import-videos.ts b/server/tests/api/videos/channel-import-videos.ts deleted file mode 100644 index a66f88a0e..000000000 --- a/server/tests/api/videos/channel-import-videos.ts +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { FIXTURE_URLS } from '@server/tests/shared' | ||
5 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | ||
6 | import { | ||
7 | createSingleServer, | ||
8 | getServerImportConfig, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | setDefaultVideoChannel, | ||
12 | waitJobs | ||
13 | } from '@shared/server-commands' | ||
14 | |||
15 | describe('Test videos import in a channel', function () { | ||
16 | if (areHttpImportTestsDisabled()) return | ||
17 | |||
18 | function runSuite (mode: 'youtube-dl' | 'yt-dlp') { | ||
19 | |||
20 | describe('Import using ' + mode, function () { | ||
21 | let server: PeerTubeServer | ||
22 | |||
23 | before(async function () { | ||
24 | this.timeout(120_000) | ||
25 | |||
26 | server = await createSingleServer(1, getServerImportConfig(mode)) | ||
27 | |||
28 | await setAccessTokensToServers([ server ]) | ||
29 | await setDefaultVideoChannel([ server ]) | ||
30 | |||
31 | await server.config.enableChannelSync() | ||
32 | }) | ||
33 | |||
34 | it('Should import a whole channel without specifying the sync id', async function () { | ||
35 | this.timeout(240_000) | ||
36 | |||
37 | await server.channels.importVideos({ channelName: server.store.channel.name, externalChannelUrl: FIXTURE_URLS.youtubeChannel }) | ||
38 | await waitJobs(server) | ||
39 | |||
40 | const videos = await server.videos.listByChannel({ handle: server.store.channel.name }) | ||
41 | expect(videos.total).to.equal(2) | ||
42 | }) | ||
43 | |||
44 | it('These imports should not have a sync id', async function () { | ||
45 | const { total, data } = await server.imports.getMyVideoImports() | ||
46 | |||
47 | expect(total).to.equal(2) | ||
48 | expect(data).to.have.lengthOf(2) | ||
49 | |||
50 | for (const videoImport of data) { | ||
51 | expect(videoImport.videoChannelSync).to.not.exist | ||
52 | } | ||
53 | }) | ||
54 | |||
55 | it('Should import a whole channel and specifying the sync id', async function () { | ||
56 | this.timeout(240_000) | ||
57 | |||
58 | { | ||
59 | server.store.channel.name = 'channel2' | ||
60 | const { id } = await server.channels.create({ attributes: { name: server.store.channel.name } }) | ||
61 | server.store.channel.id = id | ||
62 | } | ||
63 | |||
64 | { | ||
65 | const attributes = { | ||
66 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, | ||
67 | videoChannelId: server.store.channel.id | ||
68 | } | ||
69 | |||
70 | const { videoChannelSync } = await server.channelSyncs.create({ attributes }) | ||
71 | server.store.videoChannelSync = videoChannelSync | ||
72 | |||
73 | await waitJobs(server) | ||
74 | } | ||
75 | |||
76 | await server.channels.importVideos({ | ||
77 | channelName: server.store.channel.name, | ||
78 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, | ||
79 | videoChannelSyncId: server.store.videoChannelSync.id | ||
80 | }) | ||
81 | |||
82 | await waitJobs(server) | ||
83 | }) | ||
84 | |||
85 | it('These imports should have a sync id', async function () { | ||
86 | const { total, data } = await server.imports.getMyVideoImports() | ||
87 | |||
88 | expect(total).to.equal(4) | ||
89 | expect(data).to.have.lengthOf(4) | ||
90 | |||
91 | const importsWithSyncId = data.filter(i => !!i.videoChannelSync) | ||
92 | expect(importsWithSyncId).to.have.lengthOf(2) | ||
93 | |||
94 | for (const videoImport of importsWithSyncId) { | ||
95 | expect(videoImport.videoChannelSync).to.exist | ||
96 | expect(videoImport.videoChannelSync.id).to.equal(server.store.videoChannelSync.id) | ||
97 | } | ||
98 | }) | ||
99 | |||
100 | it('Should be able to filter imports by this sync id', async function () { | ||
101 | const { total, data } = await server.imports.getMyVideoImports({ videoChannelSyncId: server.store.videoChannelSync.id }) | ||
102 | |||
103 | expect(total).to.equal(2) | ||
104 | expect(data).to.have.lengthOf(2) | ||
105 | |||
106 | for (const videoImport of data) { | ||
107 | expect(videoImport.videoChannelSync).to.exist | ||
108 | expect(videoImport.videoChannelSync.id).to.equal(server.store.videoChannelSync.id) | ||
109 | } | ||
110 | }) | ||
111 | |||
112 | it('Should limit max amount of videos synced on full sync', async function () { | ||
113 | this.timeout(240_000) | ||
114 | |||
115 | await server.kill() | ||
116 | await server.run({ | ||
117 | import: { | ||
118 | video_channel_synchronization: { | ||
119 | full_sync_videos_limit: 1 | ||
120 | } | ||
121 | } | ||
122 | }) | ||
123 | |||
124 | const { id } = await server.channels.create({ attributes: { name: 'channel3' } }) | ||
125 | const channel3Id = id | ||
126 | |||
127 | const { videoChannelSync } = await server.channelSyncs.create({ | ||
128 | attributes: { | ||
129 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, | ||
130 | videoChannelId: channel3Id | ||
131 | } | ||
132 | }) | ||
133 | const syncId = videoChannelSync.id | ||
134 | |||
135 | await waitJobs(server) | ||
136 | |||
137 | await server.channels.importVideos({ | ||
138 | channelName: 'channel3', | ||
139 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, | ||
140 | videoChannelSyncId: syncId | ||
141 | }) | ||
142 | |||
143 | await waitJobs(server) | ||
144 | |||
145 | const { total, data } = await server.videos.listByChannel({ handle: 'channel3' }) | ||
146 | |||
147 | expect(total).to.equal(1) | ||
148 | expect(data).to.have.lengthOf(1) | ||
149 | }) | ||
150 | |||
151 | after(async function () { | ||
152 | await server?.kill() | ||
153 | }) | ||
154 | }) | ||
155 | } | ||
156 | |||
157 | runSuite('yt-dlp') | ||
158 | |||
159 | // FIXME: With recent changes on youtube, youtube-dl doesn't fetch live replays which means the test suite fails | ||
160 | // runSuite('youtube-dl') | ||
161 | }) | ||