diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-29 19:10:13 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-29 19:10:13 +0100 |
commit | c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (patch) | |
tree | b8d287daca6c45305090cbec9da97d1155f275bd /server/tests/utils | |
parent | 8b0d42ee372de6589796be26b83e5bffb1b69cdf (diff) | |
download | PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.gz PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.zst PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.zip |
Begin to add avatar to actors
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/users/users.ts | 29 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 4 |
2 files changed, 29 insertions, 4 deletions
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 @@ | |||
1 | import { isAbsolute, join } from 'path' | ||
1 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
2 | import { makePutBodyRequest } from '../' | 3 | import { makePostUploadRequest, makePutBodyRequest } from '../' |
3 | 4 | ||
4 | import { UserRole } from '../../../../shared/index' | 5 | import { UserRole } from '../../../../shared/index' |
5 | 6 | ||
@@ -137,6 +138,29 @@ function updateMyUser (options: { | |||
137 | }) | 138 | }) |
138 | } | 139 | } |
139 | 140 | ||
141 | function updateMyAvatar (options: { | ||
142 | url: string, | ||
143 | accessToken: string, | ||
144 | fixture: string | ||
145 | }) { | ||
146 | const path = '/api/v1/users/me/avatar/pick' | ||
147 | let filePath = '' | ||
148 | if (isAbsolute(options.fixture)) { | ||
149 | filePath = options.fixture | ||
150 | } else { | ||
151 | filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture) | ||
152 | } | ||
153 | |||
154 | return makePostUploadRequest({ | ||
155 | url: options.url, | ||
156 | path, | ||
157 | token: options.accessToken, | ||
158 | fields: {}, | ||
159 | attaches: { avatarfile: filePath }, | ||
160 | statusCodeExpected: 200 | ||
161 | }) | ||
162 | } | ||
163 | |||
140 | function updateUser (options: { | 164 | function updateUser (options: { |
141 | url: string | 165 | url: string |
142 | userId: number, | 166 | userId: number, |
@@ -173,5 +197,6 @@ export { | |||
173 | removeUser, | 197 | removeUser, |
174 | updateUser, | 198 | updateUser, |
175 | updateMyUser, | 199 | updateMyUser, |
176 | getUserInformation | 200 | getUserInformation, |
201 | updateMyAvatar | ||
177 | } | 202 | } |
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) { | |||
201 | .expect('Content-Type', /json/) | 201 | .expect('Content-Type', /json/) |
202 | } | 202 | } |
203 | 203 | ||
204 | async function testVideoImage (url: string, imageName: string, imagePath: string) { | 204 | async function testVideoImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { |
205 | // Don't test images if the node env is not set | 205 | // Don't test images if the node env is not set |
206 | // Because we need a special ffmpeg version for this test | 206 | // Because we need a special ffmpeg version for this test |
207 | if (process.env['NODE_TEST_IMAGE']) { | 207 | if (process.env['NODE_TEST_IMAGE']) { |
@@ -209,7 +209,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string | |||
209 | .get(imagePath) | 209 | .get(imagePath) |
210 | .expect(200) | 210 | .expect(200) |
211 | 211 | ||
212 | const data = await readFilePromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + '.jpg')) | 212 | const data = await readFilePromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension)) |
213 | 213 | ||
214 | return data.equals(res.body) | 214 | return data.equals(res.body) |
215 | } else { | 215 | } else { |