aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-history.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-01-18 11:23:41 +0100
committerChocobozzz <me@florianbigard.com>2022-01-18 11:23:41 +0100
commit7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180 (patch)
tree016cb0d966fe9fea8a6381eb246e966f5c4eae57 /server/tests/api/videos/videos-history.ts
parent3b83faccfffc13adaef0b63c211b1ce4944e8b3b (diff)
downloadPeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.gz
PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.zst
PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.zip
Add ability to delete history element
Diffstat (limited to 'server/tests/api/videos/videos-history.ts')
-rw-r--r--server/tests/api/videos/videos-history.ts36
1 files changed, 29 insertions, 7 deletions
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 4e5ba13aa..8648c97f0 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -17,6 +17,7 @@ const expect = chai.expect
17 17
18describe('Test videos history', function () { 18describe('Test videos history', function () {
19 let server: PeerTubeServer = null 19 let server: PeerTubeServer = null
20 let video1Id: number
20 let video1UUID: string 21 let video1UUID: string
21 let video2UUID: string 22 let video2UUID: string
22 let video3UUID: string 23 let video3UUID: string
@@ -34,8 +35,9 @@ describe('Test videos history', function () {
34 command = server.history 35 command = server.history
35 36
36 { 37 {
37 const { uuid } = await server.videos.upload({ attributes: { name: 'video 1' } }) 38 const { id, uuid } = await server.videos.upload({ attributes: { name: 'video 1' } })
38 video1UUID = uuid 39 video1UUID = uuid
40 video1Id = id
39 } 41 }
40 42
41 { 43 {
@@ -68,8 +70,8 @@ describe('Test videos history', function () {
68 }) 70 })
69 71
70 it('Should watch the first and second video', async function () { 72 it('Should watch the first and second video', async function () {
71 await command.wathVideo({ videoId: video2UUID, currentTime: 8 }) 73 await command.watchVideo({ videoId: video2UUID, currentTime: 8 })
72 await command.wathVideo({ videoId: video1UUID, currentTime: 3 }) 74 await command.watchVideo({ videoId: video1UUID, currentTime: 3 })
73 }) 75 })
74 76
75 it('Should return the correct history when listing, searching and getting videos', async function () { 77 it('Should return the correct history when listing, searching and getting videos', async function () {
@@ -122,7 +124,7 @@ describe('Test videos history', function () {
122 124
123 it('Should have these videos when listing my history', async function () { 125 it('Should have these videos when listing my history', async function () {
124 video3WatchedDate = new Date() 126 video3WatchedDate = new Date()
125 await command.wathVideo({ videoId: video3UUID, currentTime: 2 }) 127 await command.watchVideo({ videoId: video3UUID, currentTime: 2 })
126 128
127 const body = await command.list() 129 const body = await command.list()
128 130
@@ -150,7 +152,7 @@ describe('Test videos history', function () {
150 }) 152 })
151 153
152 it('Should clear my history', async function () { 154 it('Should clear my history', async function () {
153 await command.remove({ beforeDate: video3WatchedDate.toISOString() }) 155 await command.removeAll({ beforeDate: video3WatchedDate.toISOString() })
154 }) 156 })
155 157
156 it('Should have my history cleared', async function () { 158 it('Should have my history cleared', async function () {
@@ -166,7 +168,7 @@ describe('Test videos history', function () {
166 videosHistoryEnabled: false 168 videosHistoryEnabled: false
167 }) 169 })
168 170
169 await command.wathVideo({ videoId: video2UUID, currentTime: 8, expectedStatus: HttpStatusCode.CONFLICT_409 }) 171 await command.watchVideo({ videoId: video2UUID, currentTime: 8, expectedStatus: HttpStatusCode.CONFLICT_409 })
170 }) 172 })
171 173
172 it('Should re-enable videos history', async function () { 174 it('Should re-enable videos history', async function () {
@@ -174,7 +176,7 @@ describe('Test videos history', function () {
174 videosHistoryEnabled: true 176 videosHistoryEnabled: true
175 }) 177 })
176 178
177 await command.wathVideo({ videoId: video1UUID, currentTime: 8 }) 179 await command.watchVideo({ videoId: video1UUID, currentTime: 8 })
178 180
179 const body = await command.list() 181 const body = await command.list()
180 expect(body.total).to.equal(2) 182 expect(body.total).to.equal(2)
@@ -212,6 +214,26 @@ describe('Test videos history', function () {
212 expect(body.total).to.equal(0) 214 expect(body.total).to.equal(0)
213 }) 215 })
214 216
217 it('Should delete a specific history element', async function () {
218 {
219 await command.watchVideo({ videoId: video1UUID, currentTime: 4 })
220 await command.watchVideo({ videoId: video2UUID, currentTime: 8 })
221 }
222
223 {
224 const body = await command.list()
225 expect(body.total).to.equal(2)
226 }
227
228 {
229 await command.removeElement({ videoId: video1Id })
230
231 const body = await command.list()
232 expect(body.total).to.equal(1)
233 expect(body.data[0].uuid).to.equal(video2UUID)
234 }
235 })
236
215 after(async function () { 237 after(async function () {
216 await cleanupTests([ server ]) 238 await cleanupTests([ server ])
217 }) 239 })