addVideoChannel,
addVideoInPlaylist,
checkPlaylistFilesWereRemoved,
+ cleanupTests,
createUser,
createVideoPlaylist,
deleteVideoChannel,
deleteVideoPlaylist,
- doubleFollow, doVideosExistInMyPlaylist,
+ doubleFollow,
+ doVideosExistInMyPlaylist,
flushAndRunMultipleServers,
- flushTests,
getAccountPlaylistsList,
getAccountPlaylistsListWithToken,
+ getMyUserInformation,
getPlaylistVideos,
getVideoChannelPlaylistsList,
getVideoPlaylist,
getVideoPlaylistPrivacies,
getVideoPlaylistsList,
getVideoPlaylistWithToken,
- killallServers,
removeUser,
removeVideoFromPlaylist,
reorderVideosPlaylist,
uploadVideoAndGetId,
userLogin,
waitJobs
-} from '../../../../shared/utils'
+} from '../../../../shared/extra-utils'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model'
import { Video } from '../../../../shared/models/videos'
import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
+import { User } from '../../../../shared/models/users'
const expect = chai.expect
token: servers[1].accessToken,
playlistAttrs: {
displayName: 'playlist 2',
- privacy: VideoPlaylistPrivacy.PUBLIC
+ privacy: VideoPlaylistPrivacy.PUBLIC,
+ videoChannelId: servers[1].videoChannel.id
}
})
playlistServer2Id1 = res.body.videoPlaylist.id
playlistAttrs: {
displayName: 'playlist 3',
privacy: VideoPlaylistPrivacy.PUBLIC,
- thumbnailfile: 'thumbnail.jpg'
+ thumbnailfile: 'thumbnail.jpg',
+ videoChannelId: servers[1].videoChannel.id
}
})
for (const server of servers) {
const results = [
- await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'),
+ await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),
await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
]
token: servers[ 0 ].accessToken,
playlistAttrs: {
displayName: 'playlist 4',
- privacy: VideoPlaylistPrivacy.PUBLIC
+ privacy: VideoPlaylistPrivacy.PUBLIC,
+ videoChannelId: servers[0].videoChannel.id
}
})
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 () {
this.timeout(30000)
this.timeout(30000)
for (const server of servers) {
- await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)
+ await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)
}
})
this.timeout(30000)
const user = { username: 'user_1', password: 'password' }
- const res = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
+ const res = await createUser({
+ url: servers[ 0 ].url,
+ accessToken: servers[ 0 ].accessToken,
+ username: user.username,
+ password: user.password
+ })
const userId = res.body.user.id
const userAccessToken = await userLogin(servers[0], user)
+ const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
+ const userChannel = (resChannel.body as User).videoChannels[0]
+
await createVideoPlaylist({
url: servers[0].url,
token: userAccessToken,
playlistAttrs: {
displayName: 'playlist to be deleted',
- privacy: VideoPlaylistPrivacy.PUBLIC
+ privacy: VideoPlaylistPrivacy.PUBLIC,
+ videoChannelId: userChannel.id
}
})
})
after(async function () {
- killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ await cleanupTests(servers)
})
})