aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-24 11:09:00 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commitd411245096b7c9ec06e6fa2ceff7aa7b0fc0c3b7 (patch)
tree991a4c3e753b2371c8e314fd79ebc134b45659d1 /server/tests/api/search/search-videos.ts
parentcddf45035389cc7d9003ea2b64fff3c28cd368d9 (diff)
downloadPeerTube-d411245096b7c9ec06e6fa2ceff7aa7b0fc0c3b7.tar.gz
PeerTube-d411245096b7c9ec06e6fa2ceff7aa7b0fc0c3b7.tar.zst
PeerTube-d411245096b7c9ec06e6fa2ceff7aa7b0fc0c3b7.zip
Add ability to only filter in the search endpoint
Diffstat (limited to 'server/tests/api/search/search-videos.ts')
-rw-r--r--server/tests/api/search/search-videos.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index d2b0f0312..f1392ffea 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -103,6 +103,15 @@ describe('Test a videos search', function () {
103 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) 103 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] }))
104 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) 104 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] }))
105 } 105 }
106
107 {
108 const attributes1 = {
109 name: 'aaaa 2',
110 category: 1
111 }
112 await uploadVideo(server.url, server.accessToken, attributes1)
113 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 }))
114 }
106 }) 115 })
107 116
108 it('Should make a simple search and not have results', async function () { 117 it('Should make a simple search and not have results', async function () {
@@ -125,6 +134,52 @@ describe('Test a videos search', function () {
125 expect(videos[1].name).to.equal('3333 4444 5555') 134 expect(videos[1].name).to.equal('3333 4444 5555')
126 }) 135 })
127 136
137 it('Should make a search on tags too, and have results', async function () {
138 const query = {
139 search: 'aaaa',
140 categoryOneOf: [ 1 ]
141 }
142 const res = await advancedVideosSearch(server.url, query)
143
144 expect(res.body.total).to.equal(2)
145
146 const videos = res.body.data
147 expect(videos).to.have.lengthOf(2)
148
149 // bestmatch
150 expect(videos[0].name).to.equal('aaaa 2')
151 expect(videos[1].name).to.equal('9999')
152 })
153
154 it('Should filter on tags without a search', async function () {
155 const query = {
156 tagsAllOf: [ 'bbbb' ]
157 }
158 const res = await advancedVideosSearch(server.url, query)
159
160 expect(res.body.total).to.equal(2)
161
162 const videos = res.body.data
163 expect(videos).to.have.lengthOf(2)
164
165 expect(videos[0].name).to.equal('9999')
166 expect(videos[1].name).to.equal('9999')
167 })
168
169 it('Should filter on category without a search', async function () {
170 const query = {
171 categoryOneOf: [ 3 ]
172 }
173 const res = await advancedVideosSearch(server.url, query)
174
175 expect(res.body.total).to.equal(1)
176
177 const videos = res.body.data
178 expect(videos).to.have.lengthOf(1)
179
180 expect(videos[0].name).to.equal('6666 7777 8888')
181 })
182
128 it('Should search by tags (one of)', async function () { 183 it('Should search by tags (one of)', async function () {
129 const query = { 184 const query = {
130 search: '9999', 185 search: '9999',