diff options
Diffstat (limited to 'server/tests/api/search/search-channels.ts')
-rw-r--r-- | server/tests/api/search/search-channels.ts | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 4da2d0ece..d3b0f4321 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts | |||
@@ -2,24 +2,33 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' | 5 | import { |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | SearchCommand, | ||
11 | setAccessTokensToServers | ||
12 | } from '@shared/extra-utils' | ||
6 | import { VideoChannel } from '@shared/models' | 13 | import { VideoChannel } from '@shared/models' |
7 | 14 | ||
8 | const expect = chai.expect | 15 | const expect = chai.expect |
9 | 16 | ||
10 | describe('Test channels search', function () { | 17 | describe('Test channels search', function () { |
11 | let server: PeerTubeServer = null | 18 | let server: PeerTubeServer |
19 | let remoteServer: PeerTubeServer | ||
12 | let command: SearchCommand | 20 | let command: SearchCommand |
13 | 21 | ||
14 | before(async function () { | 22 | before(async function () { |
15 | this.timeout(30000) | 23 | this.timeout(30000) |
16 | 24 | ||
17 | server = await createSingleServer(1) | 25 | server = await createSingleServer(1) |
26 | remoteServer = await createSingleServer(2, { transcoding: { enabled: false } }) | ||
18 | 27 | ||
19 | await setAccessTokensToServers([ server ]) | 28 | await setAccessTokensToServers([ server, remoteServer ]) |
20 | 29 | ||
21 | { | 30 | { |
22 | await server.users.create({ username: 'user1', password: 'password' }) | 31 | await server.users.create({ username: 'user1' }) |
23 | const channel = { | 32 | const channel = { |
24 | name: 'squall_channel', | 33 | name: 'squall_channel', |
25 | displayName: 'Squall channel' | 34 | displayName: 'Squall channel' |
@@ -27,6 +36,19 @@ describe('Test channels search', function () { | |||
27 | await server.channels.create({ attributes: channel }) | 36 | await server.channels.create({ attributes: channel }) |
28 | } | 37 | } |
29 | 38 | ||
39 | { | ||
40 | await remoteServer.users.create({ username: 'user1' }) | ||
41 | const channel = { | ||
42 | name: 'zell_channel', | ||
43 | displayName: 'Zell channel' | ||
44 | } | ||
45 | const { id } = await remoteServer.channels.create({ attributes: channel }) | ||
46 | |||
47 | await remoteServer.videos.upload({ attributes: { channelId: id } }) | ||
48 | } | ||
49 | |||
50 | await doubleFollow(server, remoteServer) | ||
51 | |||
30 | command = server.search | 52 | command = server.search |
31 | }) | 53 | }) |
32 | 54 | ||
@@ -66,6 +88,34 @@ describe('Test channels search', function () { | |||
66 | } | 88 | } |
67 | }) | 89 | }) |
68 | 90 | ||
91 | it('Should filter by host', async function () { | ||
92 | { | ||
93 | const search = { search: 'channel', host: remoteServer.host } | ||
94 | |||
95 | const body = await command.advancedChannelSearch({ search }) | ||
96 | expect(body.total).to.equal(1) | ||
97 | expect(body.data).to.have.lengthOf(1) | ||
98 | expect(body.data[0].displayName).to.equal('Zell channel') | ||
99 | } | ||
100 | |||
101 | { | ||
102 | const search = { search: 'Sq', host: server.host } | ||
103 | |||
104 | const body = await command.advancedChannelSearch({ search }) | ||
105 | expect(body.total).to.equal(1) | ||
106 | expect(body.data).to.have.lengthOf(1) | ||
107 | expect(body.data[0].displayName).to.equal('Squall channel') | ||
108 | } | ||
109 | |||
110 | { | ||
111 | const search = { search: 'Squall', host: 'example.com' } | ||
112 | |||
113 | const body = await command.advancedChannelSearch({ search }) | ||
114 | expect(body.total).to.equal(0) | ||
115 | expect(body.data).to.have.lengthOf(0) | ||
116 | } | ||
117 | }) | ||
118 | |||
69 | after(async function () { | 119 | after(async function () { |
70 | await cleanupTests([ server ]) | 120 | await cleanupTests([ server ]) |
71 | }) | 121 | }) |