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/api/search/search-playlists.ts | |
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/api/search/search-playlists.ts')
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 58 |
1 files changed, 47 insertions, 11 deletions
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 | ||