diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.js | 2 | ||||
-rw-r--r-- | server/models/videos.js | 2 | ||||
-rw-r--r-- | server/tests/api/singlePod.js | 38 |
3 files changed, 40 insertions, 2 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 97d22abdb..c6a6ac966 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -23,7 +23,7 @@ let REQUEST_RETRIES = 10 | |||
23 | 23 | ||
24 | // Sortable columns per schema | 24 | // Sortable columns per schema |
25 | const SEARCHABLE_COLUMNS = { | 25 | const SEARCHABLE_COLUMNS = { |
26 | VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author' ] | 26 | VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ] |
27 | } | 27 | } |
28 | 28 | ||
29 | // Sortable columns per schema | 29 | // Sortable columns per schema |
diff --git a/server/models/videos.js b/server/models/videos.js index f4658c371..d6b743c7c 100644 --- a/server/models/videos.js +++ b/server/models/videos.js | |||
@@ -128,7 +128,7 @@ function removeByIds (ids, callback) { | |||
128 | function search (value, field, start, count, sort, callback) { | 128 | function search (value, field, start, count, sort, callback) { |
129 | const query = {} | 129 | const query = {} |
130 | // Make an exact search with the magnet | 130 | // Make an exact search with the magnet |
131 | if (field === 'magnetUri') { | 131 | if (field === 'magnetUri' || field === 'tags') { |
132 | query[field] = value | 132 | query[field] = value |
133 | } else { | 133 | } else { |
134 | query[field] = new RegExp(value) | 134 | query[field] = new RegExp(value) |
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index ef882b080..5fcf5557f 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js | |||
@@ -187,6 +187,32 @@ describe('Test a single pod', function () { | |||
187 | }) | 187 | }) |
188 | }) | 188 | }) |
189 | 189 | ||
190 | it('Should search the video by tag', function (done) { | ||
191 | utils.searchVideo(server.url, 'tag1', 'tags', function (err, res) { | ||
192 | if (err) throw err | ||
193 | |||
194 | expect(res.body.total).to.equal(1) | ||
195 | expect(res.body.data).to.be.an('array') | ||
196 | expect(res.body.data.length).to.equal(1) | ||
197 | |||
198 | const video = res.body.data[0] | ||
199 | expect(video.name).to.equal('my super name') | ||
200 | expect(video.description).to.equal('my super description') | ||
201 | expect(video.podUrl).to.equal('localhost:9001') | ||
202 | expect(video.author).to.equal('root') | ||
203 | expect(video.isLocal).to.be.true | ||
204 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | ||
205 | expect(utils.dateIsValid(video.createdDate)).to.be.true | ||
206 | |||
207 | utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | ||
208 | if (err) throw err | ||
209 | expect(test).to.equal(true) | ||
210 | |||
211 | done() | ||
212 | }) | ||
213 | }) | ||
214 | }) | ||
215 | |||
190 | it('Should not find a search by name by default', function (done) { | 216 | it('Should not find a search by name by default', function (done) { |
191 | utils.searchVideo(server.url, 'hello', function (err, res) { | 217 | utils.searchVideo(server.url, 'hello', function (err, res) { |
192 | if (err) throw err | 218 | if (err) throw err |
@@ -211,6 +237,18 @@ describe('Test a single pod', function () { | |||
211 | }) | 237 | }) |
212 | }) | 238 | }) |
213 | 239 | ||
240 | it('Should not find a search by tag', function (done) { | ||
241 | utils.searchVideo(server.url, 'tag', 'tags', function (err, res) { | ||
242 | if (err) throw err | ||
243 | |||
244 | expect(res.body.total).to.equal(0) | ||
245 | expect(res.body.data).to.be.an('array') | ||
246 | expect(res.body.data.length).to.equal(0) | ||
247 | |||
248 | done() | ||
249 | }) | ||
250 | }) | ||
251 | |||
214 | it('Should remove the video', function (done) { | 252 | it('Should remove the video', function (done) { |
215 | utils.removeVideo(server.url, server.accessToken, videoId, function (err) { | 253 | utils.removeVideo(server.url, server.accessToken, videoId, function (err) { |
216 | if (err) throw err | 254 | if (err) throw err |