test search for subscriptions and video-channels
This commit is contained in:
parent
225a7682e6
commit
7b3909644d
|
@ -53,6 +53,7 @@ export class UserNotificationsComponent implements OnInit {
|
|||
ignoreLoadingBar: this.ignoreLoadingBar,
|
||||
sort: {
|
||||
field: this.sortField,
|
||||
// if we order by creation date, we want DESC. all other fields are ASC (like unread).
|
||||
order: this.sortField === 'createdAt' ? -1 : 1
|
||||
}
|
||||
})
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
setDefaultPagination,
|
||||
setDefaultSearchSort,
|
||||
videoChannelsSearchSortValidator,
|
||||
videoChannelsSearchValidator,
|
||||
videoChannelsListSearchValidator,
|
||||
videosSearchSortValidator,
|
||||
videosSearchValidator
|
||||
} from '../../middlewares'
|
||||
|
@ -49,7 +49,7 @@ searchRouter.get('/video-channels',
|
|||
videoChannelsSearchSortValidator,
|
||||
setDefaultSearchSort,
|
||||
optionalAuthenticate,
|
||||
videoChannelsSearchValidator,
|
||||
videoChannelsListSearchValidator,
|
||||
asyncMiddleware(searchVideoChannels)
|
||||
)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const videosSearchValidator = [
|
|||
}
|
||||
]
|
||||
|
||||
const videoChannelsSearchValidator = [
|
||||
const videoChannelsListSearchValidator = [
|
||||
query('search').not().isEmpty().withMessage('Should have a valid search'),
|
||||
query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),
|
||||
|
||||
|
@ -57,6 +57,6 @@ const videoChannelsOwnSearchValidator = [
|
|||
|
||||
export {
|
||||
videosSearchValidator,
|
||||
videoChannelsSearchValidator,
|
||||
videoChannelsListSearchValidator,
|
||||
videoChannelsOwnSearchValidator
|
||||
}
|
||||
|
|
|
@ -96,14 +96,14 @@ describe('Test users subscriptions', function () {
|
|||
|
||||
it('Should list subscriptions', async function () {
|
||||
{
|
||||
const res = await listUserSubscriptions(servers[0].url, servers[0].accessToken)
|
||||
const res = await listUserSubscriptions({ url: servers[0].url, token: servers[0].accessToken })
|
||||
expect(res.body.total).to.equal(0)
|
||||
expect(res.body.data).to.be.an('array')
|
||||
expect(res.body.data).to.have.lengthOf(0)
|
||||
}
|
||||
|
||||
{
|
||||
const res = await listUserSubscriptions(servers[0].url, users[0].accessToken, 'createdAt')
|
||||
const res = await listUserSubscriptions({ url: servers[0].url, token: users[0].accessToken, sort: 'createdAt' })
|
||||
expect(res.body.total).to.equal(2)
|
||||
|
||||
const subscriptions: VideoChannel[] = res.body.data
|
||||
|
@ -156,6 +156,34 @@ describe('Test users subscriptions', function () {
|
|||
expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false
|
||||
})
|
||||
|
||||
it('Should search among subscriptions', async function () {
|
||||
{
|
||||
const res = await listUserSubscriptions({
|
||||
url: servers[0].url,
|
||||
token: users[0].accessToken,
|
||||
sort: '-createdAt',
|
||||
search: 'user3_channel'
|
||||
})
|
||||
expect(res.body.total).to.equal(1)
|
||||
|
||||
const subscriptions = res.body.data
|
||||
expect(subscriptions).to.have.lengthOf(1)
|
||||
}
|
||||
|
||||
{
|
||||
const res = await listUserSubscriptions({
|
||||
url: servers[0].url,
|
||||
token: users[0].accessToken,
|
||||
sort: '-createdAt',
|
||||
search: 'toto'
|
||||
})
|
||||
expect(res.body.total).to.equal(0)
|
||||
|
||||
const subscriptions = res.body.data
|
||||
expect(subscriptions).to.have.lengthOf(0)
|
||||
}
|
||||
})
|
||||
|
||||
it('Should list subscription videos', async function () {
|
||||
{
|
||||
const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken)
|
||||
|
|
|
@ -421,6 +421,32 @@ describe('Test video channels', function () {
|
|||
expect(totoChannel.videosCount).to.equal(0)
|
||||
})
|
||||
|
||||
it('Should search among account video channels', async function () {
|
||||
{
|
||||
const res = await getAccountVideoChannelsList({
|
||||
url: servers[0].url,
|
||||
accountName: userInfo.account.name + '@' + userInfo.account.host,
|
||||
search: 'root'
|
||||
})
|
||||
expect(res.body.total).to.equal(1)
|
||||
|
||||
const channels = res.body.data
|
||||
expect(channels).to.have.lengthOf(1)
|
||||
}
|
||||
|
||||
{
|
||||
const res = await getAccountVideoChannelsList({
|
||||
url: servers[0].url,
|
||||
accountName: userInfo.account.name + '@' + userInfo.account.host,
|
||||
search: 'does not exist'
|
||||
})
|
||||
expect(res.body.total).to.equal(0)
|
||||
|
||||
const channels = res.body.data
|
||||
expect(channels).to.have.lengthOf(0)
|
||||
}
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await cleanupTests(servers)
|
||||
})
|
||||
|
|
|
@ -12,7 +12,14 @@ function addUserSubscription (url: string, token: string, targetUri: string, sta
|
|||
})
|
||||
}
|
||||
|
||||
function listUserSubscriptions (url: string, token: string, sort = '-createdAt', statusCodeExpected = 200) {
|
||||
function listUserSubscriptions (parameters: {
|
||||
url: string
|
||||
token: string
|
||||
sort?: string
|
||||
search?: string
|
||||
statusCodeExpected?: number
|
||||
}) {
|
||||
const { url, token, sort = '-createdAt', search, statusCodeExpected = 200 } = parameters
|
||||
const path = '/api/v1/users/me/subscriptions'
|
||||
|
||||
return makeGetRequest({
|
||||
|
@ -20,7 +27,10 @@ function listUserSubscriptions (url: string, token: string, sort = '-createdAt',
|
|||
path,
|
||||
token,
|
||||
statusCodeExpected,
|
||||
query: { sort }
|
||||
query: {
|
||||
sort,
|
||||
search
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ function getAccountVideoChannelsList (parameters: {
|
|||
sort?: string
|
||||
specialStatus?: number
|
||||
withStats?: boolean
|
||||
search?: string
|
||||
}) {
|
||||
const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200, withStats = false } = parameters
|
||||
const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200, withStats = false, search } = parameters
|
||||
|
||||
const path = '/api/v1/accounts/' + accountName + '/video-channels'
|
||||
|
||||
|
@ -44,7 +45,8 @@ function getAccountVideoChannelsList (parameters: {
|
|||
start,
|
||||
count,
|
||||
sort,
|
||||
withStats
|
||||
withStats,
|
||||
search
|
||||
},
|
||||
statusCodeExpected: specialStatus
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue