import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/models'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, Video } from '@shared/models'
import {
cleanupTests,
createSingleServer,
HistoryCommand,
killallServers,
PeerTubeServer,
- setAccessTokensToServers,
- wait
-} from '@shared/extra-utils'
-import { Video } from '@shared/models'
+ setAccessTokensToServers
+} from '@shared/server-commands'
const expect = chai.expect
describe('Test videos history', function () {
let server: PeerTubeServer = null
+ let video1Id: number
let video1UUID: string
let video2UUID: string
let video3UUID: string
command = server.history
{
- const { uuid } = await server.videos.upload({ attributes: { name: 'video 1' } })
+ const { id, uuid } = await server.videos.upload({ attributes: { name: 'video 1' } })
video1UUID = uuid
+ video1Id = id
}
{
})
it('Should watch the first and second video', async function () {
- await command.wathVideo({ videoId: video2UUID, currentTime: 8 })
- await command.wathVideo({ videoId: video1UUID, currentTime: 3 })
+ await command.watchVideo({ videoId: video2UUID, currentTime: 8 })
+ await command.watchVideo({ videoId: video1UUID, currentTime: 3 })
})
it('Should return the correct history when listing, searching and getting videos', async function () {
it('Should have these videos when listing my history', async function () {
video3WatchedDate = new Date()
- await command.wathVideo({ videoId: video3UUID, currentTime: 2 })
+ await command.watchVideo({ videoId: video3UUID, currentTime: 2 })
const body = await command.list()
})
it('Should clear my history', async function () {
- await command.remove({ beforeDate: video3WatchedDate.toISOString() })
+ await command.removeAll({ beforeDate: video3WatchedDate.toISOString() })
})
it('Should have my history cleared', async function () {
videosHistoryEnabled: false
})
- await command.wathVideo({ videoId: video2UUID, currentTime: 8, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ await command.watchVideo({ videoId: video2UUID, currentTime: 8, expectedStatus: HttpStatusCode.CONFLICT_409 })
})
it('Should re-enable videos history', async function () {
videosHistoryEnabled: true
})
- await command.wathVideo({ videoId: video1UUID, currentTime: 8 })
+ await command.watchVideo({ videoId: video1UUID, currentTime: 8 })
const body = await command.list()
expect(body.total).to.equal(2)
expect(body.total).to.equal(0)
})
+ it('Should delete a specific history element', async function () {
+ {
+ await command.watchVideo({ videoId: video1UUID, currentTime: 4 })
+ await command.watchVideo({ videoId: video2UUID, currentTime: 8 })
+ }
+
+ {
+ const body = await command.list()
+ expect(body.total).to.equal(2)
+ }
+
+ {
+ await command.removeElement({ videoId: video1Id })
+
+ const body = await command.list()
+ expect(body.total).to.equal(1)
+ expect(body.data[0].uuid).to.equal(video2UUID)
+ }
+ })
+
after(async function () {
await cleanupTests([ server ])
})