]>
Commit | Line | Data |
---|---|---|
a130f33c C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | ||
5 | import { | |
c8000975 | 6 | closeAllSequelize, |
a130f33c C |
7 | createUser, |
8 | doubleFollow, | |
9 | flushAndRunMultipleServers, | |
10 | flushTests, | |
11 | getVideosListSort, | |
12 | killallServers, | |
13 | ServerInfo, | |
14 | setAccessTokensToServers, | |
2a8c5d0a C |
15 | setActorField, |
16 | setVideoField, | |
a130f33c | 17 | uploadVideo, |
2a8c5d0a C |
18 | userLogin, |
19 | waitJobs | |
94565d52 | 20 | } from '../../../../shared/extra-utils' |
a130f33c | 21 | import * as chai from 'chai' |
a130f33c C |
22 | import { Video } from '../../../../shared/models/videos' |
23 | ||
24 | const expect = chai.expect | |
25 | ||
26 | describe('Test ActivityPub fetcher', function () { | |
27 | let servers: ServerInfo[] | |
28 | ||
29 | // --------------------------------------------------------------- | |
30 | ||
31 | before(async function () { | |
32 | this.timeout(60000) | |
33 | ||
34 | servers = await flushAndRunMultipleServers(3) | |
35 | ||
36 | // Get the access tokens | |
37 | await setAccessTokensToServers(servers) | |
38 | ||
39 | const user = { username: 'user1', password: 'password' } | |
40 | for (const server of servers) { | |
1eddc9a7 | 41 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
a130f33c C |
42 | } |
43 | ||
44 | const userAccessToken = await userLogin(servers[0], user) | |
45 | ||
46 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) | |
47 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) | |
48 | const badVideoUUID = res.body.video.uuid | |
49 | await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) | |
50 | ||
51 | await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1') | |
52 | await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID) | |
53 | }) | |
54 | ||
55 | it('Should add only the video with a valid actor URL', async function () { | |
56 | this.timeout(60000) | |
57 | ||
58 | await doubleFollow(servers[0], servers[1]) | |
59 | await waitJobs(servers) | |
60 | ||
61 | { | |
62 | const res = await getVideosListSort(servers[0].url, 'createdAt') | |
63 | expect(res.body.total).to.equal(3) | |
64 | ||
65 | const data: Video[] = res.body.data | |
66 | expect(data[0].name).to.equal('video root') | |
67 | expect(data[1].name).to.equal('bad video root') | |
68 | expect(data[2].name).to.equal('video user') | |
69 | } | |
70 | ||
71 | { | |
72 | const res = await getVideosListSort(servers[1].url, 'createdAt') | |
73 | expect(res.body.total).to.equal(1) | |
74 | ||
75 | const data: Video[] = res.body.data | |
76 | expect(data[0].name).to.equal('video root') | |
77 | } | |
78 | }) | |
79 | ||
80 | after(async function () { | |
81 | killallServers(servers) | |
82 | ||
c8000975 | 83 | await closeAllSequelize(servers) |
a130f33c C |
84 | }) |
85 | }) |