diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-28 16:40:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-28 16:40:21 +0200 |
commit | fbd67e7f386504e50f2504cb6386700a58906f16 (patch) | |
tree | 1a7143aaea76ce4e195fb9d6214a0cd769c556ea /server/tests/api | |
parent | 164c8d46cf5c948a28b4ac0e596fad9b83b2c229 (diff) | |
download | PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.gz PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.zst PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.zip |
Add ability to search by uuids/actor names
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/search.ts | 15 | ||||
-rw-r--r-- | server/tests/api/search/search-channels.ts | 24 | ||||
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 28 | ||||
-rw-r--r-- | server/tests/api/search/search-videos.ts | 28 |
4 files changed, 88 insertions, 7 deletions
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index 72ad6c842..789ea7754 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -146,6 +146,16 @@ describe('Test videos API validator', function () { | |||
146 | const customQuery = { ...query, host: 'example.com' } | 146 | const customQuery = { ...query, host: 'example.com' } |
147 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) | 147 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
148 | }) | 148 | }) |
149 | |||
150 | it('Should fail with invalid uuids', async function () { | ||
151 | const customQuery = { ...query, uuids: [ '6565', 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } | ||
152 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | ||
153 | }) | ||
154 | |||
155 | it('Should succeed with valid uuids', async function () { | ||
156 | const customQuery = { ...query, uuids: [ 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } | ||
157 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) | ||
158 | }) | ||
149 | }) | 159 | }) |
150 | 160 | ||
151 | describe('When searching video playlists', function () { | 161 | describe('When searching video playlists', function () { |
@@ -172,6 +182,11 @@ describe('Test videos API validator', function () { | |||
172 | await makeGetRequest({ url: server.url, path, query: { ...query, host: '6565' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | 182 | await makeGetRequest({ url: server.url, path, query: { ...query, host: '6565' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
173 | }) | 183 | }) |
174 | 184 | ||
185 | it('Should fail with invalid uuids', async function () { | ||
186 | const customQuery = { ...query, uuids: [ '6565', 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } | ||
187 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | ||
188 | }) | ||
189 | |||
175 | it('Should succeed with the correct parameters', async function () { | 190 | it('Should succeed with the correct parameters', async function () { |
176 | await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 }) | 191 | await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 }) |
177 | }) | 192 | }) |
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index aab03bfd1..ef78c0f67 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts | |||
@@ -22,8 +22,12 @@ describe('Test channels search', function () { | |||
22 | before(async function () { | 22 | before(async function () { |
23 | this.timeout(120000) | 23 | this.timeout(120000) |
24 | 24 | ||
25 | server = await createSingleServer(1) | 25 | const servers = await Promise.all([ |
26 | remoteServer = await createSingleServer(2, { transcoding: { enabled: false } }) | 26 | createSingleServer(1), |
27 | createSingleServer(2, { transcoding: { enabled: false } }) | ||
28 | ]) | ||
29 | server = servers[0] | ||
30 | remoteServer = servers[1] | ||
27 | 31 | ||
28 | await setAccessTokensToServers([ server, remoteServer ]) | 32 | await setAccessTokensToServers([ server, remoteServer ]) |
29 | 33 | ||
@@ -116,6 +120,22 @@ describe('Test channels search', function () { | |||
116 | } | 120 | } |
117 | }) | 121 | }) |
118 | 122 | ||
123 | it('Should filter by names', async function () { | ||
124 | { | ||
125 | const body = await command.advancedChannelSearch({ search: { names: [ 'squall_channel', 'zell_channel' ] } }) | ||
126 | expect(body.total).to.equal(2) | ||
127 | expect(body.data).to.have.lengthOf(2) | ||
128 | expect(body.data[0].displayName).to.equal('Squall channel') | ||
129 | expect(body.data[1].displayName).to.equal('Zell channel') | ||
130 | } | ||
131 | |||
132 | { | ||
133 | const body = await command.advancedChannelSearch({ search: { names: [ 'chocobozzz_channel' ] } }) | ||
134 | expect(body.total).to.equal(0) | ||
135 | expect(body.data).to.have.lengthOf(0) | ||
136 | } | ||
137 | }) | ||
138 | |||
119 | after(async function () { | 139 | after(async function () { |
120 | await cleanupTests([ server ]) | 140 | await cleanupTests([ server ]) |
121 | }) | 141 | }) |
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index e7e53ff41..85be1eb59 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts | |||
@@ -19,12 +19,18 @@ describe('Test playlists search', function () { | |||
19 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
20 | let remoteServer: PeerTubeServer | 20 | let remoteServer: PeerTubeServer |
21 | let command: SearchCommand | 21 | let command: SearchCommand |
22 | let playlistUUID: string | ||
23 | let playlistShortUUID: string | ||
22 | 24 | ||
23 | before(async function () { | 25 | before(async function () { |
24 | this.timeout(120000) | 26 | this.timeout(120000) |
25 | 27 | ||
26 | server = await createSingleServer(1) | 28 | const servers = await Promise.all([ |
27 | remoteServer = await createSingleServer(2, { transcoding: { enabled: false } }) | 29 | createSingleServer(1), |
30 | createSingleServer(2, { transcoding: { enabled: false } }) | ||
31 | ]) | ||
32 | server = servers[0] | ||
33 | remoteServer = servers[1] | ||
28 | 34 | ||
29 | await setAccessTokensToServers([ remoteServer, server ]) | 35 | await setAccessTokensToServers([ remoteServer, server ]) |
30 | await setDefaultVideoChannel([ remoteServer, server ]) | 36 | await setDefaultVideoChannel([ remoteServer, server ]) |
@@ -38,6 +44,8 @@ describe('Test playlists search', function () { | |||
38 | videoChannelId: server.store.channel.id | 44 | videoChannelId: server.store.channel.id |
39 | } | 45 | } |
40 | const created = await server.playlists.create({ attributes }) | 46 | const created = await server.playlists.create({ attributes }) |
47 | playlistUUID = created.uuid | ||
48 | playlistShortUUID = created.shortUUID | ||
41 | 49 | ||
42 | await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) | 50 | await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) |
43 | } | 51 | } |
@@ -136,6 +144,22 @@ describe('Test playlists search', function () { | |||
136 | } | 144 | } |
137 | }) | 145 | }) |
138 | 146 | ||
147 | it('Should filter by UUIDs', async function () { | ||
148 | for (const uuid of [ playlistUUID, playlistShortUUID ]) { | ||
149 | const body = await command.advancedPlaylistSearch({ search: { uuids: [ uuid ] } }) | ||
150 | |||
151 | expect(body.total).to.equal(1) | ||
152 | expect(body.data[0].displayName).to.equal('Dr. Kenzo Tenma hospital videos') | ||
153 | } | ||
154 | |||
155 | { | ||
156 | const body = await command.advancedPlaylistSearch({ search: { uuids: [ 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } }) | ||
157 | |||
158 | expect(body.total).to.equal(0) | ||
159 | expect(body.data).to.have.lengthOf(0) | ||
160 | } | ||
161 | }) | ||
162 | |||
139 | it('Should not display playlists without videos', async function () { | 163 | it('Should not display playlists without videos', async function () { |
140 | const search = { | 164 | const search = { |
141 | search: 'Lunge', | 165 | search: 'Lunge', |
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index a56dc1d87..bd1e4d266 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -22,14 +22,19 @@ describe('Test videos search', function () { | |||
22 | let remoteServer: PeerTubeServer | 22 | let remoteServer: PeerTubeServer |
23 | let startDate: string | 23 | let startDate: string |
24 | let videoUUID: string | 24 | let videoUUID: string |
25 | let videoShortUUID: string | ||
25 | 26 | ||
26 | let command: SearchCommand | 27 | let command: SearchCommand |
27 | 28 | ||
28 | before(async function () { | 29 | before(async function () { |
29 | this.timeout(120000) | 30 | this.timeout(120000) |
30 | 31 | ||
31 | server = await createSingleServer(1) | 32 | const servers = await Promise.all([ |
32 | remoteServer = await createSingleServer(2) | 33 | createSingleServer(1), |
34 | createSingleServer(2) | ||
35 | ]) | ||
36 | server = servers[0] | ||
37 | remoteServer = servers[1] | ||
33 | 38 | ||
34 | await setAccessTokensToServers([ server, remoteServer ]) | 39 | await setAccessTokensToServers([ server, remoteServer ]) |
35 | await setDefaultVideoChannel([ server, remoteServer ]) | 40 | await setDefaultVideoChannel([ server, remoteServer ]) |
@@ -50,8 +55,9 @@ describe('Test videos search', function () { | |||
50 | 55 | ||
51 | { | 56 | { |
52 | const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } | 57 | const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } |
53 | const { id, uuid } = await server.videos.upload({ attributes: attributes3 }) | 58 | const { id, uuid, shortUUID } = await server.videos.upload({ attributes: attributes3 }) |
54 | videoUUID = uuid | 59 | videoUUID = uuid |
60 | videoShortUUID = shortUUID | ||
55 | 61 | ||
56 | await server.captions.add({ | 62 | await server.captions.add({ |
57 | language: 'en', | 63 | language: 'en', |
@@ -479,6 +485,22 @@ describe('Test videos search', function () { | |||
479 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | 485 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') |
480 | }) | 486 | }) |
481 | 487 | ||
488 | it('Should filter by UUIDs', async function () { | ||
489 | for (const uuid of [ videoUUID, videoShortUUID ]) { | ||
490 | const body = await command.advancedVideoSearch({ search: { uuids: [ uuid ] } }) | ||
491 | |||
492 | expect(body.total).to.equal(1) | ||
493 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | ||
494 | } | ||
495 | |||
496 | { | ||
497 | const body = await command.advancedVideoSearch({ search: { uuids: [ 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } }) | ||
498 | |||
499 | expect(body.total).to.equal(0) | ||
500 | expect(body.data).to.have.lengthOf(0) | ||
501 | } | ||
502 | }) | ||
503 | |||
482 | it('Should search by host', async function () { | 504 | it('Should search by host', async function () { |
483 | { | 505 | { |
484 | const body = await command.advancedVideoSearch({ search: { search: '6666 7777 8888', host: server.host } }) | 506 | const body = await command.advancedVideoSearch({ search: { search: '6666 7777 8888', host: server.host } }) |