diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-10 11:51:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-10 14:32:00 +0200 |
commit | a3b472a12ec6e57dbe2f650419f8064864686eab (patch) | |
tree | f36559488e34493c029b686772e986902150a647 /server/tests/api/videos | |
parent | 0567049a9819d67070aa6d548a75a7e632a4aaa4 (diff) | |
download | PeerTube-a3b472a12ec6e57dbe2f650419f8064864686eab.tar.gz PeerTube-a3b472a12ec6e57dbe2f650419f8064864686eab.tar.zst PeerTube-a3b472a12ec6e57dbe2f650419f8064864686eab.zip |
Add ability to list imports of a channel sync
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/channel-import-videos.ts | 72 | ||||
-rw-r--r-- | server/tests/api/videos/video-channel-syncs.ts | 12 | ||||
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 9 |
3 files changed, 92 insertions, 1 deletions
diff --git a/server/tests/api/videos/channel-import-videos.ts b/server/tests/api/videos/channel-import-videos.ts index f7540e1ba..7cfd02fbb 100644 --- a/server/tests/api/videos/channel-import-videos.ts +++ b/server/tests/api/videos/channel-import-videos.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
1 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
2 | import { FIXTURE_URLS } from '@server/tests/shared' | 4 | import { FIXTURE_URLS } from '@server/tests/shared' |
3 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | 5 | import { areHttpImportTestsDisabled } from '@shared/core-utils' |
@@ -29,7 +31,7 @@ describe('Test videos import in a channel', function () { | |||
29 | await server.config.enableChannelSync() | 31 | await server.config.enableChannelSync() |
30 | }) | 32 | }) |
31 | 33 | ||
32 | it('Should import a whole channel', async function () { | 34 | it('Should import a whole channel without specifying the sync id', async function () { |
33 | this.timeout(240_000) | 35 | this.timeout(240_000) |
34 | 36 | ||
35 | await server.channels.importVideos({ channelName: server.store.channel.name, externalChannelUrl: FIXTURE_URLS.youtubeChannel }) | 37 | await server.channels.importVideos({ channelName: server.store.channel.name, externalChannelUrl: FIXTURE_URLS.youtubeChannel }) |
@@ -39,6 +41,74 @@ describe('Test videos import in a channel', function () { | |||
39 | expect(videos.total).to.equal(2) | 41 | expect(videos.total).to.equal(2) |
40 | }) | 42 | }) |
41 | 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 | |||
42 | after(async function () { | 112 | after(async function () { |
43 | await server?.kill() | 113 | await server?.kill() |
44 | }) | 114 | }) |
diff --git a/server/tests/api/videos/video-channel-syncs.ts b/server/tests/api/videos/video-channel-syncs.ts index 229c01f68..835d3cb09 100644 --- a/server/tests/api/videos/video-channel-syncs.ts +++ b/server/tests/api/videos/video-channel-syncs.ts | |||
@@ -23,7 +23,10 @@ describe('Test channel synchronizations', function () { | |||
23 | describe('Sync using ' + mode, function () { | 23 | describe('Sync using ' + mode, function () { |
24 | let server: PeerTubeServer | 24 | let server: PeerTubeServer |
25 | let command: ChannelSyncsCommand | 25 | let command: ChannelSyncsCommand |
26 | |||
26 | let startTestDate: Date | 27 | let startTestDate: Date |
28 | |||
29 | let rootChannelSyncId: number | ||
27 | const userInfo = { | 30 | const userInfo = { |
28 | accessToken: '', | 31 | accessToken: '', |
29 | username: 'user1', | 32 | username: 'user1', |
@@ -90,6 +93,7 @@ describe('Test channel synchronizations', function () { | |||
90 | token: server.accessToken, | 93 | token: server.accessToken, |
91 | expectedStatus: HttpStatusCode.OK_200 | 94 | expectedStatus: HttpStatusCode.OK_200 |
92 | }) | 95 | }) |
96 | rootChannelSyncId = videoChannelSync.id | ||
93 | 97 | ||
94 | // Ensure any missing video not already fetched will be considered as new | 98 | // Ensure any missing video not already fetched will be considered as new |
95 | await changeDateForSync(videoChannelSync.id, '1970-01-01') | 99 | await changeDateForSync(videoChannelSync.id, '1970-01-01') |
@@ -208,6 +212,14 @@ describe('Test channel synchronizations', function () { | |||
208 | } | 212 | } |
209 | }) | 213 | }) |
210 | 214 | ||
215 | it('Should list imports of a channel synchronization', async function () { | ||
216 | const { total, data } = await server.imports.getMyVideoImports({ videoChannelSyncId: rootChannelSyncId }) | ||
217 | |||
218 | expect(total).to.equal(1) | ||
219 | expect(data).to.have.lengthOf(1) | ||
220 | expect(data[0].video.name).to.equal('test') | ||
221 | }) | ||
222 | |||
211 | it('Should remove user\'s channel synchronizations', async function () { | 223 | it('Should remove user\'s channel synchronizations', async function () { |
212 | await command.delete({ channelSyncId: userInfo.syncId }) | 224 | await command.delete({ channelSyncId: userInfo.syncId }) |
213 | 225 | ||
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index a487062a2..f082d4bd7 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -228,6 +228,15 @@ describe('Test video imports', function () { | |||
228 | expect(videoImports[0].targetUrl).to.equal(FIXTURE_URLS.youtube) | 228 | expect(videoImports[0].targetUrl).to.equal(FIXTURE_URLS.youtube) |
229 | }) | 229 | }) |
230 | 230 | ||
231 | it('Should search in my imports', async function () { | ||
232 | const { total, data: videoImports } = await servers[0].imports.getMyVideoImports({ search: 'peertube2' }) | ||
233 | expect(total).to.equal(1) | ||
234 | expect(videoImports).to.have.lengthOf(1) | ||
235 | |||
236 | expect(videoImports[0].magnetUri).to.equal(FIXTURE_URLS.magnet) | ||
237 | expect(videoImports[0].video.name).to.equal('super peertube2 video') | ||
238 | }) | ||
239 | |||
231 | it('Should have the video listed on the two instances', async function () { | 240 | it('Should have the video listed on the two instances', async function () { |
232 | this.timeout(120_000) | 241 | this.timeout(120_000) |
233 | 242 | ||