aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-activitypub-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-20 15:01:17 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 15:26:38 +0200
commit400043b1be38cdd7bc39462fa6a545eea0bea03e (patch)
tree68f447d00e06f80bbe84bf38dac30005e66cf2e4 /server/tests/api/search/search-activitypub-videos.ts
parentebe9b6b3f32d8432980854a51d28a8fb88fe62e5 (diff)
downloadPeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.tar.gz
PeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.tar.zst
PeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.zip
Add ability to search by URL with query params
Diffstat (limited to 'server/tests/api/search/search-activitypub-videos.ts')
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts34
1 files changed, 26 insertions, 8 deletions
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index b3cfcacca..a2e6e70fe 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -46,7 +46,7 @@ describe('Test ActivityPub videos search', function () {
46 46
47 it('Should not find a remote video', async function () { 47 it('Should not find a remote video', async function () {
48 { 48 {
49 const search = 'http://localhost:' + servers[1].port + '/videos/watch/43' 49 const search = servers[1].url + '/videos/watch/43'
50 const body = await command.searchVideos({ search, token: servers[0].accessToken }) 50 const body = await command.searchVideos({ search, token: servers[0].accessToken })
51 51
52 expect(body.total).to.equal(0) 52 expect(body.total).to.equal(0)
@@ -56,7 +56,7 @@ describe('Test ActivityPub videos search', function () {
56 56
57 { 57 {
58 // Without token 58 // Without token
59 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID 59 const search = servers[1].url + '/videos/watch/' + videoServer2UUID
60 const body = await command.searchVideos({ search }) 60 const body = await command.searchVideos({ search })
61 61
62 expect(body.total).to.equal(0) 62 expect(body.total).to.equal(0)
@@ -66,7 +66,7 @@ describe('Test ActivityPub videos search', function () {
66 }) 66 })
67 67
68 it('Should search a local video', async function () { 68 it('Should search a local video', async function () {
69 const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID 69 const search = servers[0].url + '/videos/watch/' + videoServer1UUID
70 const body = await command.searchVideos({ search }) 70 const body = await command.searchVideos({ search })
71 71
72 expect(body.total).to.equal(1) 72 expect(body.total).to.equal(1)
@@ -76,7 +76,7 @@ describe('Test ActivityPub videos search', function () {
76 }) 76 })
77 77
78 it('Should search a local video with an alternative URL', async function () { 78 it('Should search a local video with an alternative URL', async function () {
79 const search = 'http://localhost:' + servers[0].port + '/w/' + videoServer1UUID 79 const search = servers[0].url + '/w/' + videoServer1UUID
80 const body1 = await command.searchVideos({ search }) 80 const body1 = await command.searchVideos({ search })
81 const body2 = await command.searchVideos({ search, token: servers[0].accessToken }) 81 const body2 = await command.searchVideos({ search, token: servers[0].accessToken })
82 82
@@ -88,10 +88,28 @@ describe('Test ActivityPub videos search', function () {
88 } 88 }
89 }) 89 })
90 90
91 it('Should search a local video with a query in URL', async function () {
92 const searches = [
93 servers[0].url + '/w/' + videoServer1UUID,
94 servers[0].url + '/videos/watch/' + videoServer1UUID
95 ]
96
97 for (const search of searches) {
98 for (const token of [ undefined, servers[0].accessToken ]) {
99 const body = await command.searchVideos({ search: search + '?startTime=4', token })
100
101 expect(body.total).to.equal(1)
102 expect(body.data).to.be.an('array')
103 expect(body.data).to.have.lengthOf(1)
104 expect(body.data[0].name).to.equal('video 1 on server 1')
105 }
106 }
107 })
108
91 it('Should search a remote video', async function () { 109 it('Should search a remote video', async function () {
92 const searches = [ 110 const searches = [
93 'http://localhost:' + servers[1].port + '/w/' + videoServer2UUID, 111 servers[1].url + '/w/' + videoServer2UUID,
94 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID 112 servers[1].url + '/videos/watch/' + videoServer2UUID
95 ] 113 ]
96 114
97 for (const search of searches) { 115 for (const search of searches) {
@@ -134,7 +152,7 @@ describe('Test ActivityPub videos search', function () {
134 await wait(10000) 152 await wait(10000)
135 153
136 // Will run refresh async 154 // Will run refresh async
137 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID 155 const search = servers[1].url + '/videos/watch/' + videoServer2UUID
138 await command.searchVideos({ search, token: servers[0].accessToken }) 156 await command.searchVideos({ search, token: servers[0].accessToken })
139 157
140 // Wait refresh 158 // Wait refresh
@@ -160,7 +178,7 @@ describe('Test ActivityPub videos search', function () {
160 await wait(10000) 178 await wait(10000)
161 179
162 // Will run refresh async 180 // Will run refresh async
163 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID 181 const search = servers[1].url + '/videos/watch/' + videoServer2UUID
164 await command.searchVideos({ search, token: servers[0].accessToken }) 182 await command.searchVideos({ search, token: servers[0].accessToken })
165 183
166 // Wait refresh 184 // Wait refresh