aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/index-1.ts2
-rw-r--r--server/tests/api/index-2.ts2
-rw-r--r--server/tests/api/index-3.ts1
-rw-r--r--server/tests/api/index-fast.ts18
-rw-r--r--server/tests/api/index-slow.ts12
-rw-r--r--server/tests/api/index.ts5
-rw-r--r--server/tests/api/search/index.ts2
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts161
-rw-r--r--server/tests/api/server/index.ts8
-rw-r--r--server/tests/api/users/index.ts3
-rw-r--r--server/tests/api/videos/index.ts15
11 files changed, 197 insertions, 32 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 @@
1import './check-params'
2import './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 @@
1import './server'
2import './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
2import './server/stats'
3import './check-params'
4import './users/users'
5import './videos/single-server'
6import './videos/video-abuse'
7import './videos/video-captions'
8import './videos/video-blacklist'
9import './videos/video-blacklist-management'
10import './videos/video-description'
11import './videos/video-nsfw'
12import './videos/video-privacy'
13import './videos/services'
14import './server/email'
15import './server/config'
16import './server/reverse-proxy'
17import './search/search-videos'
18import './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
2import './videos/video-channels'
3import './videos/video-transcoder'
4import './videos/multiple-servers'
5import './server/follows'
6import './server/jobs'
7import './videos/video-comments'
8import './users/users-multiple-servers'
9import './users/user-subscriptions'
10import './server/handle-down'
11import './videos/video-schedule-update'
12import './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
2import './index-fast' 2import './index-1'
3import './index-slow' 3import './index-2'
4import './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 @@
1import './search-activitypub-videos'
2import './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
3import * as chai from 'chai'
4import 'mocha'
5import {
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'
20import { waitJobs } from '../../utils/server/jobs'
21import { Video, VideoPrivacy } from '../../../../shared/models/videos'
22
23const expect = chai.expect
24
25describe('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 @@
1import './config'
2import './email'
3import './follows'
4import './handle-down'
5import './jobs'
6import './reverse-proxy'
7import './stats'
8import './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 @@
1import './user-subscriptions'
2import './users'
3import './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 @@
1import './multiple-servers'
2import './services'
3import './single-server'
4import './video-abuse'
5import './video-blacklist'
6import './video-blacklist-management'
7import './video-captions'
8import './video-channels'
9import './video-comme'
10import './video-description'
11import './video-impo'
12import './video-nsfw'
13import './video-privacy'
14import './video-schedule-update'
15import './video-transcoder'