+ it('Should update the element type if the video is blacklisted', async function () {
+ this.timeout(20000)
+
+ const name = 'video 89'
+ const position = 1
+
+ {
+ await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ await checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.DELETED, position, name, 3)
+ }
+
+ {
+ await servers[0].blacklist.remove({ videoId: video1 })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ await checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ await checkPlaylistElementType(group1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ // We deleted the video (because unfederated), so even if we recreated it, the old entry is still deleted
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.DELETED, position, name, 3)
+ }
+ })
+
+ it('Should update the element type if the account or server of the video is blocked', async function () {
+ this.timeout(90000)
+
+ const command = servers[0].blocklist
+
+ const name = 'video 90'
+ const position = 2
+
+ {
+ await command.addToMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+
+ await command.removeFromMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ }
+
+ {
+ await command.addToMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+
+ await command.removeFromMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ }
+
+ {
+ await command.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+
+ await command.removeFromServerBlocklist({ account: 'root@localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ }
+
+ {
+ await command.addToServerBlocklist({ server: 'localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3)
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+
+ await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port })
+ await waitJobs(servers)
+
+ await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
+ }
+ })
+
+ it('Should hide the video if it is NSFW', async function () {
+ const body = await commands[0].listVideos({ token: userTokenServer1, playlistId: playlistServer1UUID2, query: { nsfw: 'false' } })
+ expect(body.total).to.equal(3)
+
+ const elements = body.data
+ const element = elements.find(e => e.position === 3)
+
+ expect(element).to.exist
+ expect(element.video).to.be.null
+ expect(element.type).to.equal(VideoPlaylistElementType.UNAVAILABLE)
+ })
+
+ })
+
+ describe('Managing playlist elements', function () {
+
+ it('Should reorder the playlist', async function () {
+ this.timeout(30000)
+
+ {
+ await commands[0].reorderElements({
+ playlistId: playlistServer1Id,
+ attributes: {
+ startPosition: 2,
+ insertAfterPosition: 3
+ }
+ })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const names = body.data.map(v => v.video.name)
+
+ expect(names).to.deep.equal([
+ 'video 0 server 1',
+ 'video 2 server 3',
+ 'video 1 server 3',
+ 'video 3 server 1',
+ 'video 4 server 1',
+ 'NSFW video',
+ 'NSFW video',
+ 'NSFW video'
+ ])