diff options
author | Andrés Maldonado <amaldona@etu.utc.fr> | 2018-11-27 18:57:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-12 11:14:37 +0100 |
commit | 31d065cc50e17a9abf263ed8c606cb272cd4933d (patch) | |
tree | 5e4516cb48dd36490e817bd9e59c41f3cad0d968 /server/tests | |
parent | 7f8f8bdb4a1fb695a114874c4679605ac8911e2d (diff) | |
download | PeerTube-31d065cc50e17a9abf263ed8c606cb272cd4933d.tar.gz PeerTube-31d065cc50e17a9abf263ed8c606cb272cd4933d.tar.zst PeerTube-31d065cc50e17a9abf263ed8c606cb272cd4933d.zip |
Add search by original publication date
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/search.ts | 6 | ||||
-rw-r--r-- | server/tests/api/search/search-videos.ts | 66 |
2 files changed, 71 insertions, 1 deletions
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index aa81965f3..7b7e07784 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -113,6 +113,12 @@ describe('Test videos API validator', function () { | |||
113 | 113 | ||
114 | const customQuery2 = immutableAssign(query, { endDate: 'hello' }) | 114 | const customQuery2 = immutableAssign(query, { endDate: 'hello' }) |
115 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: 400 }) | 115 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: 400 }) |
116 | |||
117 | const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' }) | ||
118 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: 400 }) | ||
119 | |||
120 | const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' }) | ||
121 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: 400 }) | ||
116 | }) | 122 | }) |
117 | }) | 123 | }) |
118 | 124 | ||
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 50da837da..fa4078b99 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -60,7 +60,10 @@ describe('Test a videos search', function () { | |||
60 | const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] }) | 60 | const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2 '] }) |
61 | await uploadVideo(server.url, server.accessToken, attributes6) | 61 | await uploadVideo(server.url, server.accessToken, attributes6) |
62 | 62 | ||
63 | const attributes7 = immutableAssign(attributes1, { name: attributes1.name + ' - 7' }) | 63 | const attributes7 = immutableAssign(attributes1, { |
64 | name: attributes1.name + ' - 7', | ||
65 | originallyPublishedAt: '2019-02-12T09:58:08.286Z' | ||
66 | }) | ||
64 | await uploadVideo(server.url, server.accessToken, attributes7) | 67 | await uploadVideo(server.url, server.accessToken, attributes7) |
65 | 68 | ||
66 | const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) | 69 | const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) |
@@ -343,6 +346,67 @@ describe('Test a videos search', function () { | |||
343 | expect(videos[0].name).to.equal('1111 2222 3333') | 346 | expect(videos[0].name).to.equal('1111 2222 3333') |
344 | }) | 347 | }) |
345 | 348 | ||
349 | it('Should search on originally published date', async function () { | ||
350 | const baseQuery = { | ||
351 | search: '1111 2222 3333', | ||
352 | languageOneOf: [ 'pl', 'fr' ], | ||
353 | durationMax: 4, | ||
354 | nsfw: 'false' as 'false', | ||
355 | licenceOneOf: [ 1, 4 ] | ||
356 | } | ||
357 | |||
358 | { | ||
359 | const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) | ||
360 | const res = await advancedVideosSearch(server.url, query) | ||
361 | |||
362 | expect(res.body.total).to.equal(1) | ||
363 | expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') | ||
364 | } | ||
365 | |||
366 | { | ||
367 | const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) | ||
368 | const res = await advancedVideosSearch(server.url, query) | ||
369 | |||
370 | expect(res.body.total).to.equal(1) | ||
371 | expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') | ||
372 | } | ||
373 | |||
374 | { | ||
375 | const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) | ||
376 | const res = await advancedVideosSearch(server.url, query) | ||
377 | |||
378 | expect(res.body.total).to.equal(0) | ||
379 | } | ||
380 | |||
381 | { | ||
382 | const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) | ||
383 | const res = await advancedVideosSearch(server.url, query) | ||
384 | |||
385 | expect(res.body.total).to.equal(0) | ||
386 | } | ||
387 | |||
388 | { | ||
389 | const query = immutableAssign(baseQuery, { | ||
390 | originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', | ||
391 | originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' | ||
392 | }) | ||
393 | const res = await advancedVideosSearch(server.url, query) | ||
394 | |||
395 | expect(res.body.total).to.equal(0) | ||
396 | } | ||
397 | |||
398 | { | ||
399 | const query = immutableAssign(baseQuery, { | ||
400 | originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', | ||
401 | originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' | ||
402 | }) | ||
403 | const res = await advancedVideosSearch(server.url, query) | ||
404 | |||
405 | expect(res.body.total).to.equal(1) | ||
406 | expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') | ||
407 | } | ||
408 | }) | ||
409 | |||
346 | after(async function () { | 410 | after(async function () { |
347 | killallServers([ server ]) | 411 | killallServers([ server ]) |
348 | 412 | ||