]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | |
2 | ||
3 | import { expect } from 'chai' | |
4 | import { | |
5 | cleanupTests, | |
6 | createMultipleServers, | |
7 | doubleFollow, | |
8 | PeerTubeServer, | |
9 | setAccessTokensToServers, | |
10 | waitJobs | |
11 | } from '@shared/server-commands' | |
12 | ||
13 | describe('Test ActivityPub fetcher', function () { | |
14 | let servers: PeerTubeServer[] | |
15 | ||
16 | // --------------------------------------------------------------- | |
17 | ||
18 | before(async function () { | |
19 | this.timeout(60000) | |
20 | ||
21 | servers = await createMultipleServers(3) | |
22 | ||
23 | // Get the access tokens | |
24 | await setAccessTokensToServers(servers) | |
25 | ||
26 | const user = { username: 'user1', password: 'password' } | |
27 | for (const server of servers) { | |
28 | await server.users.create({ username: user.username, password: user.password }) | |
29 | } | |
30 | ||
31 | const userAccessToken = await servers[0].login.getAccessToken(user) | |
32 | ||
33 | await servers[0].videos.upload({ attributes: { name: 'video root' } }) | |
34 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } }) | |
35 | await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } }) | |
36 | ||
37 | { | |
38 | const to = 'http://localhost:' + servers[0].port + '/accounts/user1' | |
39 | const value = 'http://localhost:' + servers[1].port + '/accounts/user1' | |
40 | await servers[0].sql.setActorField(to, 'url', value) | |
41 | } | |
42 | ||
43 | { | |
44 | const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid | |
45 | await servers[0].sql.setVideoField(uuid, 'url', value) | |
46 | } | |
47 | }) | |
48 | ||
49 | it('Should add only the video with a valid actor URL', async function () { | |
50 | this.timeout(60000) | |
51 | ||
52 | await doubleFollow(servers[0], servers[1]) | |
53 | await waitJobs(servers) | |
54 | ||
55 | { | |
56 | const { total, data } = await servers[0].videos.list({ sort: 'createdAt' }) | |
57 | ||
58 | expect(total).to.equal(3) | |
59 | expect(data[0].name).to.equal('video root') | |
60 | expect(data[1].name).to.equal('bad video root') | |
61 | expect(data[2].name).to.equal('video user') | |
62 | } | |
63 | ||
64 | { | |
65 | const { total, data } = await servers[1].videos.list({ sort: 'createdAt' }) | |
66 | ||
67 | expect(total).to.equal(1) | |
68 | expect(data[0].name).to.equal('video root') | |
69 | } | |
70 | }) | |
71 | ||
72 | after(async function () { | |
73 | this.timeout(20000) | |
74 | ||
75 | await cleanupTests(servers) | |
76 | }) | |
77 | }) |