diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
commit | fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58 (patch) | |
tree | bd626648077f84fb4628af3a37acf260597fa0ef /server/tests | |
parent | f68d1cb6ac4aa4fb563b9eeb831fccffee260b2f (diff) | |
download | PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.gz PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.zst PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.zip |
Filter host for channels and playlists search
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/search/search-channels.ts | 58 | ||||
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 58 |
2 files changed, 101 insertions, 15 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 | }) |
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 22e9b8fca..c3b318f5b 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.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, |
@@ -15,20 +16,22 @@ import { VideoPlaylistPrivacy } from '@shared/models' | |||
15 | const expect = chai.expect | 16 | const expect = chai.expect |
16 | 17 | ||
17 | describe('Test playlists search', function () { | 18 | describe('Test playlists search', function () { |
18 | let server: PeerTubeServer = null | 19 | let server: PeerTubeServer |
20 | let remoteServer: PeerTubeServer | ||
19 | let command: SearchCommand | 21 | let command: SearchCommand |
20 | 22 | ||
21 | before(async function () { | 23 | before(async function () { |
22 | this.timeout(30000) | 24 | this.timeout(30000) |
23 | 25 | ||
24 | server = await createSingleServer(1) | 26 | server = await createSingleServer(1) |
27 | remoteServer = await createSingleServer(2, { transcoding: { enabled: false } }) | ||
25 | 28 | ||
26 | await setAccessTokensToServers([ server ]) | 29 | await setAccessTokensToServers([ remoteServer, server ]) |
27 | await setDefaultVideoChannel([ server ]) | 30 | await setDefaultVideoChannel([ remoteServer, server ]) |
28 | |||
29 | const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid | ||
30 | 31 | ||
31 | { | 32 | { |
33 | const videoId = (await server.videos.upload()).uuid | ||
34 | |||
32 | const attributes = { | 35 | const attributes = { |
33 | displayName: 'Dr. Kenzo Tenma hospital videos', | 36 | displayName: 'Dr. Kenzo Tenma hospital videos', |
34 | privacy: VideoPlaylistPrivacy.PUBLIC, | 37 | privacy: VideoPlaylistPrivacy.PUBLIC, |
@@ -40,14 +43,16 @@ describe('Test playlists search', function () { | |||
40 | } | 43 | } |
41 | 44 | ||
42 | { | 45 | { |
46 | const videoId = (await remoteServer.videos.upload()).uuid | ||
47 | |||
43 | const attributes = { | 48 | const attributes = { |
44 | displayName: 'Johan & Anna Libert musics', | 49 | displayName: 'Johan & Anna Libert music videos', |
45 | privacy: VideoPlaylistPrivacy.PUBLIC, | 50 | privacy: VideoPlaylistPrivacy.PUBLIC, |
46 | videoChannelId: server.store.channel.id | 51 | videoChannelId: remoteServer.store.channel.id |
47 | } | 52 | } |
48 | const created = await server.playlists.create({ attributes }) | 53 | const created = await remoteServer.playlists.create({ attributes }) |
49 | 54 | ||
50 | await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) | 55 | await remoteServer.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) |
51 | } | 56 | } |
52 | 57 | ||
53 | { | 58 | { |
@@ -59,6 +64,8 @@ describe('Test playlists search', function () { | |||
59 | await server.playlists.create({ attributes }) | 64 | await server.playlists.create({ attributes }) |
60 | } | 65 | } |
61 | 66 | ||
67 | await doubleFollow(server, remoteServer) | ||
68 | |||
62 | command = server.search | 69 | command = server.search |
63 | }) | 70 | }) |
64 | 71 | ||
@@ -87,7 +94,7 @@ describe('Test playlists search', function () { | |||
87 | 94 | ||
88 | { | 95 | { |
89 | const search = { | 96 | const search = { |
90 | search: 'Anna Livert', | 97 | search: 'Anna Livert music', |
91 | start: 0, | 98 | start: 0, |
92 | count: 1 | 99 | count: 1 |
93 | } | 100 | } |
@@ -96,7 +103,36 @@ describe('Test playlists search', function () { | |||
96 | expect(body.data).to.have.lengthOf(1) | 103 | expect(body.data).to.have.lengthOf(1) |
97 | 104 | ||
98 | const playlist = body.data[0] | 105 | const playlist = body.data[0] |
99 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') | 106 | expect(playlist.displayName).to.equal('Johan & Anna Libert music videos') |
107 | } | ||
108 | }) | ||
109 | |||
110 | it('Should filter by host', async function () { | ||
111 | { | ||
112 | const search = { search: 'tenma', host: server.host } | ||
113 | const body = await command.advancedPlaylistSearch({ search }) | ||
114 | expect(body.total).to.equal(1) | ||
115 | expect(body.data).to.have.lengthOf(1) | ||
116 | |||
117 | const playlist = body.data[0] | ||
118 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') | ||
119 | } | ||
120 | |||
121 | { | ||
122 | const search = { search: 'Anna', host: 'example.com' } | ||
123 | const body = await command.advancedPlaylistSearch({ search }) | ||
124 | expect(body.total).to.equal(0) | ||
125 | expect(body.data).to.have.lengthOf(0) | ||
126 | } | ||
127 | |||
128 | { | ||
129 | const search = { search: 'video', host: remoteServer.host } | ||
130 | const body = await command.advancedPlaylistSearch({ search }) | ||
131 | expect(body.total).to.equal(1) | ||
132 | expect(body.data).to.have.lengthOf(1) | ||
133 | |||
134 | const playlist = body.data[0] | ||
135 | expect(playlist.displayName).to.equal('Johan & Anna Libert music videos') | ||
100 | } | 136 | } |
101 | }) | 137 | }) |
102 | 138 | ||