Update search index tests

pull/4300/head
Chocobozzz 2021-07-29 13:40:16 +02:00
parent 20c7087689
commit 56d07460b5
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 119 additions and 110 deletions

View File

@ -110,21 +110,6 @@ describe('Test videos search', function () {
describe('Videos search', async function () {
it('Should make a simple search and not have results', async function () {
const body = await command.searchVideos({ search: 'djidane'.repeat(50) })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
})
it('Should make a simple search and have results', async function () {
const body = await command.searchVideos({ search: 'What is PeerTube' })
expect(body.total).to.be.greaterThan(1)
})
it('Should make a complex search', async function () {
async function check (search: VideosSearchQuery, exists = true) {
const body = await command.advancedVideoSearch({ search })
@ -168,25 +153,39 @@ describe('Test videos search', function () {
endDate: '2018-10-01T10:55:46.396Z'
}
{
await check(baseSearch)
}
it('Should make a simple search and not have results', async function () {
const body = await command.searchVideos({ search: 'djidane'.repeat(50) })
{
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
})
it('Should make a simple search and have results', async function () {
const body = await command.searchVideos({ search: 'What is PeerTube' })
expect(body.total).to.be.greaterThan(1)
})
it('Should make a simple search', async function () {
await check(baseSearch)
})
it('Should search by start date', async function () {
const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' }
await check(search, false)
}
})
{
it('Should search by tags', async function () {
const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] }
await check(search, false)
}
})
{
it('Should search by duration', async function () {
const search = { ...baseSearch, durationMin: 2000 }
await check(search, false)
}
})
it('Should search by nsfw attribute', async function () {
{
const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery }
await check(search, false)
@ -201,7 +200,9 @@ describe('Test videos search', function () {
const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery }
await check(search, true)
}
})
it('Should search by host', async function () {
{
const search = { ...baseSearch, host: 'example.com' }
await check(search, false)
@ -211,8 +212,9 @@ describe('Test videos search', function () {
const search = { ...baseSearch, host: 'framatube.org' }
await check(search, true)
}
})
{
it('Should search by uuids', async function () {
const goodUUID = '9c9de5e8-0a1e-484a-b099-e80766180a6d'
const goodShortUUID = 'kkGMgK9ZtnKfYAgnEtQxbv'
const badUUID = 'c29c5b77-4a04-493d-96a9-2e9267e308f0'
@ -243,7 +245,6 @@ describe('Test videos search', function () {
await check(search, false)
}
}
}
})
it('Should have a correct pagination', async function () {
@ -300,15 +301,6 @@ describe('Test videos search', function () {
describe('Channels search', async function () {
it('Should make a simple search and not have results', async function () {
const body = await command.searchChannels({ search: 'a'.repeat(500) })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
})
it('Should make a search and have results', async function () {
async function check (search: VideoChannelsSearchQuery, exists = true) {
const body = await command.advancedChannelSearch({ search })
@ -333,11 +325,28 @@ describe('Test videos search', function () {
expect(videoChannel.ownerAccount.avatar).to.exist
}
it('Should make a simple search and not have results', async function () {
const body = await command.searchChannels({ search: 'a'.repeat(500) })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
})
it('Should make a search and have results', async function () {
await check({ search: 'Framasoft', sort: 'createdAt' }, true)
})
it('Should make host search and have appropriate results', async function () {
await check({ search: 'Framasoft', host: 'example.com' }, false)
await check({ search: 'Framasoft', host: 'framatube.org' }, true)
})
it('Should make handles search and have appropriate results', async function () {
await check({ handles: [ 'bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org' ] }, true)
await check({ handles: [ 'jeanine', 'bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org' ] }, true)
await check({ handles: [ 'jeanine', 'chocobozzz_channel2@peertube2.cpy.re' ] }, false)
})
it('Should have a correct pagination', async function () {
const body = await command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } })