+ it('Should have these videos when listing my history', async function () {
+ video3WatchedDate = new Date()
+ await userWatchVideo(server.url, server.accessToken, video3UUID, 2)
+
+ const res = await listMyVideosHistory(server.url, server.accessToken)
+
+ expect(res.body.total).to.equal(3)
+
+ const videos: Video[] = res.body.data
+ expect(videos[0].name).to.equal('video 3')
+ expect(videos[1].name).to.equal('video 1')
+ expect(videos[2].name).to.equal('video 2')
+ })
+
+ it('Should not have videos history on another user', async function () {
+ const res = await listMyVideosHistory(server.url, userAccessToken)
+
+ expect(res.body.total).to.equal(0)
+ expect(res.body.data).to.have.lengthOf(0)
+ })
+
+ it('Should be able to search through videos in my history', async function () {
+ const res = await listMyVideosHistory(server.url, server.accessToken, '2')
+
+ expect(res.body.total).to.equal(1)
+
+ const videos: Video[] = res.body.data
+ expect(videos[0].name).to.equal('video 2')
+ })
+
+ it('Should clear my history', async function () {
+ await removeMyVideosHistory(server.url, server.accessToken, video3WatchedDate.toISOString())
+ })
+
+ it('Should have my history cleared', async function () {
+ const res = await listMyVideosHistory(server.url, server.accessToken)
+
+ expect(res.body.total).to.equal(1)
+
+ const videos: Video[] = res.body.data
+ expect(videos[0].name).to.equal('video 3')
+ })
+
+ it('Should disable videos history', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: server.accessToken,
+ videosHistoryEnabled: false
+ })
+
+ await userWatchVideo(server.url, server.accessToken, video2UUID, 8, HttpStatusCode.CONFLICT_409)
+ })
+
+ it('Should re-enable videos history', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: server.accessToken,
+ videosHistoryEnabled: true
+ })
+
+ await userWatchVideo(server.url, server.accessToken, video1UUID, 8)
+
+ const res = await listMyVideosHistory(server.url, server.accessToken)
+
+ expect(res.body.total).to.equal(2)
+
+ const videos: Video[] = res.body.data
+ expect(videos[0].name).to.equal('video 1')
+ expect(videos[1].name).to.equal('video 3')
+ })
+
+ it('Should not clean old history', async function () {
+ this.timeout(50000)
+