aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-31 13:13:02 +0200
committerChocobozzz <me@florianbigard.com>2020-07-31 13:20:25 +0200
commit39433fa56c1f41f700abc912d444c9af4b4c9d13 (patch)
tree1cef1496b9d7256d49a502a5f558914c3b73d3cd /server/tests
parent2f712d2bff29dc8dc39ffea54985eeb27fed694d (diff)
downloadPeerTube-39433fa56c1f41f700abc912d444c9af4b4c9d13.tar.gz
PeerTube-39433fa56c1f41f700abc912d444c9af4b4c9d13.tar.zst
PeerTube-39433fa56c1f41f700abc912d444c9af4b4c9d13.zip
Fix client tests
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/client.ts120
1 files changed, 59 insertions, 61 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 2d8468c06..f55859b6f 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -3,24 +3,25 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { Account, VideoPlaylistPrivacy } from '@shared/models'
6import { 7import {
8 addVideoInPlaylist,
7 cleanupTests, 9 cleanupTests,
10 createVideoPlaylist,
8 flushAndRunServer, 11 flushAndRunServer,
12 getAccount,
9 getCustomConfig, 13 getCustomConfig,
10 getVideosList, 14 getVideosList,
11 makeHTMLRequest, 15 makeHTMLRequest,
12 ServerInfo, 16 ServerInfo,
13 serverLogin, 17 serverLogin,
18 setDefaultVideoChannel,
14 updateCustomConfig, 19 updateCustomConfig,
15 updateCustomSubConfig, 20 updateCustomSubConfig,
16 uploadVideo, 21 uploadVideo,
17 createVideoPlaylist, 22 updateMyUser,
18 addVideoInPlaylist, 23 updateVideoChannel
19 getAccount,
20 addVideoChannel
21} from '../../shared/extra-utils' 24} from '../../shared/extra-utils'
22import { VideoPlaylistPrivacy } from '@shared/models'
23import { MVideoPlaylist, MAccount, MChannel } from '@server/types/models'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
@@ -32,28 +33,33 @@ function checkIndexTags (html: string, title: string, description: string, css:
32 33
33describe('Test a client controllers', function () { 34describe('Test a client controllers', function () {
34 let server: ServerInfo 35 let server: ServerInfo
35 let videoPlaylist: MVideoPlaylist 36 let account: Account
36 let account: MAccount 37
37 let videoChannel: MChannel 38 const videoName = 'my super name for server 1'
38 const name = 'my super name for server 1' 39 const videoDescription = 'my super description for server 1'
39 const description = 'my super description for server 1' 40
41 const playlistName = 'super playlist name'
42 const playlistDescription = 'super playlist description'
43 let playlistUUID: string
44
45 const channelDescription = 'my super channel description'
40 46
41 before(async function () { 47 before(async function () {
42 this.timeout(120000) 48 this.timeout(120000)
43 49
44 server = await flushAndRunServer(1) 50 server = await flushAndRunServer(1)
45 server.accessToken = await serverLogin(server) 51 server.accessToken = await serverLogin(server)
52 await setDefaultVideoChannel([ server ])
46 53
47 // Video 54 await updateVideoChannel(server.url, server.accessToken, server.videoChannel.name, { description: channelDescription })
48 55
49 const videoAttributes = { name, description } 56 // Video
50 57
58 const videoAttributes = { name: videoName, description: videoDescription }
51 await uploadVideo(server.url, server.accessToken, videoAttributes) 59 await uploadVideo(server.url, server.accessToken, videoAttributes)
52 60
53 const resVideosRequest = await getVideosList(server.url) 61 const resVideosRequest = await getVideosList(server.url)
54
55 const videos = resVideosRequest.body.data 62 const videos = resVideosRequest.body.data
56
57 expect(videos.length).to.equal(1) 63 expect(videos.length).to.equal(1)
58 64
59 server.video = videos[0] 65 server.video = videos[0]
@@ -61,39 +67,31 @@ describe('Test a client controllers', function () {
61 // Playlist 67 // Playlist
62 68
63 const playlistAttrs = { 69 const playlistAttrs = {
64 displayName: name, 70 displayName: playlistName,
65 description, 71 description: playlistDescription,
66 privacy: VideoPlaylistPrivacy.PUBLIC 72 privacy: VideoPlaylistPrivacy.PUBLIC,
73 videoChannelId: server.videoChannel.id
67 } 74 }
68 75
69 const resVideoPlaylistRequest = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs }) 76 const resVideoPlaylistRequest = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs })
70 77
71 videoPlaylist = resVideoPlaylistRequest.body.videoPlaylist 78 const playlist = resVideoPlaylistRequest.body.videoPlaylist
79 const playlistId = playlist.id
80 playlistUUID = playlist.uuid
72 81
73 await addVideoInPlaylist({ 82 await addVideoInPlaylist({
74 url: server.url, 83 url: server.url,
75 token: server.accessToken, 84 token: server.accessToken,
76 playlistId: videoPlaylist.id, 85 playlistId,
77 elementAttrs: { videoId: server.video.id } 86 elementAttrs: { videoId: server.video.id }
78 }) 87 })
79 88
80 // Account 89 // Account
81 90
82 const resAccountRequest = await getAccount(server.url, `${server.user.username}@${server.host}:${server.port}`) 91 await updateMyUser({ url: server.url, accessToken: server.accessToken, description: 'my account description' })
83
84 account = resAccountRequest.body.account
85
86 // Channel
87
88 const videoChannelAttributesArg = {
89 name: `${server.user.username}_channel`,
90 displayName: name,
91 description
92 }
93
94 const resChannelRequest = await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)
95 92
96 videoChannel = resChannelRequest.body.videoChannel 93 const resAccountRequest = await getAccount(server.url, `${server.user.username}@${server.host}`)
94 account = resAccountRequest.body
97 }) 95 })
98 96
99 it('Should have valid Open Graph tags on the watch page with video id', async function () { 97 it('Should have valid Open Graph tags on the watch page with video id', async function () {
@@ -102,8 +100,8 @@ describe('Test a client controllers', function () {
102 .set('Accept', 'text/html') 100 .set('Accept', 'text/html')
103 .expect(200) 101 .expect(200)
104 102
105 expect(res.text).to.contain(`<meta property="og:title" content="${name}" />`) 103 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
106 expect(res.text).to.contain(`<meta property="og:description" content="${description}" />`) 104 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
107 expect(res.text).to.contain('<meta property="og:type" content="video" />') 105 expect(res.text).to.contain('<meta property="og:type" content="video" />')
108 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`) 106 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
109 }) 107 })
@@ -114,22 +112,22 @@ describe('Test a client controllers', function () {
114 .set('Accept', 'text/html') 112 .set('Accept', 'text/html')
115 .expect(200) 113 .expect(200)
116 114
117 expect(res.text).to.contain(`<meta property="og:title" content="${name}" />`) 115 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
118 expect(res.text).to.contain(`<meta property="og:description" content="${description}" />`) 116 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
119 expect(res.text).to.contain('<meta property="og:type" content="video" />') 117 expect(res.text).to.contain('<meta property="og:type" content="video" />')
120 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`) 118 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
121 }) 119 })
122 120
123 it('Should have valid Open Graph tags on the watch playlist page', async function () { 121 it('Should have valid Open Graph tags on the watch playlist page', async function () {
124 const res = await request(server.url) 122 const res = await request(server.url)
125 .get('/videos/watch/playlist/' + videoPlaylist.uuid) 123 .get('/videos/watch/playlist/' + playlistUUID)
126 .set('Accept', 'text/html') 124 .set('Accept', 'text/html')
127 .expect(200) 125 .expect(200)
128 126
129 expect(res.text).to.contain(`<meta property="og:title" content="${videoPlaylist.name}" />`) 127 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
130 expect(res.text).to.contain(`<meta property="og:description" content="${videoPlaylist.description}" />`) 128 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
131 expect(res.text).to.contain('<meta property="og:type" content="video" />') 129 expect(res.text).to.contain('<meta property="og:type" content="video" />')
132 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${videoPlaylist.uuid}" />`) 130 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${playlistUUID}" />`)
133 }) 131 })
134 132
135 it('Should have valid Open Graph tags on the account page', async function () { 133 it('Should have valid Open Graph tags on the account page', async function () {
@@ -138,7 +136,7 @@ describe('Test a client controllers', function () {
138 .set('Accept', 'text/html') 136 .set('Accept', 'text/html')
139 .expect(200) 137 .expect(200)
140 138
141 expect(res.text).to.contain(`<meta property="og:title" content="${account.getDisplayName()}" />`) 139 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
142 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`) 140 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`)
143 expect(res.text).to.contain('<meta property="og:type" content="website" />') 141 expect(res.text).to.contain('<meta property="og:type" content="website" />')
144 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`) 142 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`)
@@ -146,14 +144,14 @@ describe('Test a client controllers', function () {
146 144
147 it('Should have valid Open Graph tags on the channel page', async function () { 145 it('Should have valid Open Graph tags on the channel page', async function () {
148 const res = await request(server.url) 146 const res = await request(server.url)
149 .get('/video-channels/' + videoChannel.name) 147 .get('/video-channels/' + server.videoChannel.name)
150 .set('Accept', 'text/html') 148 .set('Accept', 'text/html')
151 .expect(200) 149 .expect(200)
152 150
153 expect(res.text).to.contain(`<meta property="og:title" content="${videoChannel.getDisplayName()}" />`) 151 expect(res.text).to.contain(`<meta property="og:title" content="${server.videoChannel.displayName}" />`)
154 expect(res.text).to.contain(`<meta property="og:description" content="${videoChannel.description}" />`) 152 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
155 expect(res.text).to.contain('<meta property="og:type" content="website" />') 153 expect(res.text).to.contain('<meta property="og:type" content="website" />')
156 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${videoChannel.name}" />`) 154 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${server.videoChannel.name}" />`)
157 }) 155 })
158 156
159 it('Should have valid oEmbed discovery tags', async function () { 157 it('Should have valid oEmbed discovery tags', async function () {
@@ -172,7 +170,7 @@ describe('Test a client controllers', function () {
172 expect(res.text).to.contain(expectedLink) 170 expect(res.text).to.contain(expectedLink)
173 }) 171 })
174 172
175 it('Should have valid twitter card on the whatch video page', async function () { 173 it('Should have valid twitter card on the watch video page', async function () {
176 const res = await request(server.url) 174 const res = await request(server.url)
177 .get('/videos/watch/' + server.video.uuid) 175 .get('/videos/watch/' + server.video.uuid)
178 .set('Accept', 'text/html') 176 .set('Accept', 'text/html')
@@ -180,20 +178,20 @@ describe('Test a client controllers', function () {
180 178
181 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />') 179 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
182 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 180 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
183 expect(res.text).to.contain(`<meta property="twitter:title" content="${name}" />`) 181 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
184 expect(res.text).to.contain(`<meta property="twitter:description" content="${description}" />`) 182 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`)
185 }) 183 })
186 184
187 it('Should have valid twitter card on the watch playlist page', async function () { 185 it('Should have valid twitter card on the watch playlist page', async function () {
188 const res = await request(server.url) 186 const res = await request(server.url)
189 .get('/videos/watch/playlist/' + videoPlaylist.uuid) 187 .get('/videos/watch/playlist/' + playlistUUID)
190 .set('Accept', 'text/html') 188 .set('Accept', 'text/html')
191 .expect(200) 189 .expect(200)
192 190
193 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 191 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
194 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 192 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
195 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoPlaylist.name}" />`) 193 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
196 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoPlaylist.description}" />`) 194 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
197 }) 195 })
198 196
199 it('Should have valid twitter card on the account page', async function () { 197 it('Should have valid twitter card on the account page', async function () {
@@ -210,14 +208,14 @@ describe('Test a client controllers', function () {
210 208
211 it('Should have valid twitter card on the channel page', async function () { 209 it('Should have valid twitter card on the channel page', async function () {
212 const res = await request(server.url) 210 const res = await request(server.url)
213 .get('/video-channels/' + videoChannel.name) 211 .get('/video-channels/' + server.videoChannel.name)
214 .set('Accept', 'text/html') 212 .set('Accept', 'text/html')
215 .expect(200) 213 .expect(200)
216 214
217 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 215 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
218 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 216 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
219 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoChannel.name}" />`) 217 expect(res.text).to.contain(`<meta property="twitter:title" content="${server.videoChannel.displayName}" />`)
220 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoChannel.description}" />`) 218 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
221 }) 219 })
222 220
223 it('Should have valid twitter card if Twitter is whitelisted', async function () { 221 it('Should have valid twitter card if Twitter is whitelisted', async function () {
@@ -238,11 +236,11 @@ describe('Test a client controllers', function () {
238 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 236 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
239 237
240 const resVideoPlaylistRequest = await request(server.url) 238 const resVideoPlaylistRequest = await request(server.url)
241 .get('/videos/watch/playlist/' + videoPlaylist.uuid) 239 .get('/videos/watch/playlist/' + playlistUUID)
242 .set('Accept', 'text/html') 240 .set('Accept', 'text/html')
243 .expect(200) 241 .expect(200)
244 242
245 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />') 243 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
246 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 244 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
247 245
248 const resAccountRequest = await request(server.url) 246 const resAccountRequest = await request(server.url)
@@ -250,15 +248,15 @@ describe('Test a client controllers', function () {
250 .set('Accept', 'text/html') 248 .set('Accept', 'text/html')
251 .expect(200) 249 .expect(200)
252 250
253 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="player" />') 251 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
254 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 252 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
255 253
256 const resChannelRequest = await request(server.url) 254 const resChannelRequest = await request(server.url)
257 .get('/video-channels/' + videoChannel.name) 255 .get('/video-channels/' + server.videoChannel.name)
258 .set('Accept', 'text/html') 256 .set('Accept', 'text/html')
259 .expect(200) 257 .expect(200)
260 258
261 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="player" />') 259 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
262 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 260 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
263 }) 261 })
264 262