aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 14:46:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 15:29:07 +0100
commit2422c46b27790d94fd29a7092170cee5a1b56008 (patch)
treed5c1942ce20cadb27a551d87c789edfe92f5b105 /server/tests/api/videos
parent34cbef8c6cc912143a421413bdd832c4adcc556a (diff)
downloadPeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip
Implement support field in video and video channel
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts11
-rw-r--r--server/tests/api/videos/single-server.ts2
-rw-r--r--server/tests/api/videos/video-channels.ts122
3 files changed, 90 insertions, 45 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 85d158d61..c82ac1348 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -70,6 +70,7 @@ describe('Test multiple servers', function () {
70 language: 9, 70 language: 9,
71 nsfw: true, 71 nsfw: true,
72 description: 'my super description for server 1', 72 description: 'my super description for server 1',
73 support: 'my super support text for server 1',
73 tags: [ 'tag1p1', 'tag2p1' ], 74 tags: [ 'tag1p1', 'tag2p1' ],
74 channelId: videoChannelId, 75 channelId: videoChannelId,
75 fixture: 'video_short1.webm' 76 fixture: 'video_short1.webm'
@@ -88,6 +89,7 @@ describe('Test multiple servers', function () {
88 language: 9, 89 language: 9,
89 nsfw: true, 90 nsfw: true,
90 description: 'my super description for server 1', 91 description: 'my super description for server 1',
92 support: 'my super support text for server 1',
91 host: 'localhost:9001', 93 host: 'localhost:9001',
92 account: 'root', 94 account: 'root',
93 isLocal, 95 isLocal,
@@ -136,6 +138,7 @@ describe('Test multiple servers', function () {
136 language: 11, 138 language: 11,
137 nsfw: true, 139 nsfw: true,
138 description: 'my super description for server 2', 140 description: 'my super description for server 2',
141 support: 'my super support text for server 2',
139 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], 142 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
140 fixture: 'video_short2.webm', 143 fixture: 'video_short2.webm',
141 thumbnailfile: 'thumbnail.jpg', 144 thumbnailfile: 'thumbnail.jpg',
@@ -156,6 +159,7 @@ describe('Test multiple servers', function () {
156 language: 11, 159 language: 11,
157 nsfw: true, 160 nsfw: true,
158 description: 'my super description for server 2', 161 description: 'my super description for server 2',
162 support: 'my super support text for server 2',
159 host: 'localhost:9002', 163 host: 'localhost:9002',
160 account: 'user1', 164 account: 'user1',
161 isLocal, 165 isLocal,
@@ -211,6 +215,7 @@ describe('Test multiple servers', function () {
211 language: 11, 215 language: 11,
212 nsfw: true, 216 nsfw: true,
213 description: 'my super description for server 3', 217 description: 'my super description for server 3',
218 support: 'my super support text for server 3',
214 tags: [ 'tag1p3' ], 219 tags: [ 'tag1p3' ],
215 fixture: 'video_short3.webm' 220 fixture: 'video_short3.webm'
216 } 221 }
@@ -223,6 +228,7 @@ describe('Test multiple servers', function () {
223 language: 12, 228 language: 12,
224 nsfw: false, 229 nsfw: false,
225 description: 'my super description for server 3-2', 230 description: 'my super description for server 3-2',
231 support: 'my super support text for server 3-2',
226 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 232 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
227 fixture: 'video_short.webm' 233 fixture: 'video_short.webm'
228 } 234 }
@@ -257,6 +263,7 @@ describe('Test multiple servers', function () {
257 language: 11, 263 language: 11,
258 nsfw: true, 264 nsfw: true,
259 description: 'my super description for server 3', 265 description: 'my super description for server 3',
266 support: 'my super support text for server 3',
260 host: 'localhost:9003', 267 host: 'localhost:9003',
261 account: 'root', 268 account: 'root',
262 isLocal, 269 isLocal,
@@ -286,6 +293,7 @@ describe('Test multiple servers', function () {
286 language: 12, 293 language: 12,
287 nsfw: false, 294 nsfw: false,
288 description: 'my super description for server 3-2', 295 description: 'my super description for server 3-2',
296 support: 'my super support text for server 3-2',
289 host: 'localhost:9003', 297 host: 'localhost:9003',
290 account: 'root', 298 account: 'root',
291 commentsEnabled: true, 299 commentsEnabled: true,
@@ -525,6 +533,7 @@ describe('Test multiple servers', function () {
525 language: 13, 533 language: 13,
526 nsfw: true, 534 nsfw: true,
527 description: 'my super description updated', 535 description: 'my super description updated',
536 support: 'my super support text updated',
528 tags: [ 'tag_up_1', 'tag_up_2' ], 537 tags: [ 'tag_up_1', 'tag_up_2' ],
529 thumbnailfile: 'thumbnail.jpg', 538 thumbnailfile: 'thumbnail.jpg',
530 previewfile: 'preview.jpg' 539 previewfile: 'preview.jpg'
@@ -553,6 +562,7 @@ describe('Test multiple servers', function () {
553 language: 13, 562 language: 13,
554 nsfw: true, 563 nsfw: true,
555 description: 'my super description updated', 564 description: 'my super description updated',
565 support: 'my super support text updated',
556 host: 'localhost:9003', 566 host: 'localhost:9003',
557 account: 'root', 567 account: 'root',
558 isLocal, 568 isLocal,
@@ -841,6 +851,7 @@ describe('Test multiple servers', function () {
841 language: null, 851 language: null,
842 nsfw: false, 852 nsfw: false,
843 description: null, 853 description: null,
854 support: null,
844 host: 'localhost:9002', 855 host: 'localhost:9002',
845 account: 'root', 856 account: 'root',
846 isLocal, 857 isLocal,
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 8f55075fb..83b6a0e9a 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -26,6 +26,7 @@ describe('Test a single server', function () {
26 language: 3, 26 language: 3,
27 nsfw: true, 27 nsfw: true,
28 description: 'my super description', 28 description: 'my super description',
29 support: 'my super support text',
29 host: 'localhost:9001', 30 host: 'localhost:9001',
30 account: 'root', 31 account: 'root',
31 isLocal: true, 32 isLocal: true,
@@ -54,6 +55,7 @@ describe('Test a single server', function () {
54 language: 5, 55 language: 5,
55 nsfw: false, 56 nsfw: false,
56 description: 'my super description updated', 57 description: 'my super description updated',
58 support: 'my super support text updated',
57 host: 'localhost:9001', 59 host: 'localhost:9001',
58 account: 'root', 60 account: 'root',
59 isLocal: true, 61 isLocal: true,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 25b7ad6ab..b9c9bbf3c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -1,27 +1,27 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
5const expect = chai.expect 4import 'mocha'
6 5import { User } from '../../../../shared/index'
6import { doubleFollow, flushAndRunMultipleServers, uploadVideo, wait } from '../../utils'
7import { 7import {
8 ServerInfo, 8 addVideoChannel,
9 deleteVideoChannel,
9 flushTests, 10 flushTests,
10 runServer, 11 getAccountVideoChannelsList,
11 setAccessTokensToServers,
12 killallServers,
13 getMyUserInformation, 12 getMyUserInformation,
13 getVideoChannel,
14 getVideoChannelsList, 14 getVideoChannelsList,
15 addVideoChannel, 15 killallServers,
16 getAccountVideoChannelsList, 16 ServerInfo,
17 updateVideoChannel, 17 setAccessTokensToServers,
18 deleteVideoChannel, 18 updateVideoChannel
19 getVideoChannel
20} from '../../utils/index' 19} from '../../utils/index'
21import { User } from '../../../../shared/index'
22 20
23describe('Test a video channels', function () { 21const expect = chai.expect
24 let server: ServerInfo 22
23describe('Test video channels', function () {
24 let servers: ServerInfo[]
25 let userInfo: User 25 let userInfo: User
26 let videoChannelId: number 26 let videoChannelId: number
27 27
@@ -30,29 +30,41 @@ describe('Test a video channels', function () {
30 30
31 await flushTests() 31 await flushTests()
32 32
33 server = await runServer(1) 33 servers = await flushAndRunMultipleServers(2)
34
35 await setAccessTokensToServers(servers)
36 await doubleFollow(servers[0], servers[1])
34 37
35 await setAccessTokensToServers([ server ]) 38 await wait(5000)
36 }) 39 })
37 40
38 it('Should have one video channel (created with root)', async () => { 41 it('Should have one video channel (created with root)', async () => {
39 const res = await getVideoChannelsList(server.url, 0, 2) 42 const res = await getVideoChannelsList(servers[0].url, 0, 2)
40 43
41 expect(res.body.total).to.equal(1) 44 expect(res.body.total).to.equal(1)
42 expect(res.body.data).to.be.an('array') 45 expect(res.body.data).to.be.an('array')
43 expect(res.body.data).to.have.lengthOf(1) 46 expect(res.body.data).to.have.lengthOf(1)
44 }) 47 })
45 48
46 it('Should create another video channel', async () => { 49 it('Should create another video channel', async function () {
50 this.timeout(10000)
51
47 const videoChannel = { 52 const videoChannel = {
48 name: 'second video channel', 53 name: 'second video channel',
49 description: 'super video channel description' 54 description: 'super video channel description',
55 support: 'super video channel support text'
50 } 56 }
51 await addVideoChannel(server.url, server.accessToken, videoChannel) 57 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
58 videoChannelId = res.body.videoChannel.id
59
60 // The channel is 1 is propagated to servers 2
61 await uploadVideo(servers[0].url, servers[0].accessToken, { channelId: videoChannelId })
62
63 await wait(3000)
52 }) 64 })
53 65
54 it('Should have two video channels when getting my information', async () => { 66 it('Should have two video channels when getting my information', async () => {
55 const res = await getMyUserInformation(server.url, server.accessToken) 67 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
56 userInfo = res.body 68 userInfo = res.body
57 69
58 expect(userInfo.videoChannels).to.be.an('array') 70 expect(userInfo.videoChannels).to.be.an('array')
@@ -62,11 +74,11 @@ describe('Test a video channels', function () {
62 expect(videoChannels[0].displayName).to.equal('Default root channel') 74 expect(videoChannels[0].displayName).to.equal('Default root channel')
63 expect(videoChannels[1].displayName).to.equal('second video channel') 75 expect(videoChannels[1].displayName).to.equal('second video channel')
64 expect(videoChannels[1].description).to.equal('super video channel description') 76 expect(videoChannels[1].description).to.equal('super video channel description')
77 expect(videoChannels[1].support).to.equal('super video channel support text')
65 }) 78 })
66 79
67 it('Should have two video channels when getting account channels', async () => { 80 it('Should have two video channels when getting account channels on server 1', async function () {
68 const res = await getAccountVideoChannelsList(server.url, userInfo.account.uuid) 81 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
69
70 expect(res.body.total).to.equal(2) 82 expect(res.body.total).to.equal(2)
71 expect(res.body.data).to.be.an('array') 83 expect(res.body.data).to.be.an('array')
72 expect(res.body.data).to.have.lengthOf(2) 84 expect(res.body.data).to.have.lengthOf(2)
@@ -75,12 +87,23 @@ describe('Test a video channels', function () {
75 expect(videoChannels[0].displayName).to.equal('Default root channel') 87 expect(videoChannels[0].displayName).to.equal('Default root channel')
76 expect(videoChannels[1].displayName).to.equal('second video channel') 88 expect(videoChannels[1].displayName).to.equal('second video channel')
77 expect(videoChannels[1].description).to.equal('super video channel description') 89 expect(videoChannels[1].description).to.equal('super video channel description')
90 expect(videoChannels[1].support).to.equal('super video channel support text')
91 })
92
93 it('Should have one video channel when getting account channels on server 2', async function () {
94 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
95 expect(res.body.total).to.equal(1)
96 expect(res.body.data).to.be.an('array')
97 expect(res.body.data).to.have.lengthOf(1)
78 98
79 videoChannelId = videoChannels[1].id 99 const videoChannels = res.body.data
100 expect(videoChannels[0].displayName).to.equal('second video channel')
101 expect(videoChannels[0].description).to.equal('super video channel description')
102 expect(videoChannels[0].support).to.equal('super video channel support text')
80 }) 103 })
81 104
82 it('Should list video channels', async () => { 105 it('Should list video channels', async function () {
83 const res = await getVideoChannelsList(server.url, 1, 1, '-name') 106 const res = await getVideoChannelsList(servers[0].url, 1, 1, '-name')
84 107
85 expect(res.body.total).to.equal(2) 108 expect(res.body.total).to.equal(2)
86 expect(res.body.data).to.be.an('array') 109 expect(res.body.data).to.be.an('array')
@@ -88,39 +111,48 @@ describe('Test a video channels', function () {
88 expect(res.body.data[0].displayName).to.equal('Default root channel') 111 expect(res.body.data[0].displayName).to.equal('Default root channel')
89 }) 112 })
90 113
91 it('Should update video channel', async () => { 114 it('Should update video channel', async function () {
115 this.timeout(5000)
116
92 const videoChannelAttributes = { 117 const videoChannelAttributes = {
93 name: 'video channel updated', 118 name: 'video channel updated',
94 description: 'video channel description updated' 119 description: 'video channel description updated',
120 support: 'video channel support text updated'
95 } 121 }
96 122
97 await updateVideoChannel(server.url, server.accessToken, videoChannelId, videoChannelAttributes) 123 await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes)
124
125 await wait(3000)
98 }) 126 })
99 127
100 it('Should have video channel updated', async () => { 128 it('Should have video channel updated', async function () {
101 const res = await getVideoChannelsList(server.url, 0, 1, '-name') 129 for (const server of servers) {
130 const res = await getVideoChannelsList(server.url, 0, 1, '-name')
102 131
103 expect(res.body.total).to.equal(2) 132 expect(res.body.total).to.equal(2)
104 expect(res.body.data).to.be.an('array') 133 expect(res.body.data).to.be.an('array')
105 expect(res.body.data).to.have.lengthOf(1) 134 expect(res.body.data).to.have.lengthOf(1)
106 expect(res.body.data[0].displayName).to.equal('video channel updated') 135 expect(res.body.data[0].displayName).to.equal('video channel updated')
107 expect(res.body.data[0].description).to.equal('video channel description updated') 136 expect(res.body.data[0].description).to.equal('video channel description updated')
137 expect(res.body.data[0].support).to.equal('video channel support text updated')
138 }
108 }) 139 })
109 140
110 it('Should get video channel', async () => { 141 it('Should get video channel', async function () {
111 const res = await getVideoChannel(server.url, videoChannelId) 142 const res = await getVideoChannel(servers[0].url, videoChannelId)
112 143
113 const videoChannel = res.body 144 const videoChannel = res.body
114 expect(videoChannel.displayName).to.equal('video channel updated') 145 expect(videoChannel.displayName).to.equal('video channel updated')
115 expect(videoChannel.description).to.equal('video channel description updated') 146 expect(videoChannel.description).to.equal('video channel description updated')
147 expect(videoChannel.support).to.equal('video channel support text updated')
116 }) 148 })
117 149
118 it('Should delete video channel', async () => { 150 it('Should delete video channel', async function () {
119 await deleteVideoChannel(server.url, server.accessToken, videoChannelId) 151 await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId)
120 }) 152 })
121 153
122 it('Should have video channel deleted', async () => { 154 it('Should have video channel deleted', async function () {
123 const res = await getVideoChannelsList(server.url, 0, 10) 155 const res = await getVideoChannelsList(servers[0].url, 0, 10)
124 156
125 expect(res.body.total).to.equal(1) 157 expect(res.body.total).to.equal(1)
126 expect(res.body.data).to.be.an('array') 158 expect(res.body.data).to.be.an('array')
@@ -129,7 +161,7 @@ describe('Test a video channels', function () {
129 }) 161 })
130 162
131 after(async function () { 163 after(async function () {
132 killallServers([ server ]) 164 killallServers(servers)
133 165
134 // Keep the logs if the test failed 166 // Keep the logs if the test failed
135 if (this['ok']) { 167 if (this['ok']) {