+ this.timeout(30000)
+
+ await updateVideoPlaylistElement({
+ url: servers[0].url,
+ token: servers[0].accessToken,
+ playlistId: playlistServer1Id,
+ videoId: servers[0].videos[3].uuid,
+ elementAttrs: {
+ startTimestamp: 1
+ }
+ })
+
+ await updateVideoPlaylistElement({
+ url: servers[0].url,
+ token: servers[0].accessToken,
+ playlistId: playlistServer1Id,
+ videoId: servers[0].videos[4].uuid,
+ elementAttrs: {
+ stopTimestamp: null
+ }
+ })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getPlaylistVideos(server.url, server.accessToken, playlistServer1UUID, 0, 10)
+ const videos: Video[] = res.body.data
+
+ expect(videos[0].name).to.equal('video 3 server 1')
+ expect(videos[0].playlistElement.position).to.equal(1)
+ expect(videos[0].playlistElement.startTimestamp).to.equal(1)
+ expect(videos[0].playlistElement.stopTimestamp).to.equal(35)
+
+ expect(videos[5].name).to.equal('video 4 server 1')
+ expect(videos[5].playlistElement.position).to.equal(6)
+ expect(videos[5].playlistElement.startTimestamp).to.equal(45)
+ expect(videos[5].playlistElement.stopTimestamp).to.be.null
+ }
+ })
+
+ it('Should check videos existence in my playlist', async function () {
+ const videoIds = [
+ servers[0].videos[0].id,
+ 42000,
+ servers[0].videos[3].id,
+ 43000,
+ servers[0].videos[4].id
+ ]
+ const res = await doVideosExistInMyPlaylist(servers[ 0 ].url, servers[ 0 ].accessToken, videoIds)
+ const obj = res.body as VideoExistInPlaylist
+
+ {
+ const elem = obj[servers[0].videos[0].id]
+ expect(elem).to.have.lengthOf(1)
+ expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
+ expect(elem[ 0 ].startTimestamp).to.equal(15)
+ expect(elem[ 0 ].stopTimestamp).to.equal(28)
+ }
+
+ {
+ const elem = obj[servers[0].videos[3].id]
+ expect(elem).to.have.lengthOf(1)
+ expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
+ expect(elem[ 0 ].startTimestamp).to.equal(1)
+ expect(elem[ 0 ].stopTimestamp).to.equal(35)
+ }
+
+ {
+ const elem = obj[servers[0].videos[4].id]
+ expect(elem).to.have.lengthOf(1)
+ expect(elem[ 0 ].playlistId).to.equal(playlistServer1Id)
+ expect(elem[ 0 ].startTimestamp).to.equal(45)
+ expect(elem[ 0 ].stopTimestamp).to.equal(null)
+ }
+
+ expect(obj[42000]).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')