diff options
Diffstat (limited to 'server/tests/api/search')
-rw-r--r-- | server/tests/api/search/search-videos.ts | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 965766742..a56dc1d87 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -5,6 +5,7 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | createSingleServer, | 7 | createSingleServer, |
8 | doubleFollow, | ||
8 | PeerTubeServer, | 9 | PeerTubeServer, |
9 | SearchCommand, | 10 | SearchCommand, |
10 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
@@ -17,19 +18,21 @@ import { VideoPrivacy } from '@shared/models' | |||
17 | const expect = chai.expect | 18 | const expect = chai.expect |
18 | 19 | ||
19 | describe('Test videos search', function () { | 20 | describe('Test videos search', function () { |
20 | let server: PeerTubeServer = null | 21 | let server: PeerTubeServer |
22 | let remoteServer: PeerTubeServer | ||
21 | let startDate: string | 23 | let startDate: string |
22 | let videoUUID: string | 24 | let videoUUID: string |
23 | 25 | ||
24 | let command: SearchCommand | 26 | let command: SearchCommand |
25 | 27 | ||
26 | before(async function () { | 28 | before(async function () { |
27 | this.timeout(60000) | 29 | this.timeout(120000) |
28 | 30 | ||
29 | server = await createSingleServer(1) | 31 | server = await createSingleServer(1) |
32 | remoteServer = await createSingleServer(2) | ||
30 | 33 | ||
31 | await setAccessTokensToServers([ server ]) | 34 | await setAccessTokensToServers([ server, remoteServer ]) |
32 | await setDefaultVideoChannel([ server ]) | 35 | await setDefaultVideoChannel([ server, remoteServer ]) |
33 | 36 | ||
34 | { | 37 | { |
35 | const attributes1 = { | 38 | const attributes1 = { |
@@ -131,6 +134,13 @@ describe('Test videos search', function () { | |||
131 | await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) | 134 | await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) |
132 | } | 135 | } |
133 | 136 | ||
137 | { | ||
138 | await remoteServer.videos.upload({ attributes: { name: 'remote video 1' } }) | ||
139 | await remoteServer.videos.upload({ attributes: { name: 'remote video 2' } }) | ||
140 | } | ||
141 | |||
142 | await doubleFollow(server, remoteServer) | ||
143 | |||
134 | command = server.search | 144 | command = server.search |
135 | }) | 145 | }) |
136 | 146 | ||
@@ -469,8 +479,30 @@ describe('Test videos search', function () { | |||
469 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | 479 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') |
470 | }) | 480 | }) |
471 | 481 | ||
482 | it('Should search by host', async function () { | ||
483 | { | ||
484 | const body = await command.advancedVideoSearch({ search: { search: '6666 7777 8888', host: server.host } }) | ||
485 | expect(body.total).to.equal(1) | ||
486 | expect(body.data[0].name).to.equal('6666 7777 8888') | ||
487 | } | ||
488 | |||
489 | { | ||
490 | const body = await command.advancedVideoSearch({ search: { search: '1111', host: 'example.com' } }) | ||
491 | expect(body.total).to.equal(0) | ||
492 | expect(body.data).to.have.lengthOf(0) | ||
493 | } | ||
494 | |||
495 | { | ||
496 | const body = await command.advancedVideoSearch({ search: { search: 'remote', host: remoteServer.host } }) | ||
497 | expect(body.total).to.equal(2) | ||
498 | expect(body.data).to.have.lengthOf(2) | ||
499 | expect(body.data[0].name).to.equal('remote video 1') | ||
500 | expect(body.data[1].name).to.equal('remote video 2') | ||
501 | } | ||
502 | }) | ||
503 | |||
472 | it('Should search by live', async function () { | 504 | it('Should search by live', async function () { |
473 | this.timeout(30000) | 505 | this.timeout(60000) |
474 | 506 | ||
475 | { | 507 | { |
476 | const newConfig = { | 508 | const newConfig = { |