aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/users.ts22
-rw-r--r--server/tests/api/fixtures/avatar.pngbin0 -> 1674 bytes
-rw-r--r--server/tests/api/users/users.ts18
3 files changed, 38 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 0c126dbff..44412ad82 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,11 +2,13 @@
2 2
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import 'mocha' 4import 'mocha'
5import { join } from "path"
5import { UserRole } from '../../../../shared' 6import { UserRole } from '../../../../shared'
6 7
7import { 8import {
8 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, 9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
9 makePostBodyRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers, updateUser, 10 makePostBodyRequest, makePostUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
11 updateUser,
10 uploadVideo, userLogin 12 uploadVideo, userLogin
11} from '../../utils' 13} from '../../utils'
12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 14import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
@@ -266,6 +268,24 @@ describe('Test users API validators', function () {
266 }) 268 })
267 }) 269 })
268 270
271 describe('When updating my avatar', function () {
272 it('Should fail without an incorrect input file', async function () {
273 const fields = {}
274 const attaches = {
275 'avatarfile': join(__dirname, '..', 'fixtures', 'video_short.mp4')
276 }
277 await makePostUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
278 })
279
280 it('Should succeed with the correct params', async function () {
281 const fields = {}
282 const attaches = {
283 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar.png')
284 }
285 await makePostUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
286 })
287 })
288
269 describe('When updating a user', function () { 289 describe('When updating a user', function () {
270 290
271 before(async function () { 291 before(async function () {
diff --git a/server/tests/api/fixtures/avatar.png b/server/tests/api/fixtures/avatar.png
new file mode 100644
index 000000000..4b7fd2c0a
--- /dev/null
+++ b/server/tests/api/fixtures/avatar.png
Binary files differ
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 19549acdd..3390b2d56 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -6,7 +6,7 @@ import { UserRole } from '../../../../shared/index'
6import { 6import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoRating, getUserInformation, getUsersList, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoRating, getUserInformation, getUsersList,
8 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo, 8 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo,
9 runServer, ServerInfo, serverLogin, updateMyUser, updateUser, uploadVideo 9 runServer, ServerInfo, serverLogin, testVideoImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo
10} from '../../utils/index' 10} from '../../utils/index'
11import { follow } from '../../utils/server/follows' 11import { follow } from '../../utils/server/follows'
12import { setAccessTokensToServers } from '../../utils/users/login' 12import { setAccessTokensToServers } from '../../utils/users/login'
@@ -340,6 +340,22 @@ describe('Test users', function () {
340 expect(user.id).to.be.a('number') 340 expect(user.id).to.be.a('number')
341 }) 341 })
342 342
343 it('Should be able to update my avatar', async function () {
344 const fixture = 'avatar.png'
345
346 await updateMyAvatar({
347 url: server.url,
348 accessToken: accessTokenUser,
349 fixture
350 })
351
352 const res = await getMyUserInformation(server.url, accessTokenUser)
353 const user = res.body
354
355 const test = await testVideoImage(server.url, 'avatar', user.account.avatar.path, '.png')
356 expect(test).to.equal(true)
357 })
358
343 it('Should be able to update another user', async function () { 359 it('Should be able to update another user', async function () {
344 await updateUser({ 360 await updateUser({
345 url: server.url, 361 url: server.url,