aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/videos/videos-overview.ts58
1 files changed, 43 insertions, 15 deletions
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index d38bcb6eb..7889bcf80 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -1,16 +1,35 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../../../shared/extra-utils' 4import * as chai from 'chai'
6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 5
6import {
7 cleanupTests,
8 flushAndRunServer,
9 generateUserAccessToken,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo,
13 wait
14} from '../../../../shared/extra-utils'
15import { getVideosOverview, getVideosOverviewWithToken } from '../../../../shared/extra-utils/overviews/overviews'
7import { VideosOverview } from '../../../../shared/models/overviews' 16import { VideosOverview } from '../../../../shared/models/overviews'
17import { addAccountToAccountBlocklist } from '@shared/extra-utils/users/blocklist'
18import { Response } from 'superagent'
8 19
9const expect = chai.expect 20const expect = chai.expect
10 21
11describe('Test a videos overview', function () { 22describe('Test a videos overview', function () {
12 let server: ServerInfo = null 23 let server: ServerInfo = null
13 24
25 function testOverviewCount (res: Response, expected: number) {
26 const overview: VideosOverview = res.body
27
28 expect(overview.tags).to.have.lengthOf(expected)
29 expect(overview.categories).to.have.lengthOf(expected)
30 expect(overview.channels).to.have.lengthOf(expected)
31 }
32
14 before(async function () { 33 before(async function () {
15 this.timeout(30000) 34 this.timeout(30000)
16 35
@@ -22,10 +41,7 @@ describe('Test a videos overview', function () {
22 it('Should send empty overview', async function () { 41 it('Should send empty overview', async function () {
23 const res = await getVideosOverview(server.url, 1) 42 const res = await getVideosOverview(server.url, 1)
24 43
25 const overview: VideosOverview = res.body 44 testOverviewCount(res, 0)
26 expect(overview.tags).to.have.lengthOf(0)
27 expect(overview.categories).to.have.lengthOf(0)
28 expect(overview.channels).to.have.lengthOf(0)
29 }) 45 })
30 46
31 it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () { 47 it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', async function () {
@@ -41,10 +57,7 @@ describe('Test a videos overview', function () {
41 57
42 const res = await getVideosOverview(server.url, 1) 58 const res = await getVideosOverview(server.url, 1)
43 59
44 const overview: VideosOverview = res.body 60 testOverviewCount(res, 0)
45 expect(overview.tags).to.have.lengthOf(0)
46 expect(overview.categories).to.have.lengthOf(0)
47 expect(overview.channels).to.have.lengthOf(0)
48 }) 61 })
49 62
50 it('Should upload another video and include all videos in the overview', async function () { 63 it('Should upload another video and include all videos in the overview', async function () {
@@ -63,10 +76,7 @@ describe('Test a videos overview', function () {
63 { 76 {
64 const res = await getVideosOverview(server.url, 1) 77 const res = await getVideosOverview(server.url, 1)
65 78
66 const overview: VideosOverview = res.body 79 testOverviewCount(res, 1)
67 expect(overview.tags).to.have.lengthOf(1)
68 expect(overview.categories).to.have.lengthOf(1)
69 expect(overview.channels).to.have.lengthOf(1)
70 } 80 }
71 81
72 { 82 {
@@ -116,6 +126,24 @@ describe('Test a videos overview', function () {
116 expect(overview1.channels[0].channel.name).to.equal('root_channel') 126 expect(overview1.channels[0].channel.name).to.equal('root_channel')
117 }) 127 })
118 128
129 it('Should hide muted accounts', async function () {
130 const token = await generateUserAccessToken(server, 'choco')
131
132 await addAccountToAccountBlocklist(server.url, token, 'root@' + server.host)
133
134 {
135 const res = await getVideosOverview(server.url, 1)
136
137 testOverviewCount(res, 1)
138 }
139
140 {
141 const res = await getVideosOverviewWithToken(server.url, 1, token)
142
143 testOverviewCount(res, 0)
144 }
145 })
146
119 after(async function () { 147 after(async function () {
120 await cleanupTests([ server ]) 148 await cleanupTests([ server ])
121 }) 149 })