aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-29 15:09:38 +0200
committerChocobozzz <me@florianbigard.com>2019-05-29 15:09:38 +0200
commit91b6631984fa7097bd60aa013d1cf041d7b95f58 (patch)
tree717cc94c3cba7b02ba404f2536ebc76118adf504 /server/tests/api
parentb247a132709eb212fef4f77c4912dc0ec108f36b (diff)
downloadPeerTube-91b6631984fa7097bd60aa013d1cf041d7b95f58.tar.gz
PeerTube-91b6631984fa7097bd60aa013d1cf041d7b95f58.tar.zst
PeerTube-91b6631984fa7097bd60aa013d1cf041d7b95f58.zip
Add pagination to account video channels endpoint
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/video-channels.ts24
-rw-r--r--server/tests/api/videos/video-channels.ts64
2 files changed, 84 insertions, 4 deletions
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 65bc20613..ff04f6b03 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -67,8 +67,30 @@ describe('Test video channels API validator', function () {
67 }) 67 })
68 68
69 describe('When listing account video channels', function () { 69 describe('When listing account video channels', function () {
70 const accountChannelPath = '/api/v1/accounts/fake/video-channels'
71
72 it('Should fail with a bad start pagination', async function () {
73 await checkBadStartPagination(server.url, accountChannelPath, server.accessToken)
74 })
75
76 it('Should fail with a bad count pagination', async function () {
77 await checkBadCountPagination(server.url, accountChannelPath, server.accessToken)
78 })
79
80 it('Should fail with an incorrect sort', async function () {
81 await checkBadSortPagination(server.url, accountChannelPath, server.accessToken)
82 })
83
70 it('Should fail with a unknown account', async function () { 84 it('Should fail with a unknown account', async function () {
71 await getAccountVideoChannelsList(server.url, 'unknown', 404) 85 await getAccountVideoChannelsList({ url: server.url, accountName: 'unknown', specialStatus: 404 })
86 })
87
88 it('Should succeed with the correct parameters', async function () {
89 await makeGetRequest({
90 url: server.url,
91 path: accountChannelPath,
92 statusCodeExpected: 200
93 })
72 }) 94 })
73 }) 95 })
74 96
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 41fe3be5c..e98f14ea8 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { User, Video } from '../../../../shared/index' 5import { User, Video, VideoChannel } from '../../../../shared/index'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createUser, 8 createUser,
@@ -108,7 +108,11 @@ describe('Test video channels', function () {
108 }) 108 })
109 109
110 it('Should have two video channels when getting account channels on server 1', async function () { 110 it('Should have two video channels when getting account channels on server 1', async function () {
111 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host) 111 const res = await getAccountVideoChannelsList({
112 url: servers[ 0 ].url,
113 accountName: userInfo.account.name + '@' + userInfo.account.host
114 })
115
112 expect(res.body.total).to.equal(2) 116 expect(res.body.total).to.equal(2)
113 expect(res.body.data).to.be.an('array') 117 expect(res.body.data).to.be.an('array')
114 expect(res.body.data).to.have.lengthOf(2) 118 expect(res.body.data).to.have.lengthOf(2)
@@ -123,8 +127,62 @@ describe('Test video channels', function () {
123 expect(videoChannels[1].support).to.equal('super video channel support text') 127 expect(videoChannels[1].support).to.equal('super video channel support text')
124 }) 128 })
125 129
130 it('Should paginate and sort account channels', async function () {
131 {
132 const res = await getAccountVideoChannelsList({
133 url: servers[ 0 ].url,
134 accountName: userInfo.account.name + '@' + userInfo.account.host,
135 start: 0,
136 count: 1,
137 sort: 'createdAt'
138 })
139
140 expect(res.body.total).to.equal(2)
141 expect(res.body.data).to.have.lengthOf(1)
142
143 const videoChannel: VideoChannel = res.body.data[ 0 ]
144 expect(videoChannel.name).to.equal('root_channel')
145 }
146
147 {
148 const res = await getAccountVideoChannelsList({
149 url: servers[ 0 ].url,
150 accountName: userInfo.account.name + '@' + userInfo.account.host,
151 start: 0,
152 count: 1,
153 sort: '-createdAt'
154 })
155
156 expect(res.body.total).to.equal(2)
157 expect(res.body.data).to.have.lengthOf(1)
158
159 const videoChannel: VideoChannel = res.body.data[ 0 ]
160 expect(videoChannel.name).to.equal('second_video_channel')
161 }
162
163 {
164 const res = await getAccountVideoChannelsList({
165 url: servers[ 0 ].url,
166 accountName: userInfo.account.name + '@' + userInfo.account.host,
167 start: 1,
168 count: 1,
169 sort: '-createdAt'
170 })
171
172 expect(res.body.total).to.equal(2)
173 expect(res.body.data).to.have.lengthOf(1)
174
175 const videoChannel: VideoChannel = res.body.data[ 0 ]
176 expect(videoChannel.name).to.equal('root_channel')
177 }
178 })
179
126 it('Should have one video channel when getting account channels on server 2', async function () { 180 it('Should have one video channel when getting account channels on server 2', async function () {
127 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host) 181 const res = await getAccountVideoChannelsList({
182 url: servers[ 1 ].url,
183 accountName: userInfo.account.name + '@' + userInfo.account.host
184 })
185
128 expect(res.body.total).to.equal(1) 186 expect(res.body.total).to.equal(1)
129 expect(res.body.data).to.be.an('array') 187 expect(res.body.data).to.be.an('array')
130 expect(res.body.data).to.have.lengthOf(1) 188 expect(res.body.data).to.have.lengthOf(1)