diff options
author | Chocobozzz <me@florianbigard.com> | 2022-09-19 15:47:57 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-09-19 16:02:02 +0200 |
commit | 065684b2fe0db63736afc6fac6f9dad50bcac87d (patch) | |
tree | f0b8a9aa4c80a1e358674cfd5afe89f5898e0188 /server/tests/api/videos | |
parent | d342d752b363d7bf0e4bb0682452081655943e02 (diff) | |
download | PeerTube-065684b2fe0db63736afc6fac6f9dad50bcac87d.tar.gz PeerTube-065684b2fe0db63736afc6fac6f9dad50bcac87d.tar.zst PeerTube-065684b2fe0db63736afc6fac6f9dad50bcac87d.zip |
Add sync youtube playlist test
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-channel-syncs.ts | 95 |
1 files changed, 56 insertions, 39 deletions
diff --git a/server/tests/api/videos/video-channel-syncs.ts b/server/tests/api/videos/video-channel-syncs.ts index 5c0663311..865b25f04 100644 --- a/server/tests/api/videos/video-channel-syncs.ts +++ b/server/tests/api/videos/video-channel-syncs.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { FIXTURE_URLS } from '@server/tests/shared' | 4 | import { FIXTURE_URLS } from '@server/tests/shared' |
5 | import { areHttpImportTestsDisabled } from '@shared/core-utils' | 5 | import { areHttpImportTestsDisabled } from '@shared/core-utils' |
6 | import { HttpStatusCode, VideoChannelSyncState, VideoInclude, VideoPrivacy } from '@shared/models' | 6 | import { VideoChannelSyncState, VideoInclude, VideoPrivacy } from '@shared/models' |
7 | import { | 7 | import { |
8 | createMultipleServers, | 8 | createMultipleServers, |
9 | getServerImportConfig, | 9 | getServerImportConfig, |
@@ -43,6 +43,25 @@ describe('Test channel synchronizations', function () { | |||
43 | ) | 43 | ) |
44 | } | 44 | } |
45 | 45 | ||
46 | async function listAllVideosOfChannel (channelName: string) { | ||
47 | return servers[0].videos.listByChannel({ | ||
48 | handle: channelName, | ||
49 | include: VideoInclude.NOT_PUBLISHED_STATE | ||
50 | }) | ||
51 | } | ||
52 | |||
53 | async function forceSyncAll (videoChannelSyncId: number, fromDate = '1970-01-01') { | ||
54 | await changeDateForSync(videoChannelSyncId, fromDate) | ||
55 | |||
56 | await servers[0].debug.sendCommand({ | ||
57 | body: { | ||
58 | command: 'process-video-channel-sync-latest' | ||
59 | } | ||
60 | }) | ||
61 | |||
62 | await waitJobs(servers) | ||
63 | } | ||
64 | |||
46 | before(async function () { | 65 | before(async function () { |
47 | this.timeout(240_000) | 66 | this.timeout(240_000) |
48 | 67 | ||
@@ -80,7 +99,7 @@ describe('Test channel synchronizations', function () { | |||
80 | expect(video.name).to.equal('small video - youtube') | 99 | expect(video.name).to.equal('small video - youtube') |
81 | expect(video.waitTranscoding).to.be.true | 100 | expect(video.waitTranscoding).to.be.true |
82 | 101 | ||
83 | const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', include: VideoInclude.NOT_PUBLISHED_STATE }) | 102 | const { total } = await listAllVideosOfChannel('root_channel') |
84 | expect(total).to.equal(1) | 103 | expect(total).to.equal(1) |
85 | } | 104 | } |
86 | 105 | ||
@@ -88,28 +107,14 @@ describe('Test channel synchronizations', function () { | |||
88 | attributes: { | 107 | attributes: { |
89 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, | 108 | externalChannelUrl: FIXTURE_URLS.youtubeChannel, |
90 | videoChannelId: servers[0].store.channel.id | 109 | videoChannelId: servers[0].store.channel.id |
91 | }, | 110 | } |
92 | token: servers[0].accessToken, | ||
93 | expectedStatus: HttpStatusCode.OK_200 | ||
94 | }) | 111 | }) |
95 | rootChannelSyncId = videoChannelSync.id | 112 | rootChannelSyncId = videoChannelSync.id |
96 | 113 | ||
97 | // Ensure any missing video not already fetched will be considered as new | 114 | await forceSyncAll(rootChannelSyncId) |
98 | await changeDateForSync(videoChannelSync.id, '1970-01-01') | ||
99 | |||
100 | await servers[0].debug.sendCommand({ | ||
101 | body: { | ||
102 | command: 'process-video-channel-sync-latest' | ||
103 | } | ||
104 | }) | ||
105 | 115 | ||
106 | { | 116 | { |
107 | await waitJobs(servers) | 117 | const { total, data } = await listAllVideosOfChannel('root_channel') |
108 | |||
109 | const { total, data } = await servers[0].videos.listByChannel({ | ||
110 | handle: 'root_channel', | ||
111 | include: VideoInclude.NOT_PUBLISHED_STATE | ||
112 | }) | ||
113 | expect(total).to.equal(2) | 118 | expect(total).to.equal(2) |
114 | expect(data[0].name).to.equal('test') | 119 | expect(data[0].name).to.equal('test') |
115 | expect(data[0].waitTranscoding).to.be.true | 120 | expect(data[0].waitTranscoding).to.be.true |
@@ -123,16 +128,12 @@ describe('Test channel synchronizations', function () { | |||
123 | attributes: { | 128 | attributes: { |
124 | externalChannelUrl, | 129 | externalChannelUrl, |
125 | videoChannelId: servers[0].store.channel.id | 130 | videoChannelId: servers[0].store.channel.id |
126 | }, | 131 | } |
127 | token: servers[0].accessToken, | ||
128 | expectedStatus: HttpStatusCode.OK_200 | ||
129 | }) | 132 | }) |
130 | 133 | ||
131 | expect(videoChannelSync.externalChannelUrl).to.equal(externalChannelUrl) | 134 | expect(videoChannelSync.externalChannelUrl).to.equal(externalChannelUrl) |
132 | expect(videoChannelSync.channel).to.include({ | 135 | expect(videoChannelSync.channel.id).to.equal(servers[0].store.channel.id) |
133 | id: servers[0].store.channel.id, | 136 | expect(videoChannelSync.channel.name).to.equal('root_channel') |
134 | name: 'root_channel' | ||
135 | }) | ||
136 | expect(videoChannelSync.state.id).to.equal(VideoChannelSyncState.WAITING_FIRST_RUN) | 137 | expect(videoChannelSync.state.id).to.equal(VideoChannelSyncState.WAITING_FIRST_RUN) |
137 | expect(new Date(videoChannelSync.createdAt)).to.be.above(startTestDate).and.to.be.at.most(new Date()) | 138 | expect(new Date(videoChannelSync.createdAt)).to.be.above(startTestDate).and.to.be.at.most(new Date()) |
138 | }) | 139 | }) |
@@ -162,20 +163,9 @@ describe('Test channel synchronizations', function () { | |||
162 | it('Should only fetch the videos newer than the creation date', async function () { | 163 | it('Should only fetch the videos newer than the creation date', async function () { |
163 | this.timeout(120_000) | 164 | this.timeout(120_000) |
164 | 165 | ||
165 | await changeDateForSync(userInfo.syncId, '2019-03-01') | 166 | await forceSyncAll(userInfo.syncId, '2019-03-01') |
166 | 167 | ||
167 | await servers[0].debug.sendCommand({ | 168 | const { data, total } = await listAllVideosOfChannel(userInfo.channelName) |
168 | body: { | ||
169 | command: 'process-video-channel-sync-latest' | ||
170 | } | ||
171 | }) | ||
172 | |||
173 | await waitJobs(servers) | ||
174 | |||
175 | const { data, total } = await servers[0].videos.listByChannel({ | ||
176 | handle: userInfo.channelName, | ||
177 | include: VideoInclude.NOT_PUBLISHED_STATE | ||
178 | }) | ||
179 | 169 | ||
180 | expect(total).to.equal(1) | 170 | expect(total).to.equal(1) |
181 | expect(data[0].name).to.equal('test') | 171 | expect(data[0].name).to.equal('test') |
@@ -284,6 +274,33 @@ describe('Test channel synchronizations', function () { | |||
284 | // expect(data[0].name).to.equal('remote 2') | 274 | // expect(data[0].name).to.equal('remote 2') |
285 | // }) | 275 | // }) |
286 | 276 | ||
277 | it('Should fetch the latest videos of a youtube playlist', async function () { | ||
278 | this.timeout(120_000) | ||
279 | |||
280 | const { id: channelId } = await servers[0].channels.create({ | ||
281 | attributes: { | ||
282 | name: 'channel2' | ||
283 | } | ||
284 | }) | ||
285 | |||
286 | const { videoChannelSync: { id: videoChannelSyncId } } = await servers[0].channelSyncs.create({ | ||
287 | attributes: { | ||
288 | externalChannelUrl: FIXTURE_URLS.youtubePlaylist, | ||
289 | videoChannelId: channelId | ||
290 | } | ||
291 | }) | ||
292 | |||
293 | await forceSyncAll(videoChannelSyncId) | ||
294 | |||
295 | { | ||
296 | |||
297 | const { total, data } = await listAllVideosOfChannel('channel2') | ||
298 | expect(total).to.equal(2) | ||
299 | expect(data[0].name).to.equal('test') | ||
300 | expect(data[1].name).to.equal('small video - youtube') | ||
301 | } | ||
302 | }) | ||
303 | |||
287 | after(async function () { | 304 | after(async function () { |
288 | await killallServers(servers) | 305 | await killallServers(servers) |
289 | }) | 306 | }) |