From c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Dec 2017 19:10:13 +0100 Subject: Begin to add avatar to actors --- server/tests/utils/users/users.ts | 29 +++++++++++++++++++++++++++-- server/tests/utils/videos/videos.ts | 4 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'server/tests/utils') diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index e0cca3f51..90b1ca0a6 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts @@ -1,5 +1,6 @@ +import { isAbsolute, join } from 'path' import * as request from 'supertest' -import { makePutBodyRequest } from '../' +import { makePostUploadRequest, makePutBodyRequest } from '../' import { UserRole } from '../../../../shared/index' @@ -137,6 +138,29 @@ function updateMyUser (options: { }) } +function updateMyAvatar (options: { + url: string, + accessToken: string, + fixture: string +}) { + const path = '/api/v1/users/me/avatar/pick' + let filePath = '' + if (isAbsolute(options.fixture)) { + filePath = options.fixture + } else { + filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture) + } + + return makePostUploadRequest({ + url: options.url, + path, + token: options.accessToken, + fields: {}, + attaches: { avatarfile: filePath }, + statusCodeExpected: 200 + }) +} + function updateUser (options: { url: string userId: number, @@ -173,5 +197,6 @@ export { removeUser, updateUser, updateMyUser, - getUserInformation + getUserInformation, + updateMyAvatar } diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index d6bf27dc7..aca51ee5d 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -201,7 +201,7 @@ function searchVideoWithSort (url: string, search: string, sort: string) { .expect('Content-Type', /json/) } -async function testVideoImage (url: string, imageName: string, imagePath: string) { +async function testVideoImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { // Don't test images if the node env is not set // Because we need a special ffmpeg version for this test if (process.env['NODE_TEST_IMAGE']) { @@ -209,7 +209,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string .get(imagePath) .expect(200) - const data = await readFilePromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + '.jpg')) + const data = await readFilePromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension)) return data.equals(res.body) } else { -- cgit v1.2.3