diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 15:22:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | af971e06c620bd46a5aa64c8833364e7022b5e3d (patch) | |
tree | 4288b66b79fe4dd1ab9496e85a3abf7d747ad03a /server/tests/api/search/search-activitypub-video-channels.ts | |
parent | 23a3a8827cb8b862f5cc7ee2819f39918303beca (diff) | |
download | PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.gz PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.zst PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.zip |
Introduce search command
Diffstat (limited to 'server/tests/api/search/search-activitypub-video-channels.ts')
-rw-r--r-- | server/tests/api/search/search-activitypub-video-channels.ts | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index e83eb7171..cf5158b66 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { | 5 | import { |
6 | addVideoChannel, | 6 | addVideoChannel, |
7 | cleanupTests, | 7 | cleanupTests, |
@@ -10,6 +10,7 @@ import { | |||
10 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
11 | getVideoChannelsList, | 11 | getVideoChannelsList, |
12 | getVideoChannelVideos, | 12 | getVideoChannelVideos, |
13 | SearchCommand, | ||
13 | ServerInfo, | 14 | ServerInfo, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | updateMyUser, | 16 | updateMyUser, |
@@ -17,11 +18,10 @@ import { | |||
17 | updateVideoChannel, | 18 | updateVideoChannel, |
18 | uploadVideo, | 19 | uploadVideo, |
19 | userLogin, | 20 | userLogin, |
20 | wait | 21 | wait, |
21 | } from '../../../../shared/extra-utils' | 22 | waitJobs |
22 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 23 | } from '@shared/extra-utils' |
23 | import { VideoChannel } from '../../../../shared/models/videos' | 24 | import { VideoChannel } from '@shared/models' |
24 | import { searchVideoChannel } from '../../../../shared/extra-utils/search/video-channels' | ||
25 | 25 | ||
26 | const expect = chai.expect | 26 | const expect = chai.expect |
27 | 27 | ||
@@ -30,6 +30,7 @@ describe('Test ActivityPub video channels search', function () { | |||
30 | let userServer2Token: string | 30 | let userServer2Token: string |
31 | let videoServer2UUID: string | 31 | let videoServer2UUID: string |
32 | let channelIdServer2: number | 32 | let channelIdServer2: number |
33 | let command: SearchCommand | ||
33 | 34 | ||
34 | before(async function () { | 35 | before(async function () { |
35 | this.timeout(120000) | 36 | this.timeout(120000) |
@@ -64,6 +65,8 @@ describe('Test ActivityPub video channels search', function () { | |||
64 | } | 65 | } |
65 | 66 | ||
66 | await waitJobs(servers) | 67 | await waitJobs(servers) |
68 | |||
69 | command = servers[0].searchCommand | ||
67 | }) | 70 | }) |
68 | 71 | ||
69 | it('Should not find a remote video channel', async function () { | 72 | it('Should not find a remote video channel', async function () { |
@@ -71,21 +74,21 @@ describe('Test ActivityPub video channels search', function () { | |||
71 | 74 | ||
72 | { | 75 | { |
73 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3' | 76 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3' |
74 | const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) | 77 | const body = await command.searchChannels({ search, token: servers[0].accessToken }) |
75 | 78 | ||
76 | expect(res.body.total).to.equal(0) | 79 | expect(body.total).to.equal(0) |
77 | expect(res.body.data).to.be.an('array') | 80 | expect(body.data).to.be.an('array') |
78 | expect(res.body.data).to.have.lengthOf(0) | 81 | expect(body.data).to.have.lengthOf(0) |
79 | } | 82 | } |
80 | 83 | ||
81 | { | 84 | { |
82 | // Without token | 85 | // Without token |
83 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' | 86 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' |
84 | const res = await searchVideoChannel(servers[0].url, search) | 87 | const body = await command.searchChannels({ search }) |
85 | 88 | ||
86 | expect(res.body.total).to.equal(0) | 89 | expect(body.total).to.equal(0) |
87 | expect(res.body.data).to.be.an('array') | 90 | expect(body.data).to.be.an('array') |
88 | expect(res.body.data).to.have.lengthOf(0) | 91 | expect(body.data).to.have.lengthOf(0) |
89 | } | 92 | } |
90 | }) | 93 | }) |
91 | 94 | ||
@@ -96,13 +99,13 @@ describe('Test ActivityPub video channels search', function () { | |||
96 | ] | 99 | ] |
97 | 100 | ||
98 | for (const search of searches) { | 101 | for (const search of searches) { |
99 | const res = await searchVideoChannel(servers[0].url, search) | 102 | const body = await command.searchChannels({ search }) |
100 | 103 | ||
101 | expect(res.body.total).to.equal(1) | 104 | expect(body.total).to.equal(1) |
102 | expect(res.body.data).to.be.an('array') | 105 | expect(body.data).to.be.an('array') |
103 | expect(res.body.data).to.have.lengthOf(1) | 106 | expect(body.data).to.have.lengthOf(1) |
104 | expect(res.body.data[0].name).to.equal('channel1_server1') | 107 | expect(body.data[0].name).to.equal('channel1_server1') |
105 | expect(res.body.data[0].displayName).to.equal('Channel 1 server 1') | 108 | expect(body.data[0].displayName).to.equal('Channel 1 server 1') |
106 | } | 109 | } |
107 | }) | 110 | }) |
108 | 111 | ||
@@ -110,13 +113,13 @@ describe('Test ActivityPub video channels search', function () { | |||
110 | const search = 'http://localhost:' + servers[0].port + '/c/channel1_server1' | 113 | const search = 'http://localhost:' + servers[0].port + '/c/channel1_server1' |
111 | 114 | ||
112 | for (const token of [ undefined, servers[0].accessToken ]) { | 115 | for (const token of [ undefined, servers[0].accessToken ]) { |
113 | const res = await searchVideoChannel(servers[0].url, search, token) | 116 | const body = await command.searchChannels({ search, token }) |
114 | 117 | ||
115 | expect(res.body.total).to.equal(1) | 118 | expect(body.total).to.equal(1) |
116 | expect(res.body.data).to.be.an('array') | 119 | expect(body.data).to.be.an('array') |
117 | expect(res.body.data).to.have.lengthOf(1) | 120 | expect(body.data).to.have.lengthOf(1) |
118 | expect(res.body.data[0].name).to.equal('channel1_server1') | 121 | expect(body.data[0].name).to.equal('channel1_server1') |
119 | expect(res.body.data[0].displayName).to.equal('Channel 1 server 1') | 122 | expect(body.data[0].displayName).to.equal('Channel 1 server 1') |
120 | } | 123 | } |
121 | }) | 124 | }) |
122 | 125 | ||
@@ -129,13 +132,13 @@ describe('Test ActivityPub video channels search', function () { | |||
129 | ] | 132 | ] |
130 | 133 | ||
131 | for (const search of searches) { | 134 | for (const search of searches) { |
132 | const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) | 135 | const body = await command.searchChannels({ search, token: servers[0].accessToken }) |
133 | 136 | ||
134 | expect(res.body.total).to.equal(1) | 137 | expect(body.total).to.equal(1) |
135 | expect(res.body.data).to.be.an('array') | 138 | expect(body.data).to.be.an('array') |
136 | expect(res.body.data).to.have.lengthOf(1) | 139 | expect(body.data).to.have.lengthOf(1) |
137 | expect(res.body.data[0].name).to.equal('channel1_server2') | 140 | expect(body.data[0].name).to.equal('channel1_server2') |
138 | expect(res.body.data[0].displayName).to.equal('Channel 1 server 2') | 141 | expect(body.data[0].displayName).to.equal('Channel 1 server 2') |
139 | } | 142 | } |
140 | }) | 143 | }) |
141 | 144 | ||
@@ -176,11 +179,11 @@ describe('Test ActivityPub video channels search', function () { | |||
176 | await wait(10000) | 179 | await wait(10000) |
177 | 180 | ||
178 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' | 181 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' |
179 | const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) | 182 | const body = await command.searchChannels({ search, token: servers[0].accessToken }) |
180 | expect(res.body.total).to.equal(1) | 183 | expect(body.total).to.equal(1) |
181 | expect(res.body.data).to.have.lengthOf(1) | 184 | expect(body.data).to.have.lengthOf(1) |
182 | 185 | ||
183 | const videoChannel: VideoChannel = res.body.data[0] | 186 | const videoChannel: VideoChannel = body.data[0] |
184 | expect(videoChannel.displayName).to.equal('channel updated') | 187 | expect(videoChannel.displayName).to.equal('channel updated') |
185 | 188 | ||
186 | // We don't return the owner account for now | 189 | // We don't return the owner account for now |
@@ -199,7 +202,7 @@ describe('Test ActivityPub video channels search', function () { | |||
199 | await wait(10000) | 202 | await wait(10000) |
200 | 203 | ||
201 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' | 204 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' |
202 | await searchVideoChannel(servers[0].url, search, servers[0].accessToken) | 205 | await command.searchChannels({ search, token: servers[0].accessToken }) |
203 | 206 | ||
204 | await waitJobs(servers) | 207 | await waitJobs(servers) |
205 | 208 | ||
@@ -221,9 +224,9 @@ describe('Test ActivityPub video channels search', function () { | |||
221 | await wait(10000) | 224 | await wait(10000) |
222 | 225 | ||
223 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' | 226 | const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2' |
224 | const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) | 227 | const body = await command.searchChannels({ search, token: servers[0].accessToken }) |
225 | expect(res.body.total).to.equal(0) | 228 | expect(body.total).to.equal(0) |
226 | expect(res.body.data).to.have.lengthOf(0) | 229 | expect(body.data).to.have.lengthOf(0) |
227 | }) | 230 | }) |
228 | 231 | ||
229 | after(async function () { | 232 | after(async function () { |