]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/views.ts
Support live session in server
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / views.ts
index 185b04af1c3747f0bd86c7548365cd0c387aa5e7..3dba2a42e59dbb151eac3118a0fbca491698d53c 100644 (file)
@@ -19,7 +19,7 @@ describe('Test videos views', function () {
   let userAccessToken: string
 
   before(async function () {
-    this.timeout(30000)
+    this.timeout(120000)
 
     servers = await createMultipleServers(2)
     await setAccessTokensToServers(servers)
@@ -112,6 +112,54 @@ describe('Test videos views', function () {
       await servers[0].videoStats.getTimeserieStats({ videoId, metric: 'hello' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
     })
 
+    it('Should fail with an invalid start date', async function () {
+      await servers[0].videoStats.getTimeserieStats({
+        videoId,
+        metric: 'viewers',
+        startDate: 'fake' as any,
+        endDate: new Date(),
+        expectedStatus: HttpStatusCode.BAD_REQUEST_400
+      })
+    })
+
+    it('Should fail with an invalid end date', async function () {
+      await servers[0].videoStats.getTimeserieStats({
+        videoId,
+        metric: 'viewers',
+        startDate: new Date(),
+        endDate: 'fake' as any,
+        expectedStatus: HttpStatusCode.BAD_REQUEST_400
+      })
+    })
+
+    it('Should fail if start date is specified but not end date', async function () {
+      await servers[0].videoStats.getTimeserieStats({
+        videoId,
+        metric: 'viewers',
+        startDate: new Date(),
+        expectedStatus: HttpStatusCode.BAD_REQUEST_400
+      })
+    })
+
+    it('Should fail if end date is specified but not start date', async function () {
+      await servers[0].videoStats.getTimeserieStats({
+        videoId,
+        metric: 'viewers',
+        endDate: new Date(),
+        expectedStatus: HttpStatusCode.BAD_REQUEST_400
+      })
+    })
+
+    it('Should fail with a too big interval', async function () {
+      await servers[0].videoStats.getTimeserieStats({
+        videoId,
+        metric: 'viewers',
+        startDate: new Date('2021-04-07T08:31:57.126Z'),
+        endDate: new Date(),
+        expectedStatus: HttpStatusCode.BAD_REQUEST_400
+      })
+    })
+
     it('Should succeed with the correct parameters', async function () {
       await servers[0].videoStats.getTimeserieStats({ videoId, metric: 'viewers' })
     })