await checkBadSortPagination(server.url, path, null, query)
})
- it('Should success with the correct parameters', async function () {
+ it('Should succeed with the correct parameters', async function () {
await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
+
+ it('Should fail with an invalid host', async function () {
+ const customQuery = { ...query, host: '6565' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should succeed with a host', async function () {
+ const customQuery = { ...query, host: 'example.com' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
+ })
})
describe('When searching video playlists', function () {
const path = '/api/v1/search/video-playlists/'
const query = {
- search: 'coucou'
+ search: 'coucou',
+ host: 'example.com'
}
it('Should fail with a bad start pagination', async function () {
await checkBadSortPagination(server.url, path, null, query)
})
- it('Should success with the correct parameters', async function () {
+ it('Should fail with an invalid host', async function () {
+ await makeGetRequest({ url: server.url, path, query: { ...query, host: '6565' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should succeed with the correct parameters', async function () {
await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
const path = '/api/v1/search/video-channels/'
const query = {
- search: 'coucou'
+ search: 'coucou',
+ host: 'example.com'
}
it('Should fail with a bad start pagination', async function () {
await checkBadSortPagination(server.url, path, null, query)
})
- it('Should success with the correct parameters', async function () {
+ it('Should fail with an invalid host', async function () {
+ await makeGetRequest({ url: server.url, path, query: { ...query, host: '6565' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should succeed with the correct parameters', async function () {
await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
import 'mocha'
import * as chai from 'chai'
import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils'
-import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
+import {
+ BooleanBothQuery,
+ VideoChannelsSearchQuery,
+ VideoPlaylistPrivacy,
+ VideoPlaylistsSearchQuery,
+ VideoPlaylistType,
+ VideosSearchQuery
+} from '@shared/models'
const expect = chai.expect
const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery }
await check(search, true)
}
+
+ {
+ const search = { ...baseSearch, host: 'example.com' }
+ await check(search, false)
+ }
+
+ {
+ const search = { ...baseSearch, host: 'framatube.org' }
+ await check(search, true)
+ }
})
it('Should have a correct pagination', async function () {
})
it('Should make a search and have results', async function () {
- const body = await command.advancedChannelSearch({ search: { search: 'Framasoft', sort: 'createdAt' } })
- expect(body.total).to.be.greaterThan(0)
- expect(body.data).to.have.length.greaterThan(0)
+ async function check (search: VideoChannelsSearchQuery, exists = true) {
+ const body = await command.advancedChannelSearch({ search })
+
+ if (exists === false) {
+ expect(body.total).to.equal(0)
+ expect(body.data).to.have.lengthOf(0)
+ return
+ }
+
+ expect(body.total).to.be.greaterThan(0)
+ expect(body.data).to.have.length.greaterThan(0)
+
+ 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')
+ expect(videoChannel.avatar).to.exist
+ expect(videoChannel.displayName).to.exist
- 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')
- expect(videoChannel.avatar).to.exist
- 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')
+ expect(videoChannel.ownerAccount.avatar).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')
- expect(videoChannel.ownerAccount.avatar).to.exist
+ await check({ search: 'Framasoft', sort: 'createdAt' }, true)
+ await check({ search: 'Framasoft', host: 'example.com' }, false)
+ await check({ search: 'Framasoft', host: 'framatube.org' }, true)
})
it('Should have a correct pagination', async function () {
})
it('Should make a search and have results', async function () {
- const body = await command.advancedPlaylistSearch({ search: { search: 'E2E playlist', sort: '-match' } })
- expect(body.total).to.be.greaterThan(0)
- expect(body.data).to.have.length.greaterThan(0)
+ async function check (search: VideoPlaylistsSearchQuery, exists = true) {
+ const body = await command.advancedPlaylistSearch({ search })
+
+ if (exists === false) {
+ expect(body.total).to.equal(0)
+ expect(body.data).to.have.lengthOf(0)
+ return
+ }
+
+ expect(body.total).to.be.greaterThan(0)
+ expect(body.data).to.have.length.greaterThan(0)
+
+ const videoPlaylist = body.data[0]
- const videoPlaylist = body.data[0]
+ expect(videoPlaylist.url).to.equal('https://peertube2.cpy.re/videos/watch/playlist/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
+ expect(videoPlaylist.thumbnailUrl).to.exist
+ expect(videoPlaylist.embedUrl).to.equal('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
- expect(videoPlaylist.url).to.equal('https://peertube2.cpy.re/videos/watch/playlist/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
- expect(videoPlaylist.thumbnailUrl).to.exist
- expect(videoPlaylist.embedUrl).to.equal('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
+ expect(videoPlaylist.type.id).to.equal(VideoPlaylistType.REGULAR)
+ expect(videoPlaylist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
+ expect(videoPlaylist.videosLength).to.exist
- expect(videoPlaylist.type.id).to.equal(VideoPlaylistType.REGULAR)
- expect(videoPlaylist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
- expect(videoPlaylist.videosLength).to.exist
+ expect(videoPlaylist.createdAt).to.exist
+ expect(videoPlaylist.updatedAt).to.exist
- expect(videoPlaylist.createdAt).to.exist
- expect(videoPlaylist.updatedAt).to.exist
+ expect(videoPlaylist.uuid).to.equal('73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
+ expect(videoPlaylist.displayName).to.exist
- expect(videoPlaylist.uuid).to.equal('73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
- expect(videoPlaylist.displayName).to.exist
+ 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')
+ expect(videoPlaylist.ownerAccount.avatar).to.exist
- 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')
- expect(videoPlaylist.ownerAccount.avatar).to.exist
+ 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')
+ expect(videoPlaylist.videoChannel.avatar).to.exist
+ }
- 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')
- expect(videoPlaylist.videoChannel.avatar).to.exist
+ await check({ search: 'E2E playlist', sort: '-match' }, true)
+ await check({ search: 'E2E playlist', host: 'example.com' }, false)
+ await check({ search: 'E2E playlist', host: 'peertube2.cpy.re' }, true)
})
it('Should have a correct pagination', async function () {