aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/users.ts32
-rw-r--r--server/tests/api/users/users.ts32
2 files changed, 46 insertions, 18 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 13be8b460..f3ee99e85 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -538,6 +538,38 @@ describe('Test users API validators', function () {
538 }) 538 })
539 }) 539 })
540 540
541 describe('When retrieving my global ratings', function () {
542 const path = '/api/v1/accounts/user1/ratings'
543
544 it('Should fail with a bad start pagination', async function () {
545 await checkBadStartPagination(server.url, path, userAccessToken)
546 })
547
548 it('Should fail with a bad count pagination', async function () {
549 await checkBadCountPagination(server.url, path, userAccessToken)
550 })
551
552 it('Should fail with an incorrect sort', async function () {
553 await checkBadSortPagination(server.url, path, userAccessToken)
554 })
555
556 it('Should fail with a unauthenticated user', async function () {
557 await makeGetRequest({ url: server.url, path, statusCodeExpected: 401 })
558 })
559
560 it('Should fail with a another user', async function () {
561 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 403 })
562 })
563
564 it('Should fail with a bad type', async function () {
565 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { rating: 'toto ' }, statusCodeExpected: 400 })
566 })
567
568 it('Should succeed with the correct params', async function () {
569 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 200 })
570 })
571 })
572
541 describe('When blocking/unblocking/removing user', function () { 573 describe('When blocking/unblocking/removing user', function () {
542 it('Should fail with an incorrect id', async function () { 574 it('Should fail with an incorrect id', async function () {
543 await removeUser(server.url, 'blabla', server.accessToken, 400) 575 await removeUser(server.url, 'blabla', server.accessToken, 400)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index bc069a7be..6e7de9c38 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -140,31 +140,27 @@ describe('Test users', function () {
140 140
141 it('Should retrieve ratings list', async function () { 141 it('Should retrieve ratings list', async function () {
142 await rateVideo(server.url, accessToken, videoId, 'like') 142 await rateVideo(server.url, accessToken, videoId, 'like')
143 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200) 143
144 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, 200)
144 const ratings = res.body 145 const ratings = res.body
145 146
147 expect(ratings.total).to.equal(1)
146 expect(ratings.data[0].video.id).to.equal(videoId) 148 expect(ratings.data[0].video.id).to.equal(videoId)
147 expect(ratings.data[0].rating).to.equal('like') 149 expect(ratings.data[0].rating).to.equal('like')
148 }) 150 })
149 151
150 it('Should retrieve ratings list by rating type', async function () { 152 it('Should retrieve ratings list by rating type', async function () {
151 await rateVideo(server.url, accessToken, videoId, 'like') 153 {
152 let res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'like' }) 154 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like')
153 let ratings = res.body 155 const ratings = res.body
154 expect(ratings.data.length).to.equal(1) 156 expect(ratings.data.length).to.equal(1)
155 res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'dislike' }) 157 }
156 ratings = res.body 158
157 expect(ratings.data.length).to.equal(0) 159 {
158 await getAccountRatings(server.url, server.user.username, server.accessToken, 400, { rating: 'invalid' }) 160 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike')
159 }) 161 const ratings = res.body
160 162 expect(ratings.data.length).to.equal(0)
161 it('Should not access ratings list if not logged with correct user', async function () { 163 }
162 const user = { username: 'anuragh', password: 'passbyme' }
163 const resUser = await createUser(server.url, server.accessToken, user.username, user.password)
164 const userId = resUser.body.user.id
165 const userAccessToken = await userLogin(server, user)
166 await getAccountRatings(server.url, server.user.username, userAccessToken, 403)
167 await removeUser(server.url, userId, server.accessToken)
168 }) 164 })
169 165
170 it('Should not be able to remove the video with an incorrect token', async function () { 166 it('Should not be able to remove the video with an incorrect token', async function () {