aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/activitypub/fetch.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/activitypub/fetch.ts')
-rw-r--r--server/tests/api/activitypub/fetch.ts33
1 files changed, 10 insertions, 23 deletions
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 162f3ec83..5ab4a85d7 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -2,17 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
6 cleanupTests,
7 doubleFollow,
8 flushAndRunMultipleServers,
9 getVideosListSort,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo,
13 waitJobs
14} from '../../../../shared/extra-utils'
15import { Video } from '../../../../shared/models/videos'
16 6
17const expect = chai.expect 7const expect = chai.expect
18 8
@@ -36,10 +26,9 @@ describe('Test ActivityPub fetcher', function () {
36 26
37 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 27 const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
38 28
39 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) 29 await servers[0].videosCommand.upload({ attributes: { name: 'video root' } })
40 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) 30 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'bad video root' } })
41 const badVideoUUID = res.body.video.uuid 31 await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'video user' } })
42 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
43 32
44 { 33 {
45 const to = 'http://localhost:' + servers[0].port + '/accounts/user1' 34 const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
@@ -48,8 +37,8 @@ describe('Test ActivityPub fetcher', function () {
48 } 37 }
49 38
50 { 39 {
51 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID 40 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid
52 await servers[0].sqlCommand.setVideoField(badVideoUUID, 'url', value) 41 await servers[0].sqlCommand.setVideoField(uuid, 'url', value)
53 } 42 }
54 }) 43 })
55 44
@@ -60,20 +49,18 @@ describe('Test ActivityPub fetcher', function () {
60 await waitJobs(servers) 49 await waitJobs(servers)
61 50
62 { 51 {
63 const res = await getVideosListSort(servers[0].url, 'createdAt') 52 const { total, data } = await servers[0].videosCommand.list({ sort: 'createdAt' })
64 expect(res.body.total).to.equal(3)
65 53
66 const data: Video[] = res.body.data 54 expect(total).to.equal(3)
67 expect(data[0].name).to.equal('video root') 55 expect(data[0].name).to.equal('video root')
68 expect(data[1].name).to.equal('bad video root') 56 expect(data[1].name).to.equal('bad video root')
69 expect(data[2].name).to.equal('video user') 57 expect(data[2].name).to.equal('video user')
70 } 58 }
71 59
72 { 60 {
73 const res = await getVideosListSort(servers[1].url, 'createdAt') 61 const { total, data } = await servers[1].videosCommand.list({ sort: 'createdAt' })
74 expect(res.body.total).to.equal(1)
75 62
76 const data: Video[] = res.body.data 63 expect(total).to.equal(1)
77 expect(data[0].name).to.equal('video root') 64 expect(data[0].name).to.equal('video root')
78 } 65 }
79 }) 66 })