+ const body = await command.list()
+
+ expect(body.total).to.equal(3)
+
+ const videos = 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 body = await command.list({ token: userAccessToken })
+
+ expect(body.total).to.equal(0)
+ expect(body.data).to.have.lengthOf(0)
+ })
+
+ it('Should be able to search through videos in my history', async function () {
+ const body = await command.list({ search: '2' })
+ expect(body.total).to.equal(1)
+
+ const videos = body.data
+ expect(videos[0].name).to.equal('video 2')
+ })
+
+ it('Should clear my history', async function () {
+ await command.remove({ beforeDate: video3WatchedDate.toISOString() })
+ })
+
+ it('Should have my history cleared', async function () {
+ const body = await command.list()
+ expect(body.total).to.equal(1)
+
+ const videos = body.data
+ expect(videos[0].name).to.equal('video 3')
+ })
+
+ it('Should disable videos history', async function () {
+ await server.users.updateMe({
+ videosHistoryEnabled: false
+ })
+
+ await command.wathVideo({ videoId: video2UUID, currentTime: 8, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ })
+
+ it('Should re-enable videos history', async function () {
+ await server.users.updateMe({
+ videosHistoryEnabled: true
+ })
+
+ await command.wathVideo({ videoId: video1UUID, currentTime: 8 })
+
+ const body = await command.list()
+ expect(body.total).to.equal(2)
+
+ const videos = 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)
+
+ await killallServers([ server ])
+
+ await server.run({ history: { videos: { max_age: '10 days' } } })
+
+ await wait(6000)
+
+ // Should still have history
+
+ const body = await command.list()
+ expect(body.total).to.equal(2)
+ })
+
+ it('Should clean old history', async function () {
+ this.timeout(50000)
+
+ await killallServers([ server ])
+
+ await server.run({ history: { videos: { max_age: '5 seconds' } } })
+
+ await wait(6000)
+
+ const body = await command.list()
+ expect(body.total).to.equal(0)
+ })
+
+ after(async function () {
+ await cleanupTests([ server ])