+ it('Should have these videos when listing my history', async function () {
+ video3WatchedDate = new Date()
+ await server.views.view({ id: video3UUID, token: server.accessToken, currentTime: 2 })
+
+ const body = await server.history.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 server.history.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 server.history.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 server.history.removeAll({ beforeDate: video3WatchedDate.toISOString() })
+ })
+
+ it('Should have my history cleared', async function () {
+ const body = await server.history.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 server.views.view({ id: video2UUID, token: server.accessToken, currentTime: 8 })
+
+ const { data } = await server.history.list()
+ expect(data[0].name).to.not.equal('video 2')
+ })
+
+ it('Should re-enable videos history', async function () {
+ await server.users.updateMe({
+ videosHistoryEnabled: true
+ })
+
+ await server.views.view({ id: video2UUID, token: server.accessToken, currentTime: 8 })