Add ability to search by URL with query params

This commit is contained in:
Chocobozzz
2021-10-20 15:01:17 +02:00
parent ebe9b6b3f3
commit 400043b1be
10 changed files with 109 additions and 33 deletions

View File

@@ -64,7 +64,7 @@ describe('Test ActivityPub video channels search', function () {
this.timeout(15000)
{
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3'
const search = servers[1].url + '/video-channels/channel1_server3'
const body = await command.searchChannels({ search, token: servers[0].accessToken })
expect(body.total).to.equal(0)
@@ -74,7 +74,7 @@ describe('Test ActivityPub video channels search', function () {
{
// Without token
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const search = servers[1].url + '/video-channels/channel1_server2'
const body = await command.searchChannels({ search })
expect(body.total).to.equal(0)
@@ -85,7 +85,7 @@ describe('Test ActivityPub video channels search', function () {
it('Should search a local video channel', async function () {
const searches = [
'http://localhost:' + servers[0].port + '/video-channels/channel1_server1',
servers[0].url + '/video-channels/channel1_server1',
'channel1_server1@localhost:' + servers[0].port
]
@@ -101,7 +101,7 @@ describe('Test ActivityPub video channels search', function () {
})
it('Should search a local video channel with an alternative URL', async function () {
const search = 'http://localhost:' + servers[0].port + '/c/channel1_server1'
const search = servers[0].url + '/c/channel1_server1'
for (const token of [ undefined, servers[0].accessToken ]) {
const body = await command.searchChannels({ search, token })
@@ -114,11 +114,30 @@ describe('Test ActivityPub video channels search', function () {
}
})
it('Should search a local video channel with a query in URL', async function () {
const searches = [
servers[0].url + '/video-channels/channel1_server1',
servers[0].url + '/c/channel1_server1'
]
for (const search of searches) {
for (const token of [ undefined, servers[0].accessToken ]) {
const body = await command.searchChannels({ search: search + '?param=2', token })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].name).to.equal('channel1_server1')
expect(body.data[0].displayName).to.equal('Channel 1 server 1')
}
}
})
it('Should search a remote video channel with URL or handle', async function () {
const searches = [
'http://localhost:' + servers[1].port + '/video-channels/channel1_server2',
'http://localhost:' + servers[1].port + '/c/channel1_server2',
'http://localhost:' + servers[1].port + '/c/channel1_server2/videos',
servers[1].url + '/video-channels/channel1_server2',
servers[1].url + '/c/channel1_server2',
servers[1].url + '/c/channel1_server2/videos',
'channel1_server2@localhost:' + servers[1].port
]
@@ -178,7 +197,7 @@ describe('Test ActivityPub video channels search', function () {
// Expire video channel
await wait(10000)
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const search = servers[1].url + '/video-channels/channel1_server2'
const body = await command.searchChannels({ search, token: servers[0].accessToken })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
@@ -201,7 +220,7 @@ describe('Test ActivityPub video channels search', function () {
// Expire video channel
await wait(10000)
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const search = servers[1].url + '/video-channels/channel1_server2'
await command.searchChannels({ search, token: servers[0].accessToken })
await waitJobs(servers)
@@ -223,7 +242,7 @@ describe('Test ActivityPub video channels search', function () {
// Expire video
await wait(10000)
const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'
const search = servers[1].url + '/video-channels/channel1_server2'
const body = await command.searchChannels({ search, token: servers[0].accessToken })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)

View File

@@ -71,7 +71,7 @@ describe('Test ActivityPub playlists search', function () {
it('Should not find a remote playlist', async function () {
{
const search = 'http://localhost:' + servers[1].port + '/video-playlists/43'
const search = servers[1].url + '/video-playlists/43'
const body = await command.searchPlaylists({ search, token: servers[0].accessToken })
expect(body.total).to.equal(0)
@@ -81,7 +81,7 @@ describe('Test ActivityPub playlists search', function () {
{
// Without token
const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
const search = servers[1].url + '/video-playlists/' + playlistServer2UUID
const body = await command.searchPlaylists({ search })
expect(body.total).to.equal(0)
@@ -91,7 +91,7 @@ describe('Test ActivityPub playlists search', function () {
})
it('Should search a local playlist', async function () {
const search = 'http://localhost:' + servers[0].port + '/video-playlists/' + playlistServer1UUID
const search = servers[0].url + '/video-playlists/' + playlistServer1UUID
const body = await command.searchPlaylists({ search })
expect(body.total).to.equal(1)
@@ -103,8 +103,8 @@ describe('Test ActivityPub playlists search', function () {
it('Should search a local playlist with an alternative URL', async function () {
const searches = [
'http://localhost:' + servers[0].port + '/videos/watch/playlist/' + playlistServer1UUID,
'http://localhost:' + servers[0].port + '/w/p/' + playlistServer1UUID
servers[0].url + '/videos/watch/playlist/' + playlistServer1UUID,
servers[0].url + '/w/p/' + playlistServer1UUID
]
for (const search of searches) {
@@ -120,11 +120,30 @@ describe('Test ActivityPub playlists search', function () {
}
})
it('Should search a local playlist with a query in URL', async function () {
const searches = [
servers[0].url + '/videos/watch/playlist/' + playlistServer1UUID,
servers[0].url + '/w/p/' + playlistServer1UUID
]
for (const search of searches) {
for (const token of [ undefined, servers[0].accessToken ]) {
const body = await command.searchPlaylists({ search: search + '?param=1', token })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
expect(body.data[0].videosLength).to.equal(2)
}
}
})
it('Should search a remote playlist', async function () {
const searches = [
'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID,
'http://localhost:' + servers[1].port + '/videos/watch/playlist/' + playlistServer2UUID,
'http://localhost:' + servers[1].port + '/w/p/' + playlistServer2UUID
servers[1].url + '/video-playlists/' + playlistServer2UUID,
servers[1].url + '/videos/watch/playlist/' + playlistServer2UUID,
servers[1].url + '/w/p/' + playlistServer2UUID
]
for (const search of searches) {
@@ -155,7 +174,7 @@ describe('Test ActivityPub playlists search', function () {
await wait(10000)
// Will run refresh async
const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
const search = servers[1].url + '/video-playlists/' + playlistServer2UUID
await command.searchPlaylists({ search, token: servers[0].accessToken })
// Wait refresh
@@ -179,7 +198,7 @@ describe('Test ActivityPub playlists search', function () {
await wait(10000)
// Will run refresh async
const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
const search = servers[1].url + '/video-playlists/' + playlistServer2UUID
await command.searchPlaylists({ search, token: servers[0].accessToken })
// Wait refresh

View File

@@ -46,7 +46,7 @@ describe('Test ActivityPub videos search', function () {
it('Should not find a remote video', async function () {
{
const search = 'http://localhost:' + servers[1].port + '/videos/watch/43'
const search = servers[1].url + '/videos/watch/43'
const body = await command.searchVideos({ search, token: servers[0].accessToken })
expect(body.total).to.equal(0)
@@ -56,7 +56,7 @@ describe('Test ActivityPub videos search', function () {
{
// Without token
const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
const search = servers[1].url + '/videos/watch/' + videoServer2UUID
const body = await command.searchVideos({ search })
expect(body.total).to.equal(0)
@@ -66,7 +66,7 @@ describe('Test ActivityPub videos search', function () {
})
it('Should search a local video', async function () {
const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID
const search = servers[0].url + '/videos/watch/' + videoServer1UUID
const body = await command.searchVideos({ search })
expect(body.total).to.equal(1)
@@ -76,7 +76,7 @@ describe('Test ActivityPub videos search', function () {
})
it('Should search a local video with an alternative URL', async function () {
const search = 'http://localhost:' + servers[0].port + '/w/' + videoServer1UUID
const search = servers[0].url + '/w/' + videoServer1UUID
const body1 = await command.searchVideos({ search })
const body2 = await command.searchVideos({ search, token: servers[0].accessToken })
@@ -88,10 +88,28 @@ describe('Test ActivityPub videos search', function () {
}
})
it('Should search a local video with a query in URL', async function () {
const searches = [
servers[0].url + '/w/' + videoServer1UUID,
servers[0].url + '/videos/watch/' + videoServer1UUID
]
for (const search of searches) {
for (const token of [ undefined, servers[0].accessToken ]) {
const body = await command.searchVideos({ search: search + '?startTime=4', token })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].name).to.equal('video 1 on server 1')
}
}
})
it('Should search a remote video', async function () {
const searches = [
'http://localhost:' + servers[1].port + '/w/' + videoServer2UUID,
'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
servers[1].url + '/w/' + videoServer2UUID,
servers[1].url + '/videos/watch/' + videoServer2UUID
]
for (const search of searches) {
@@ -134,7 +152,7 @@ describe('Test ActivityPub videos search', function () {
await wait(10000)
// Will run refresh async
const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
const search = servers[1].url + '/videos/watch/' + videoServer2UUID
await command.searchVideos({ search, token: servers[0].accessToken })
// Wait refresh
@@ -160,7 +178,7 @@ describe('Test ActivityPub videos search', function () {
await wait(10000)
// Will run refresh async
const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
const search = servers[1].url + '/videos/watch/' + videoServer2UUID
await command.searchVideos({ search, token: servers[0].accessToken })
// Wait refresh