diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-15 10:02:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch) | |
tree | da82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/external-plugins | |
parent | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff) | |
download | PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip |
Introduce videos command
Diffstat (limited to 'server/tests/external-plugins')
-rw-r--r-- | server/tests/external-plugins/auth-ldap.ts | 4 | ||||
-rw-r--r-- | server/tests/external-plugins/auto-block-videos.ts | 38 | ||||
-rw-r--r-- | server/tests/external-plugins/auto-mute.ts | 38 |
3 files changed, 37 insertions, 43 deletions
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index d99b3badc..b626ab2bb 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' | 6 | import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' |
7 | 7 | ||
8 | describe('Official plugin auth-ldap', function () { | 8 | describe('Official plugin auth-ldap', function () { |
9 | let server: ServerInfo | 9 | let server: ServerInfo |
@@ -77,7 +77,7 @@ describe('Official plugin auth-ldap', function () { | |||
77 | }) | 77 | }) |
78 | 78 | ||
79 | it('Should upload a video', async function () { | 79 | it('Should upload a video', async function () { |
80 | await uploadVideo(server.url, accessToken, { name: 'my super video' }) | 80 | await server.videosCommand.upload({ token: accessToken, attributes: { name: 'my super video' } }) |
81 | }) | 81 | }) |
82 | 82 | ||
83 | it('Should not be able to login if the user is banned', async function () { | 83 | it('Should not be able to login if the user is banned', async function () { |
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index f4b55522a..1cce15a2f 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts | |||
@@ -2,27 +2,23 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { Video } from '@shared/models' | ||
6 | import { | ||
7 | doubleFollow, | ||
8 | getVideosList, | ||
9 | MockBlocklist, | ||
10 | setAccessTokensToServers, | ||
11 | uploadVideoAndGetId, | ||
12 | wait | ||
13 | } from '../../../shared/extra-utils' | ||
14 | import { | 5 | import { |
15 | cleanupTests, | 6 | cleanupTests, |
7 | doubleFollow, | ||
16 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
17 | killallServers, | 9 | killallServers, |
10 | MockBlocklist, | ||
18 | reRunServer, | 11 | reRunServer, |
19 | ServerInfo | 12 | ServerInfo, |
20 | } from '../../../shared/extra-utils/server/servers' | 13 | setAccessTokensToServers, |
14 | wait | ||
15 | } from '@shared/extra-utils' | ||
16 | import { Video } from '@shared/models' | ||
21 | 17 | ||
22 | async function check (server: ServerInfo, videoUUID: string, exists = true) { | 18 | async function check (server: ServerInfo, videoUUID: string, exists = true) { |
23 | const res = await getVideosList(server.url) | 19 | const { data } = await server.videosCommand.list() |
24 | 20 | ||
25 | const video = res.body.data.find(v => v.uuid === videoUUID) | 21 | const video = data.find(v => v.uuid === videoUUID) |
26 | 22 | ||
27 | if (exists) expect(video).to.not.be.undefined | 23 | if (exists) expect(video).to.not.be.undefined |
28 | else expect(video).to.be.undefined | 24 | else expect(video).to.be.undefined |
@@ -48,19 +44,19 @@ describe('Official plugin auto-block videos', function () { | |||
48 | blocklistServer = new MockBlocklist() | 44 | blocklistServer = new MockBlocklist() |
49 | port = await blocklistServer.initialize() | 45 | port = await blocklistServer.initialize() |
50 | 46 | ||
51 | await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) | 47 | await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) |
52 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) | 48 | await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) |
53 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video 2 server 2' }) | 49 | await await servers[1].videosCommand.quickUpload({ name: 'video 2 server 2' }) |
54 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2' }) | 50 | await await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2' }) |
55 | 51 | ||
56 | { | 52 | { |
57 | const res = await getVideosList(servers[0].url) | 53 | const { data } = await servers[0].videosCommand.list() |
58 | server1Videos = res.body.data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) | 54 | server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) |
59 | } | 55 | } |
60 | 56 | ||
61 | { | 57 | { |
62 | const res = await getVideosList(servers[1].url) | 58 | const { data } = await servers[1].videosCommand.list() |
63 | server2Videos = res.body.data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) | 59 | server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) |
64 | } | 60 | } |
65 | 61 | ||
66 | await doubleFollow(servers[0], servers[1]) | 62 | await doubleFollow(servers[0], servers[1]) |
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index 844023b83..81a96744e 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts | |||
@@ -7,14 +7,12 @@ import { | |||
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
9 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
10 | getVideosList, | ||
11 | killallServers, | 10 | killallServers, |
12 | makeGetRequest, | 11 | makeGetRequest, |
13 | MockBlocklist, | 12 | MockBlocklist, |
14 | reRunServer, | 13 | reRunServer, |
15 | ServerInfo, | 14 | ServerInfo, |
16 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
17 | uploadVideoAndGetId, | ||
18 | wait | 16 | wait |
19 | } from '@shared/extra-utils' | 17 | } from '@shared/extra-utils' |
20 | 18 | ||
@@ -37,8 +35,8 @@ describe('Official plugin auto-mute', function () { | |||
37 | blocklistServer = new MockBlocklist() | 35 | blocklistServer = new MockBlocklist() |
38 | port = await blocklistServer.initialize() | 36 | port = await blocklistServer.initialize() |
39 | 37 | ||
40 | await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) | 38 | await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) |
41 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) | 39 | await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) |
42 | 40 | ||
43 | await doubleFollow(servers[0], servers[1]) | 41 | await doubleFollow(servers[0], servers[1]) |
44 | }) | 42 | }) |
@@ -66,8 +64,8 @@ describe('Official plugin auto-mute', function () { | |||
66 | 64 | ||
67 | await wait(2000) | 65 | await wait(2000) |
68 | 66 | ||
69 | const res = await getVideosList(servers[0].url) | 67 | const { total } = await servers[0].videosCommand.list() |
70 | expect(res.body.total).to.equal(1) | 68 | expect(total).to.equal(1) |
71 | }) | 69 | }) |
72 | 70 | ||
73 | it('Should remove a server blocklist', async function () { | 71 | it('Should remove a server blocklist', async function () { |
@@ -84,8 +82,8 @@ describe('Official plugin auto-mute', function () { | |||
84 | 82 | ||
85 | await wait(2000) | 83 | await wait(2000) |
86 | 84 | ||
87 | const res = await getVideosList(servers[0].url) | 85 | const { total } = await servers[0].videosCommand.list() |
88 | expect(res.body.total).to.equal(2) | 86 | expect(total).to.equal(2) |
89 | }) | 87 | }) |
90 | 88 | ||
91 | it('Should add an account blocklist', async function () { | 89 | it('Should add an account blocklist', async function () { |
@@ -101,8 +99,8 @@ describe('Official plugin auto-mute', function () { | |||
101 | 99 | ||
102 | await wait(2000) | 100 | await wait(2000) |
103 | 101 | ||
104 | const res = await getVideosList(servers[0].url) | 102 | const { total } = await servers[0].videosCommand.list() |
105 | expect(res.body.total).to.equal(1) | 103 | expect(total).to.equal(1) |
106 | }) | 104 | }) |
107 | 105 | ||
108 | it('Should remove an account blocklist', async function () { | 106 | it('Should remove an account blocklist', async function () { |
@@ -119,8 +117,8 @@ describe('Official plugin auto-mute', function () { | |||
119 | 117 | ||
120 | await wait(2000) | 118 | await wait(2000) |
121 | 119 | ||
122 | const res = await getVideosList(servers[0].url) | 120 | const { total } = await servers[0].videosCommand.list() |
123 | expect(res.body.total).to.equal(2) | 121 | expect(total).to.equal(2) |
124 | }) | 122 | }) |
125 | 123 | ||
126 | it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { | 124 | it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { |
@@ -140,15 +138,15 @@ describe('Official plugin auto-mute', function () { | |||
140 | await wait(2000) | 138 | await wait(2000) |
141 | 139 | ||
142 | { | 140 | { |
143 | const res = await getVideosList(servers[0].url) | 141 | const { total } = await servers[0].videosCommand.list() |
144 | expect(res.body.total).to.equal(1) | 142 | expect(total).to.equal(1) |
145 | } | 143 | } |
146 | 144 | ||
147 | await servers[0].blocklistCommand.removeFromServerBlocklist({ account }) | 145 | await servers[0].blocklistCommand.removeFromServerBlocklist({ account }) |
148 | 146 | ||
149 | { | 147 | { |
150 | const res = await getVideosList(servers[0].url) | 148 | const { total } = await servers[0].videosCommand.list() |
151 | expect(res.body.total).to.equal(2) | 149 | expect(total).to.equal(2) |
152 | } | 150 | } |
153 | 151 | ||
154 | await killallServers([ servers[0] ]) | 152 | await killallServers([ servers[0] ]) |
@@ -156,8 +154,8 @@ describe('Official plugin auto-mute', function () { | |||
156 | await wait(2000) | 154 | await wait(2000) |
157 | 155 | ||
158 | { | 156 | { |
159 | const res = await getVideosList(servers[0].url) | 157 | const { total } = await servers[0].videosCommand.list() |
160 | expect(res.body.total).to.equal(2) | 158 | expect(total).to.equal(2) |
161 | } | 159 | } |
162 | }) | 160 | }) |
163 | 161 | ||
@@ -215,8 +213,8 @@ describe('Official plugin auto-mute', function () { | |||
215 | await wait(2000) | 213 | await wait(2000) |
216 | 214 | ||
217 | for (const server of servers) { | 215 | for (const server of servers) { |
218 | const res = await getVideosList(server.url) | 216 | const { total } = await server.videosCommand.list() |
219 | expect(res.body.total).to.equal(1) | 217 | expect(total).to.equal(1) |
220 | } | 218 | } |
221 | }) | 219 | }) |
222 | 220 | ||