aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/client.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-05 15:35:58 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:58:29 +0200
commit6fad8e51c47b9d07bea99b777c1f55c10f6d576d (patch)
tree09b33652d565a6dbe70e413b88c64aa611f7f4b6 /server/tests/client.ts
parenta75292db788d400ba84933693f5f98a83f3aaa60 (diff)
downloadPeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.tar.gz
PeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.tar.zst
PeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.zip
Handle playlist oembed
Diffstat (limited to 'server/tests/client.ts')
-rw-r--r--server/tests/client.ts342
1 files changed, 184 insertions, 158 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts
index f55859b6f..96821eb6f 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -94,204 +94,230 @@ describe('Test a client controllers', function () {
94 account = resAccountRequest.body 94 account = resAccountRequest.body
95 }) 95 })
96 96
97 it('Should have valid Open Graph tags on the watch page with video id', async function () { 97 describe('oEmbed', function () {
98 const res = await request(server.url) 98 it('Should have valid oEmbed discovery tags for videos', async function () {
99 .get('/videos/watch/' + server.video.id) 99 const path = '/videos/watch/' + server.video.uuid
100 .set('Accept', 'text/html') 100 const res = await request(server.url)
101 .expect(200) 101 .get(path)
102 102 .set('Accept', 'text/html')
103 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 103 .expect(200)
104 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
105 expect(res.text).to.contain('<meta property="og:type" content="video" />')
106 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
107 })
108 104
109 it('Should have valid Open Graph tags on the watch page with video uuid', async function () { 105 const port = server.port
110 const res = await request(server.url)
111 .get('/videos/watch/' + server.video.uuid)
112 .set('Accept', 'text/html')
113 .expect(200)
114 106
115 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 107 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
116 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`) 108 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2F${server.video.uuid}" ` +
117 expect(res.text).to.contain('<meta property="og:type" content="video" />') 109 `title="${server.video.name}" />`
118 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
119 })
120 110
121 it('Should have valid Open Graph tags on the watch playlist page', async function () { 111 expect(res.text).to.contain(expectedLink)
122 const res = await request(server.url) 112 })
123 .get('/videos/watch/playlist/' + playlistUUID)
124 .set('Accept', 'text/html')
125 .expect(200)
126 113
127 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`) 114 it('Should have valid oEmbed discovery tags for a playlist', async function () {
128 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`) 115 const res = await request(server.url)
129 expect(res.text).to.contain('<meta property="og:type" content="video" />') 116 .get('/videos/watch/playlist/' + playlistUUID)
130 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${playlistUUID}" />`) 117 .set('Accept', 'text/html')
131 }) 118 .expect(200)
119
120 const port = server.port
132 121
133 it('Should have valid Open Graph tags on the account page', async function () { 122 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
134 const res = await request(server.url) 123 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2Fplaylist%2F${playlistUUID}" ` +
135 .get('/accounts/' + server.user.username) 124 `title="${playlistName}" />`
136 .set('Accept', 'text/html')
137 .expect(200)
138 125
139 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) 126 expect(res.text).to.contain(expectedLink)
140 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`) 127 })
141 expect(res.text).to.contain('<meta property="og:type" content="website" />')
142 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`)
143 }) 128 })
144 129
145 it('Should have valid Open Graph tags on the channel page', async function () { 130 describe('Open Graph', function () {
146 const res = await request(server.url)
147 .get('/video-channels/' + server.videoChannel.name)
148 .set('Accept', 'text/html')
149 .expect(200)
150 131
151 expect(res.text).to.contain(`<meta property="og:title" content="${server.videoChannel.displayName}" />`) 132 it('Should have valid Open Graph tags on the account page', async function () {
152 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) 133 const res = await request(server.url)
153 expect(res.text).to.contain('<meta property="og:type" content="website" />') 134 .get('/accounts/' + server.user.username)
154 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${server.videoChannel.name}" />`) 135 .set('Accept', 'text/html')
155 }) 136 .expect(200)
156 137
157 it('Should have valid oEmbed discovery tags', async function () { 138 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
158 const path = '/videos/watch/' + server.video.uuid 139 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`)
159 const res = await request(server.url) 140 expect(res.text).to.contain('<meta property="og:type" content="website" />')
160 .get(path) 141 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`)
161 .set('Accept', 'text/html') 142 })
162 .expect(200)
163 143
164 const port = server.port 144 it('Should have valid Open Graph tags on the channel page', async function () {
145 const res = await request(server.url)
146 .get('/video-channels/' + server.videoChannel.name)
147 .set('Accept', 'text/html')
148 .expect(200)
165 149
166 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + 150 expect(res.text).to.contain(`<meta property="og:title" content="${server.videoChannel.displayName}" />`)
167 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2F${server.video.uuid}" ` + 151 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
168 `title="${server.video.name}" />` 152 expect(res.text).to.contain('<meta property="og:type" content="website" />')
153 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${server.videoChannel.name}" />`)
154 })
169 155
170 expect(res.text).to.contain(expectedLink) 156 it('Should have valid Open Graph tags on the watch page with video id', async function () {
171 }) 157 const res = await request(server.url)
158 .get('/videos/watch/' + server.video.id)
159 .set('Accept', 'text/html')
160 .expect(200)
172 161
173 it('Should have valid twitter card on the watch video page', async function () { 162 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
174 const res = await request(server.url) 163 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
175 .get('/videos/watch/' + server.video.uuid) 164 expect(res.text).to.contain('<meta property="og:type" content="video" />')
176 .set('Accept', 'text/html') 165 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
177 .expect(200) 166 })
178 167
179 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />') 168 it('Should have valid Open Graph tags on the watch page with video uuid', async function () {
180 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 169 const res = await request(server.url)
181 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`) 170 .get('/videos/watch/' + server.video.uuid)
182 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`) 171 .set('Accept', 'text/html')
183 }) 172 .expect(200)
184 173
185 it('Should have valid twitter card on the watch playlist page', async function () { 174 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
186 const res = await request(server.url) 175 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
187 .get('/videos/watch/playlist/' + playlistUUID) 176 expect(res.text).to.contain('<meta property="og:type" content="video" />')
188 .set('Accept', 'text/html') 177 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
189 .expect(200) 178 })
190 179
191 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 180 it('Should have valid Open Graph tags on the watch playlist page', async function () {
192 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 181 const res = await request(server.url)
193 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`) 182 .get('/videos/watch/playlist/' + playlistUUID)
194 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`) 183 .set('Accept', 'text/html')
184 .expect(200)
185
186 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
187 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
188 expect(res.text).to.contain('<meta property="og:type" content="video" />')
189 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${playlistUUID}" />`)
190 })
195 }) 191 })
196 192
197 it('Should have valid twitter card on the account page', async function () { 193 describe('Twitter card', async function () {
198 const res = await request(server.url)
199 .get('/accounts/' + account.name)
200 .set('Accept', 'text/html')
201 .expect(200)
202 194
203 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 195 it('Should have valid twitter card on the watch video page', async function () {
204 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 196 const res = await request(server.url)
205 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`) 197 .get('/videos/watch/' + server.video.uuid)
206 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`) 198 .set('Accept', 'text/html')
207 }) 199 .expect(200)
208 200
209 it('Should have valid twitter card on the channel page', async function () { 201 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
210 const res = await request(server.url) 202 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
211 .get('/video-channels/' + server.videoChannel.name) 203 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
212 .set('Accept', 'text/html') 204 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`)
213 .expect(200) 205 })
214 206
215 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 207 it('Should have valid twitter card on the watch playlist page', async function () {
216 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 208 const res = await request(server.url)
217 expect(res.text).to.contain(`<meta property="twitter:title" content="${server.videoChannel.displayName}" />`) 209 .get('/videos/watch/playlist/' + playlistUUID)
218 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) 210 .set('Accept', 'text/html')
219 }) 211 .expect(200)
220 212
221 it('Should have valid twitter card if Twitter is whitelisted', async function () { 213 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
222 const res1 = await getCustomConfig(server.url, server.accessToken) 214 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
223 const config = res1.body 215 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
224 config.services.twitter = { 216 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
225 username: '@Kuja', 217 })
226 whitelisted: true
227 }
228 await updateCustomConfig(server.url, server.accessToken, config)
229 218
230 const resVideoRequest = await request(server.url) 219 it('Should have valid twitter card on the account page', async function () {
231 .get('/videos/watch/' + server.video.uuid) 220 const res = await request(server.url)
232 .set('Accept', 'text/html') 221 .get('/accounts/' + account.name)
233 .expect(200) 222 .set('Accept', 'text/html')
223 .expect(200)
234 224
235 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />') 225 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
236 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 226 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
227 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
228 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
229 })
237 230
238 const resVideoPlaylistRequest = await request(server.url) 231 it('Should have valid twitter card on the channel page', async function () {
239 .get('/videos/watch/playlist/' + playlistUUID) 232 const res = await request(server.url)
240 .set('Accept', 'text/html') 233 .get('/video-channels/' + server.videoChannel.name)
241 .expect(200) 234 .set('Accept', 'text/html')
235 .expect(200)
242 236
243 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 237 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
244 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 238 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
239 expect(res.text).to.contain(`<meta property="twitter:title" content="${server.videoChannel.displayName}" />`)
240 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
241 })
245 242
246 const resAccountRequest = await request(server.url) 243 it('Should have valid twitter card if Twitter is whitelisted', async function () {
247 .get('/accounts/' + account.name) 244 const res1 = await getCustomConfig(server.url, server.accessToken)
248 .set('Accept', 'text/html') 245 const config = res1.body
249 .expect(200) 246 config.services.twitter = {
247 username: '@Kuja',
248 whitelisted: true
249 }
250 await updateCustomConfig(server.url, server.accessToken, config)
250 251
251 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 252 const resVideoRequest = await request(server.url)
252 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 253 .get('/videos/watch/' + server.video.uuid)
254 .set('Accept', 'text/html')
255 .expect(200)
253 256
254 const resChannelRequest = await request(server.url) 257 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />')
255 .get('/video-channels/' + server.videoChannel.name) 258 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
256 .set('Accept', 'text/html')
257 .expect(200)
258 259
259 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 260 const resVideoPlaylistRequest = await request(server.url)
260 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 261 .get('/videos/watch/playlist/' + playlistUUID)
261 }) 262 .set('Accept', 'text/html')
263 .expect(200)
262 264
263 it('Should have valid index html tags (title, description...)', async function () { 265 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />')
264 const res = await makeHTMLRequest(server.url, '/videos/trending') 266 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
265 267
266 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 268 const resAccountRequest = await request(server.url)
267 checkIndexTags(res.text, 'PeerTube', description, '') 269 .get('/accounts/' + account.name)
270 .set('Accept', 'text/html')
271 .expect(200)
272
273 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
274 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
275
276 const resChannelRequest = await request(server.url)
277 .get('/video-channels/' + server.videoChannel.name)
278 .set('Accept', 'text/html')
279 .expect(200)
280
281 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
282 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
283 })
268 }) 284 })
269 285
270 it('Should update the customized configuration and have the correct index html tags', async function () { 286 describe('Index HTML', function () {
271 await updateCustomSubConfig(server.url, server.accessToken, { 287
272 instance: { 288 it('Should have valid index html tags (title, description...)', async function () {
273 name: 'PeerTube updated', 289 const res = await makeHTMLRequest(server.url, '/videos/trending')
274 shortDescription: 'my short description', 290
275 description: 'my super description', 291 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
276 terms: 'my super terms', 292 checkIndexTags(res.text, 'PeerTube', description, '')
277 defaultClientRoute: '/videos/recently-added',
278 defaultNSFWPolicy: 'blur',
279 customizations: {
280 javascript: 'alert("coucou")',
281 css: 'body { background-color: red; }'
282 }
283 }
284 }) 293 })
285 294
286 const res = await makeHTMLRequest(server.url, '/videos/trending') 295 it('Should update the customized configuration and have the correct index html tags', async function () {
296 await updateCustomSubConfig(server.url, server.accessToken, {
297 instance: {
298 name: 'PeerTube updated',
299 shortDescription: 'my short description',
300 description: 'my super description',
301 terms: 'my super terms',
302 defaultClientRoute: '/videos/recently-added',
303 defaultNSFWPolicy: 'blur',
304 customizations: {
305 javascript: 'alert("coucou")',
306 css: 'body { background-color: red; }'
307 }
308 }
309 })
287 310
288 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 311 const res = await makeHTMLRequest(server.url, '/videos/trending')
289 }) 312
313 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
314 })
290 315
291 it('Should have valid index html updated tags (title, description...)', async function () { 316 it('Should have valid index html updated tags (title, description...)', async function () {
292 const res = await makeHTMLRequest(server.url, '/videos/trending') 317 const res = await makeHTMLRequest(server.url, '/videos/trending')
293 318
294 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 319 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
320 })
295 }) 321 })
296 322
297 after(async function () { 323 after(async function () {