X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fsearch%2Fsearch-index.ts;h=21473b6bf0a02e991996b7dadbd321204a490a36;hb=17ecdf61ce1d374cc8ba17601b93c9bda08112b2;hp=4c8b1f6084ccd6c81afa51d135c6cf1c236ea86f;hpb=56d07460b5fe55cc86501742e759d9711d7eb386;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index 4c8b1f608..21473b6bf 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -1,8 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' -import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' +import { expect } from 'chai' import { BooleanBothQuery, VideoChannelsSearchQuery, @@ -11,10 +9,9 @@ import { VideoPlaylistType, VideosSearchQuery } from '@shared/models' +import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/server-commands' -const expect = chai.expect - -describe('Test videos search', function () { +describe('Test index search', function () { const localVideoName = 'local video' + new Date().toISOString() let server: PeerTubeServer = null @@ -35,8 +32,6 @@ describe('Test videos search', function () { describe('Default search', async function () { it('Should make a local videos search by default', async function () { - this.timeout(10000) - await server.config.updateCustomSubConfig({ newConfig: { search: { @@ -60,7 +55,7 @@ describe('Test videos search', function () { expect(body.total).to.equal(1) expect(body.data[0].name).to.equal('root_channel') - expect(body.data[0].host).to.equal('localhost:' + server.port) + expect(body.data[0].host).to.equal(server.host) }) it('Should make an index videos search by default', async function () { @@ -84,28 +79,6 @@ describe('Test videos search', function () { const body = await command.searchChannels({ search: 'root' }) expect(body.total).to.be.greaterThan(2) }) - - it('Should make an index videos search if local search is disabled', async function () { - await server.config.updateCustomSubConfig({ - newConfig: { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: false, - disableLocalSearch: true - } - } - } - }) - - const body = await command.searchVideos({ search: 'local video' }) - expect(body.total).to.be.greaterThan(2) - }) - - it('Should make an index channels search if local search is disabled', async function () { - const body = await command.searchChannels({ search: 'root' }) - expect(body.total).to.be.greaterThan(2) - }) }) describe('Videos search', async function () { @@ -134,12 +107,16 @@ describe('Test videos search', function () { expect(video.account.host).to.equal('framatube.org') expect(video.account.name).to.equal('framasoft') expect(video.account.url).to.equal('https://framatube.org/accounts/framasoft') + // TODO: remove, deprecated in 4.2 expect(video.account.avatar).to.exist + expect(video.account.avatars.length).to.equal(2, 'Account should have one avatar image') expect(video.channel.host).to.equal('framatube.org') - expect(video.channel.name).to.equal('bf54d359-cfad-4935-9d45-9d6be93f63e8') - expect(video.channel.url).to.equal('https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8') + expect(video.channel.name).to.equal('joinpeertube') + expect(video.channel.url).to.equal('https://framatube.org/video-channels/joinpeertube') + // TODO: remove, deprecated in 4.2 expect(video.channel.avatar).to.exist + expect(video.channel.avatars.length).to.equal(2, 'Channel should have one avatar image') } const baseSearch: VideosSearchQuery = { @@ -316,13 +293,17 @@ describe('Test videos search', function () { const videoChannel = body.data[0] expect(videoChannel.url).to.equal('https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8') expect(videoChannel.host).to.equal('framatube.org') + // TODO: remove, deprecated in 4.2 expect(videoChannel.avatar).to.exist + expect(videoChannel.avatars.length).to.equal(2, 'Channel should have two avatar images') expect(videoChannel.displayName).to.exist expect(videoChannel.ownerAccount.url).to.equal('https://framatube.org/accounts/framasoft') expect(videoChannel.ownerAccount.name).to.equal('framasoft') expect(videoChannel.ownerAccount.host).to.equal('framatube.org') + // TODO: remove, deprecated in 4.2 expect(videoChannel.ownerAccount.avatar).to.exist + expect(videoChannel.ownerAccount.avatars.length).to.equal(2, 'Account should have two avatar images') } it('Should make a simple search and not have results', async function () { @@ -337,8 +318,8 @@ describe('Test videos search', function () { }) 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) + await check({ search: 'Framasoft videos', host: 'example.com' }, false) + await check({ search: 'Framasoft videos', host: 'framatube.org' }, true) }) it('Should make handles search and have appropriate results', async function () { @@ -388,12 +369,16 @@ describe('Test videos search', function () { expect(videoPlaylist.ownerAccount.url).to.equal('https://peertube2.cpy.re/accounts/chocobozzz') expect(videoPlaylist.ownerAccount.name).to.equal('chocobozzz') expect(videoPlaylist.ownerAccount.host).to.equal('peertube2.cpy.re') + // TODO: remove, deprecated in 4.2 expect(videoPlaylist.ownerAccount.avatar).to.exist + expect(videoPlaylist.ownerAccount.avatars.length).to.equal(2, 'Account should have two avatar images') expect(videoPlaylist.videoChannel.url).to.equal('https://peertube2.cpy.re/video-channels/chocobozzz_channel') expect(videoPlaylist.videoChannel.name).to.equal('chocobozzz_channel') expect(videoPlaylist.videoChannel.host).to.equal('peertube2.cpy.re') + // TODO: remove, deprecated in 4.2 expect(videoPlaylist.videoChannel.avatar).to.exist + expect(videoPlaylist.videoChannel.avatars.length).to.equal(2, 'Channel should have two avatar images') } it('Should make a simple search and not have results', async function () {