diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-30 14:31:39 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-30 14:31:39 +0100 |
commit | cca1e13b96799377f19bcc95110fbf76ff741e20 (patch) | |
tree | 785dfaa81d1eb4e568a038161611126f7704af0b | |
parent | 1a393a7e23cb20afa951d4ef77084487629df58e (diff) | |
download | PeerTube-cca1e13b96799377f19bcc95110fbf76ff741e20.tar.gz PeerTube-cca1e13b96799377f19bcc95110fbf76ff741e20.tar.zst PeerTube-cca1e13b96799377f19bcc95110fbf76ff741e20.zip |
Add test to search in my videos
-rw-r--r-- | server/tests/api/users/users.ts | 18 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index ca06942e7..07b7fc747 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -309,6 +309,24 @@ describe('Test users', function () { | |||
309 | expect(video.thumbnailPath).to.not.be.null | 309 | expect(video.thumbnailPath).to.not.be.null |
310 | expect(video.previewPath).to.not.be.null | 310 | expect(video.previewPath).to.not.be.null |
311 | }) | 311 | }) |
312 | |||
313 | it('Should be able to search in my videos', async function () { | ||
314 | { | ||
315 | const res = await getMyVideos(server.url, accessTokenUser, 0, 5, '-createdAt', 'user video') | ||
316 | expect(res.body.total).to.equal(1) | ||
317 | |||
318 | const videos = res.body.data | ||
319 | expect(videos).to.have.lengthOf(1) | ||
320 | } | ||
321 | |||
322 | { | ||
323 | const res = await getMyVideos(server.url, accessTokenUser, 0, 5, '-createdAt', 'toto') | ||
324 | expect(res.body.total).to.equal(0) | ||
325 | |||
326 | const videos = res.body.data | ||
327 | expect(videos).to.have.lengthOf(0) | ||
328 | } | ||
329 | }) | ||
312 | }) | 330 | }) |
313 | 331 | ||
314 | describe('Users listing', function () { | 332 | describe('Users listing', function () { |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 1fcc949da..84b79b253 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -161,13 +161,14 @@ function getLocalVideos (url: string) { | |||
161 | .expect('Content-Type', /json/) | 161 | .expect('Content-Type', /json/) |
162 | } | 162 | } |
163 | 163 | ||
164 | function getMyVideos (url: string, accessToken: string, start: number, count: number, sort?: string) { | 164 | function getMyVideos (url: string, accessToken: string, start: number, count: number, sort?: string, search?: string) { |
165 | const path = '/api/v1/users/me/videos' | 165 | const path = '/api/v1/users/me/videos' |
166 | 166 | ||
167 | const req = request(url) | 167 | const req = request(url) |
168 | .get(path) | 168 | .get(path) |
169 | .query({ start: start }) | 169 | .query({ start: start }) |
170 | .query({ count: count }) | 170 | .query({ count: count }) |
171 | .query({ search: search }) | ||
171 | 172 | ||
172 | if (sort) req.query({ sort }) | 173 | if (sort) req.query({ sort }) |
173 | 174 | ||