aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-20 09:05:43 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 09:25:44 +0200
commit978c87e7f58b6673fe60f04f1767bc9e02ea4936 (patch)
treee7d48735d4099fec8c7732f33e7dadb09c0eac80 /server/tests/api
parent7e76cc380040e40a2292a9dc825f037c9b538030 (diff)
downloadPeerTube-978c87e7f58b6673fe60f04f1767bc9e02ea4936.tar.gz
PeerTube-978c87e7f58b6673fe60f04f1767bc9e02ea4936.tar.zst
PeerTube-978c87e7f58b6673fe60f04f1767bc9e02ea4936.zip
Add channel filters for my videos/followers
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/videos.ts14
-rw-r--r--server/tests/api/users/users.ts25
2 files changed, 39 insertions, 0 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index e11ca0c82..d02b6e156 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -119,6 +119,20 @@ describe('Test videos API validator', function () {
119 await checkBadSortPagination(server.url, path, server.accessToken) 119 await checkBadSortPagination(server.url, path, server.accessToken)
120 }) 120 })
121 121
122 it('Should fail with an invalid channel', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, query: { channelId: 'toto' } })
124 })
125
126 it('Should fail with an unknown channel', async function () {
127 await makeGetRequest({
128 url: server.url,
129 token: server.accessToken,
130 path,
131 query: { channelId: 89898 },
132 expectedStatus: HttpStatusCode.NOT_FOUND_404
133 })
134 })
135
122 it('Should success with the correct parameters', async function () { 136 it('Should success with the correct parameters', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 }) 137 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
124 }) 138 })
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 085d9d870..6c41e7d56 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -318,6 +318,8 @@ describe('Test users', function () {
318 fixture: 'video_short.webm' 318 fixture: 'video_short.webm'
319 } 319 }
320 await server.videos.upload({ token: userToken, attributes }) 320 await server.videos.upload({ token: userToken, attributes })
321
322 await server.channels.create({ token: userToken, attributes: { name: 'other_channel' } })
321 }) 323 })
322 324
323 it('Should have video quota updated', async function () { 325 it('Should have video quota updated', async function () {
@@ -340,6 +342,29 @@ describe('Test users', function () {
340 expect(video.previewPath).to.not.be.null 342 expect(video.previewPath).to.not.be.null
341 }) 343 })
342 344
345 it('Should be able to filter by channel in my videos', async function () {
346 const myInfo = await server.users.getMyInfo({ token: userToken })
347 const mainChannel = myInfo.videoChannels.find(c => c.name !== 'other_channel')
348 const otherChannel = myInfo.videoChannels.find(c => c.name === 'other_channel')
349
350 {
351 const { total, data } = await server.videos.listMyVideos({ token: userToken, channelId: mainChannel.id })
352 expect(total).to.equal(1)
353 expect(data).to.have.lengthOf(1)
354
355 const video: Video = data[0]
356 expect(video.name).to.equal('super user video')
357 expect(video.thumbnailPath).to.not.be.null
358 expect(video.previewPath).to.not.be.null
359 }
360
361 {
362 const { total, data } = await server.videos.listMyVideos({ token: userToken, channelId: otherChannel.id })
363 expect(total).to.equal(0)
364 expect(data).to.have.lengthOf(0)
365 }
366 })
367
343 it('Should be able to search in my videos', async function () { 368 it('Should be able to search in my videos', async function () {
344 { 369 {
345 const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' }) 370 const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })