Add playlist updatedAt tests
This commit is contained in:
parent
76564702b7
commit
2a10aab3d7
|
@ -292,7 +292,7 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
|
||||||
videoId: video.id
|
videoId: video.id
|
||||||
}, { transaction: t })
|
}, { transaction: t })
|
||||||
|
|
||||||
videoPlaylist.updatedAt = new Date()
|
videoPlaylist.changed('updatedAt', true)
|
||||||
await videoPlaylist.save({ transaction: t })
|
await videoPlaylist.save({ transaction: t })
|
||||||
|
|
||||||
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
||||||
|
@ -332,7 +332,7 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re
|
||||||
|
|
||||||
const element = await videoPlaylistElement.save({ transaction: t })
|
const element = await videoPlaylistElement.save({ transaction: t })
|
||||||
|
|
||||||
videoPlaylist.updatedAt = new Date()
|
videoPlaylist.changed('updatedAt', true)
|
||||||
await videoPlaylist.save({ transaction: t })
|
await videoPlaylist.save({ transaction: t })
|
||||||
|
|
||||||
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
||||||
|
@ -356,7 +356,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
|
||||||
// Decrease position of the next elements
|
// Decrease position of the next elements
|
||||||
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t)
|
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t)
|
||||||
|
|
||||||
videoPlaylist.updatedAt = new Date()
|
videoPlaylist.changed('updatedAt', true)
|
||||||
await videoPlaylist.save({ transaction: t })
|
await videoPlaylist.save({ transaction: t })
|
||||||
|
|
||||||
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
||||||
|
@ -401,7 +401,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
|
||||||
// Decrease positions of elements after the old position of our ordered elements (decrease)
|
// Decrease positions of elements after the old position of our ordered elements (decrease)
|
||||||
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t)
|
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t)
|
||||||
|
|
||||||
videoPlaylist.updatedAt = new Date()
|
videoPlaylist.changed('updatedAt', true)
|
||||||
await videoPlaylist.save({ transaction: t })
|
await videoPlaylist.save({ transaction: t })
|
||||||
|
|
||||||
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
await sendUpdateVideoPlaylist(videoPlaylist, t)
|
||||||
|
|
|
@ -664,6 +664,37 @@ describe('Test video playlists', function () {
|
||||||
expect(obj[43000]).to.have.lengthOf(0)
|
expect(obj[43000]).to.have.lengthOf(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should automatically update updatedAt field of playlists', async function () {
|
||||||
|
const server = servers[1]
|
||||||
|
const videoId = servers[1].videos[5].id
|
||||||
|
|
||||||
|
async function getPlaylistNames () {
|
||||||
|
const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt')
|
||||||
|
|
||||||
|
return (res.body.data as VideoPlaylist[]).map(p => p.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
const elementAttrs = { videoId }
|
||||||
|
await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, elementAttrs })
|
||||||
|
await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, elementAttrs })
|
||||||
|
|
||||||
|
const names1 = await getPlaylistNames()
|
||||||
|
expect(names1[0]).to.equal('playlist 3 updated')
|
||||||
|
expect(names1[1]).to.equal('playlist 2')
|
||||||
|
|
||||||
|
await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, videoId })
|
||||||
|
|
||||||
|
const names2 = await getPlaylistNames()
|
||||||
|
expect(names2[0]).to.equal('playlist 2')
|
||||||
|
expect(names2[1]).to.equal('playlist 3 updated')
|
||||||
|
|
||||||
|
await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, videoId })
|
||||||
|
|
||||||
|
const names3 = await getPlaylistNames()
|
||||||
|
expect(names3[0]).to.equal('playlist 3 updated')
|
||||||
|
expect(names3[1]).to.equal('playlist 2')
|
||||||
|
})
|
||||||
|
|
||||||
it('Should delete some elements', async function () {
|
it('Should delete some elements', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,16 @@ function getAccountPlaylistsListWithToken (
|
||||||
accountName: string,
|
accountName: string,
|
||||||
start: number,
|
start: number,
|
||||||
count: number,
|
count: number,
|
||||||
playlistType?: VideoPlaylistType
|
playlistType?: VideoPlaylistType,
|
||||||
|
sort?: string
|
||||||
) {
|
) {
|
||||||
const path = '/api/v1/accounts/' + accountName + '/video-playlists'
|
const path = '/api/v1/accounts/' + accountName + '/video-playlists'
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
playlistType
|
playlistType,
|
||||||
|
sort
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user