diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/videos/video-abuse.ts | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index a2f3ee161..0cd6f22c7 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts | |||
@@ -17,6 +17,12 @@ import { | |||
17 | } from '../../../../shared/extra-utils/index' | 17 | } from '../../../../shared/extra-utils/index' |
18 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 18 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
20 | import { | ||
21 | addAccountToServerBlocklist, | ||
22 | addServerToServerBlocklist, | ||
23 | removeAccountFromServerBlocklist, | ||
24 | removeServerFromServerBlocklist | ||
25 | } from '../../../../shared/extra-utils/users/blocklist' | ||
20 | 26 | ||
21 | const expect = chai.expect | 27 | const expect = chai.expect |
22 | 28 | ||
@@ -163,13 +169,76 @@ describe('Test video abuses', function () { | |||
163 | expect(res.body.data[0].moderationComment).to.equal('It is valid') | 169 | expect(res.body.data[0].moderationComment).to.equal('It is valid') |
164 | }) | 170 | }) |
165 | 171 | ||
172 | it('Should hide video abuses from blocked accounts', async function () { | ||
173 | this.timeout(10000) | ||
174 | |||
175 | { | ||
176 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') | ||
177 | await waitJobs(servers) | ||
178 | |||
179 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | ||
180 | expect(res.body.total).to.equal(3) | ||
181 | } | ||
182 | |||
183 | const accountToBlock = 'root@localhost:' + servers[1].port | ||
184 | |||
185 | { | ||
186 | await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | ||
187 | |||
188 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
189 | expect(res.body.total).to.equal(2) | ||
190 | |||
191 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | ||
192 | expect(abuse).to.be.undefined | ||
193 | } | ||
194 | |||
195 | { | ||
196 | await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | ||
197 | |||
198 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
199 | expect(res.body.total).to.equal(3) | ||
200 | } | ||
201 | }) | ||
202 | |||
203 | it('Should hide video abuses from blocked servers', async function () { | ||
204 | const serverToBlock = servers[1].host | ||
205 | |||
206 | { | ||
207 | await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host) | ||
208 | |||
209 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
210 | expect(res.body.total).to.equal(2) | ||
211 | |||
212 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | ||
213 | expect(abuse).to.be.undefined | ||
214 | } | ||
215 | |||
216 | { | ||
217 | await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock) | ||
218 | |||
219 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
220 | expect(res.body.total).to.equal(3) | ||
221 | } | ||
222 | }) | ||
223 | |||
166 | it('Should delete the video abuse', async function () { | 224 | it('Should delete the video abuse', async function () { |
225 | this.timeout(10000) | ||
226 | |||
167 | await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) | 227 | await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) |
168 | 228 | ||
169 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 229 | await waitJobs(servers) |
170 | expect(res.body.total).to.equal(0) | 230 | |
171 | expect(res.body.data).to.be.an('array') | 231 | { |
172 | expect(res.body.data.length).to.equal(0) | 232 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
233 | expect(res.body.total).to.equal(1) | ||
234 | expect(res.body.data.length).to.equal(1) | ||
235 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) | ||
236 | } | ||
237 | |||
238 | { | ||
239 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | ||
240 | expect(res.body.total).to.equal(3) | ||
241 | } | ||
173 | }) | 242 | }) |
174 | 243 | ||
175 | after(async function () { | 244 | after(async function () { |