diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-22 16:15:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 1297eb5db651a230474670c5da1517862fb9cc3e (patch) | |
tree | ecad4a0ceb0bb09e3c775262691ac68e9e0aca0c /server/tests | |
parent | f6eebcb336c067e160a62020a5140d8d992ba384 (diff) | |
download | PeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.tar.gz PeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.tar.zst PeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.zip |
Add refresh video on search
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/index-1.ts | 2 | ||||
-rw-r--r-- | server/tests/api/index-2.ts | 2 | ||||
-rw-r--r-- | server/tests/api/index-3.ts | 1 | ||||
-rw-r--r-- | server/tests/api/index-fast.ts | 18 | ||||
-rw-r--r-- | server/tests/api/index-slow.ts | 12 | ||||
-rw-r--r-- | server/tests/api/index.ts | 5 | ||||
-rw-r--r-- | server/tests/api/search/index.ts | 2 | ||||
-rw-r--r-- | server/tests/api/search/search-activitypub-videos.ts | 161 | ||||
-rw-r--r-- | server/tests/api/server/index.ts | 8 | ||||
-rw-r--r-- | server/tests/api/users/index.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/index.ts | 15 | ||||
-rw-r--r-- | server/tests/feeds/index.ts | 1 | ||||
-rw-r--r-- | server/tests/index.ts | 3 |
13 files changed, 200 insertions, 33 deletions
diff --git a/server/tests/api/index-1.ts b/server/tests/api/index-1.ts new file mode 100644 index 000000000..80d752f42 --- /dev/null +++ b/server/tests/api/index-1.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | import './check-params' | ||
2 | import './search' | ||
diff --git a/server/tests/api/index-2.ts b/server/tests/api/index-2.ts new file mode 100644 index 000000000..ed93faa91 --- /dev/null +++ b/server/tests/api/index-2.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | import './server' | ||
2 | import './users' | ||
diff --git a/server/tests/api/index-3.ts b/server/tests/api/index-3.ts new file mode 100644 index 000000000..39823b82c --- /dev/null +++ b/server/tests/api/index-3.ts | |||
@@ -0,0 +1 @@ | |||
import './videos' | |||
diff --git a/server/tests/api/index-fast.ts b/server/tests/api/index-fast.ts deleted file mode 100644 index 02ffdd4f1..000000000 --- a/server/tests/api/index-fast.ts +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | // Order of the tests we want to execute | ||
2 | import './server/stats' | ||
3 | import './check-params' | ||
4 | import './users/users' | ||
5 | import './videos/single-server' | ||
6 | import './videos/video-abuse' | ||
7 | import './videos/video-captions' | ||
8 | import './videos/video-blacklist' | ||
9 | import './videos/video-blacklist-management' | ||
10 | import './videos/video-description' | ||
11 | import './videos/video-nsfw' | ||
12 | import './videos/video-privacy' | ||
13 | import './videos/services' | ||
14 | import './server/email' | ||
15 | import './server/config' | ||
16 | import './server/reverse-proxy' | ||
17 | import './search/search-videos' | ||
18 | import './server/tracker' | ||
diff --git a/server/tests/api/index-slow.ts b/server/tests/api/index-slow.ts deleted file mode 100644 index e24a7b664..000000000 --- a/server/tests/api/index-slow.ts +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | // Order of the tests we want to execute | ||
2 | import './videos/video-channels' | ||
3 | import './videos/video-transcoder' | ||
4 | import './videos/multiple-servers' | ||
5 | import './server/follows' | ||
6 | import './server/jobs' | ||
7 | import './videos/video-comments' | ||
8 | import './users/users-multiple-servers' | ||
9 | import './users/user-subscriptions' | ||
10 | import './server/handle-down' | ||
11 | import './videos/video-schedule-update' | ||
12 | import './videos/video-imports' | ||
diff --git a/server/tests/api/index.ts b/server/tests/api/index.ts index 258502d26..2d996dbf9 100644 --- a/server/tests/api/index.ts +++ b/server/tests/api/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './index-fast' | 2 | import './index-1' |
3 | import './index-slow' | 3 | import './index-2' |
4 | import './index-3' | ||
diff --git a/server/tests/api/search/index.ts b/server/tests/api/search/index.ts new file mode 100644 index 000000000..64b3d0910 --- /dev/null +++ b/server/tests/api/search/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | import './search-activitypub-videos' | ||
2 | import './search-videos' | ||
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts new file mode 100644 index 000000000..6dc792696 --- /dev/null +++ b/server/tests/api/search/search-activitypub-videos.ts | |||
@@ -0,0 +1,161 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | addVideoChannel, | ||
7 | flushAndRunMultipleServers, | ||
8 | flushTests, | ||
9 | getVideosList, | ||
10 | killallServers, | ||
11 | removeVideo, | ||
12 | searchVideoWithToken, | ||
13 | ServerInfo, | ||
14 | setAccessTokensToServers, | ||
15 | updateVideo, | ||
16 | uploadVideo, | ||
17 | wait, | ||
18 | searchVideo | ||
19 | } from '../../utils' | ||
20 | import { waitJobs } from '../../utils/server/jobs' | ||
21 | import { Video, VideoPrivacy } from '../../../../shared/models/videos' | ||
22 | |||
23 | const expect = chai.expect | ||
24 | |||
25 | describe('Test a ActivityPub videos search', function () { | ||
26 | let servers: ServerInfo[] | ||
27 | let videoServer1UUID: string | ||
28 | let videoServer2UUID: string | ||
29 | |||
30 | before(async function () { | ||
31 | this.timeout(120000) | ||
32 | |||
33 | await flushTests() | ||
34 | |||
35 | servers = await flushAndRunMultipleServers(2) | ||
36 | |||
37 | await setAccessTokensToServers(servers) | ||
38 | |||
39 | { | ||
40 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1 on server 1' }) | ||
41 | videoServer1UUID = res.body.video.uuid | ||
42 | } | ||
43 | |||
44 | { | ||
45 | const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 on server 2' }) | ||
46 | videoServer2UUID = res.body.video.uuid | ||
47 | } | ||
48 | |||
49 | await waitJobs(servers) | ||
50 | }) | ||
51 | |||
52 | it('Should not find a remote video', async function () { | ||
53 | { | ||
54 | const res = await searchVideoWithToken(servers[ 0 ].url, 'http://localhost:9002/videos/watch/43', servers[ 0 ].accessToken) | ||
55 | |||
56 | expect(res.body.total).to.equal(0) | ||
57 | expect(res.body.data).to.be.an('array') | ||
58 | expect(res.body.data).to.have.lengthOf(0) | ||
59 | } | ||
60 | |||
61 | { | ||
62 | const res = await searchVideo(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID) | ||
63 | |||
64 | expect(res.body.total).to.equal(0) | ||
65 | expect(res.body.data).to.be.an('array') | ||
66 | expect(res.body.data).to.have.lengthOf(0) | ||
67 | } | ||
68 | }) | ||
69 | |||
70 | it('Should search a local video', async function () { | ||
71 | const res = await searchVideo(servers[0].url, 'http://localhost:9001/videos/watch/' + videoServer1UUID) | ||
72 | |||
73 | expect(res.body.total).to.equal(1) | ||
74 | expect(res.body.data).to.be.an('array') | ||
75 | expect(res.body.data).to.have.lengthOf(1) | ||
76 | expect(res.body.data[0].name).to.equal('video 1 on server 1') | ||
77 | }) | ||
78 | |||
79 | it('Should search a remote video', async function () { | ||
80 | const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) | ||
81 | |||
82 | expect(res.body.total).to.equal(1) | ||
83 | expect(res.body.data).to.be.an('array') | ||
84 | expect(res.body.data).to.have.lengthOf(1) | ||
85 | expect(res.body.data[0].name).to.equal('video 1 on server 2') | ||
86 | }) | ||
87 | |||
88 | it('Should not list this remote video', async function () { | ||
89 | const res = await getVideosList(servers[0].url) | ||
90 | expect(res.body.total).to.equal(1) | ||
91 | expect(res.body.data).to.have.lengthOf(1) | ||
92 | expect(res.body.data[0].name).to.equal('video 1 on server 1') | ||
93 | }) | ||
94 | |||
95 | it('Should update video of server 2, and refresh it on server 1', async function () { | ||
96 | this.timeout(60000) | ||
97 | |||
98 | const channelAttributes = { | ||
99 | name: 'super_channel', | ||
100 | displayName: 'super channel' | ||
101 | } | ||
102 | const resChannel = await addVideoChannel(servers[1].url, servers[1].accessToken, channelAttributes) | ||
103 | const videoChannelId = resChannel.body.videoChannel.id | ||
104 | |||
105 | const attributes = { | ||
106 | name: 'updated', | ||
107 | tag: [ 'tag1', 'tag2' ], | ||
108 | privacy: VideoPrivacy.UNLISTED, | ||
109 | channelId: videoChannelId | ||
110 | } | ||
111 | await updateVideo(servers[1].url, servers[1].accessToken, videoServer2UUID, attributes) | ||
112 | |||
113 | await waitJobs(servers) | ||
114 | // Expire video | ||
115 | await wait(10000) | ||
116 | |||
117 | // Will run refresh async | ||
118 | await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) | ||
119 | |||
120 | // Wait refresh | ||
121 | await wait(5000) | ||
122 | |||
123 | const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) | ||
124 | expect(res.body.total).to.equal(1) | ||
125 | expect(res.body.data).to.have.lengthOf(1) | ||
126 | |||
127 | const video: Video = res.body.data[0] | ||
128 | expect(video.name).to.equal('updated') | ||
129 | expect(video.channel.name).to.equal('super_channel') | ||
130 | expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) | ||
131 | }) | ||
132 | |||
133 | it('Should delete video of server 2, and delete it on server 1', async function () { | ||
134 | this.timeout(60000) | ||
135 | |||
136 | await removeVideo(servers[1].url, servers[1].accessToken, videoServer2UUID) | ||
137 | |||
138 | await waitJobs(servers) | ||
139 | // Expire video | ||
140 | await wait(10000) | ||
141 | |||
142 | // Will run refresh async | ||
143 | await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) | ||
144 | |||
145 | // Wait refresh | ||
146 | await wait(5000) | ||
147 | |||
148 | const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) | ||
149 | expect(res.body.total).to.equal(0) | ||
150 | expect(res.body.data).to.have.lengthOf(0) | ||
151 | }) | ||
152 | |||
153 | after(async function () { | ||
154 | killallServers(servers) | ||
155 | |||
156 | // Keep the logs if the test failed | ||
157 | if (this['ok']) { | ||
158 | await flushTests() | ||
159 | } | ||
160 | }) | ||
161 | }) | ||
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts new file mode 100644 index 000000000..eeb8b7a28 --- /dev/null +++ b/server/tests/api/server/index.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | import './config' | ||
2 | import './email' | ||
3 | import './follows' | ||
4 | import './handle-down' | ||
5 | import './jobs' | ||
6 | import './reverse-proxy' | ||
7 | import './stats' | ||
8 | import './tracker' | ||
diff --git a/server/tests/api/users/index.ts b/server/tests/api/users/index.ts new file mode 100644 index 000000000..4ce87fb91 --- /dev/null +++ b/server/tests/api/users/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import './user-subscriptions' | ||
2 | import './users' | ||
3 | import './users-multiple-servers' | ||
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts new file mode 100644 index 000000000..9f1230767 --- /dev/null +++ b/server/tests/api/videos/index.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import './multiple-servers' | ||
2 | import './services' | ||
3 | import './single-server' | ||
4 | import './video-abuse' | ||
5 | import './video-blacklist' | ||
6 | import './video-blacklist-management' | ||
7 | import './video-captions' | ||
8 | import './video-channels' | ||
9 | import './video-comme' | ||
10 | import './video-description' | ||
11 | import './video-impo' | ||
12 | import './video-nsfw' | ||
13 | import './video-privacy' | ||
14 | import './video-schedule-update' | ||
15 | import './video-transcoder' | ||
diff --git a/server/tests/feeds/index.ts b/server/tests/feeds/index.ts new file mode 100644 index 000000000..aa6236a91 --- /dev/null +++ b/server/tests/feeds/index.ts | |||
@@ -0,0 +1 @@ | |||
import './feeds' | |||
diff --git a/server/tests/index.ts b/server/tests/index.ts index 755fb2604..e659fd3df 100644 --- a/server/tests/index.ts +++ b/server/tests/index.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './client' | 2 | import './client' |
3 | import './activitypub' | 3 | import './activitypub' |
4 | import './api/' | 4 | import './feeds/' |
5 | import './cli/' | 5 | import './cli/' |
6 | import './api/' | ||