aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/services.ts46
-rw-r--r--server/tests/api/videos/services.ts75
-rw-r--r--server/tests/client.ts342
3 files changed, 288 insertions, 175 deletions
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index 457adfaab..e57edd9e4 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -8,11 +8,15 @@ import {
8 makeGetRequest, 8 makeGetRequest,
9 ServerInfo, 9 ServerInfo,
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 uploadVideo 11 uploadVideo,
12 createVideoPlaylist,
13 setDefaultVideoChannel
12} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { VideoPlaylistPrivacy } from '@shared/models'
13 16
14describe('Test services API validators', function () { 17describe('Test services API validators', function () {
15 let server: ServerInfo 18 let server: ServerInfo
19 let playlistUUID: string
16 20
17 // --------------------------------------------------------------- 21 // ---------------------------------------------------------------
18 22
@@ -21,9 +25,26 @@ describe('Test services API validators', function () {
21 25
22 server = await flushAndRunServer(1) 26 server = await flushAndRunServer(1)
23 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
24 28 await setDefaultVideoChannel([ server ])
25 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' }) 29
26 server.video = res.body.video 30 {
31 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
32 server.video = res.body.video
33 }
34
35 {
36 const res = await createVideoPlaylist({
37 url: server.url,
38 token: server.accessToken,
39 playlistAttrs: {
40 displayName: 'super playlist',
41 privacy: VideoPlaylistPrivacy.PUBLIC,
42 videoChannelId: server.videoChannel.id
43 }
44 })
45
46 playlistUUID = res.body.videoPlaylist.uuid
47 }
27 }) 48 })
28 49
29 describe('Test oEmbed API validators', function () { 50 describe('Test oEmbed API validators', function () {
@@ -38,12 +59,12 @@ describe('Test services API validators', function () {
38 await checkParamEmbed(server, embedUrl) 59 await checkParamEmbed(server, embedUrl)
39 }) 60 })
40 61
41 it('Should fail with an invalid video id', async function () { 62 it('Should fail with an invalid element id', async function () {
42 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla` 63 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
43 await checkParamEmbed(server, embedUrl) 64 await checkParamEmbed(server, embedUrl)
44 }) 65 })
45 66
46 it('Should fail with an unknown video', async function () { 67 it('Should fail with an unknown element', async function () {
47 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` 68 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
48 await checkParamEmbed(server, embedUrl, 404) 69 await checkParamEmbed(server, embedUrl, 404)
49 }) 70 })
@@ -78,7 +99,7 @@ describe('Test services API validators', function () {
78 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) 99 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
79 }) 100 })
80 101
81 it('Should succeed with the correct params', async function () { 102 it('Should succeed with the correct params with a video', async function () {
82 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 103 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
83 const query = { 104 const query = {
84 format: 'json', 105 format: 'json',
@@ -88,6 +109,17 @@ describe('Test services API validators', function () {
88 109
89 await checkParamEmbed(server, embedUrl, 200, query) 110 await checkParamEmbed(server, embedUrl, 200, query)
90 }) 111 })
112
113 it('Should succeed with the correct params with a playlist', async function () {
114 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}`
115 const query = {
116 format: 'json',
117 maxheight: 400,
118 maxwidth: 400
119 }
120
121 await checkParamEmbed(server, embedUrl, 200, query)
122 })
91 }) 123 })
92 124
93 after(async function () { 125 after(async function () {
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 5505a845a..897f37c04 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -1,14 +1,25 @@
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
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index' 4import * as chai from 'chai'
5import {
6 getOEmbed,
7 getVideosList,
8 ServerInfo,
9 setAccessTokensToServers,
10 setDefaultVideoChannel,
11 uploadVideo,
12 createVideoPlaylist,
13 addVideoInPlaylist
14} from '../../../../shared/extra-utils'
6import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' 15import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
16import { VideoPlaylistPrivacy } from '@shared/models'
7 17
8const expect = chai.expect 18const expect = chai.expect
9 19
10describe('Test services', function () { 20describe('Test services', function () {
11 let server: ServerInfo = null 21 let server: ServerInfo = null
22 let playlistUUID: string
12 23
13 before(async function () { 24 before(async function () {
14 this.timeout(30000) 25 this.timeout(30000)
@@ -16,17 +27,43 @@ describe('Test services', function () {
16 server = await flushAndRunServer(1) 27 server = await flushAndRunServer(1)
17 28
18 await setAccessTokensToServers([ server ]) 29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
19 31
20 const videoAttributes = { 32 {
21 name: 'my super name' 33 const videoAttributes = {
34 name: 'my super name'
35 }
36 await uploadVideo(server.url, server.accessToken, videoAttributes)
37
38 const res = await getVideosList(server.url)
39 server.video = res.body.data[0]
22 } 40 }
23 await uploadVideo(server.url, server.accessToken, videoAttributes)
24 41
25 const res = await getVideosList(server.url) 42 {
26 server.video = res.body.data[0] 43 const res = await createVideoPlaylist({
44 url: server.url,
45 token: server.accessToken,
46 playlistAttrs: {
47 displayName: 'The Life and Times of Scrooge McDuck',
48 privacy: VideoPlaylistPrivacy.PUBLIC,
49 videoChannelId: server.videoChannel.id
50 }
51 })
52
53 playlistUUID = res.body.videoPlaylist.uuid
54
55 await addVideoInPlaylist({
56 url: server.url,
57 token: server.accessToken,
58 playlistId: res.body.videoPlaylist.id,
59 elementAttrs: {
60 videoId: server.video.id
61 }
62 })
63 }
27 }) 64 })
28 65
29 it('Should have a valid oEmbed response', async function () { 66 it('Should have a valid oEmbed video response', async function () {
30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 67 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
31 68
32 const res = await getOEmbed(server.url, oembedUrl) 69 const res = await getOEmbed(server.url, oembedUrl)
@@ -37,7 +74,7 @@ describe('Test services', function () {
37 74
38 expect(res.body.html).to.equal(expectedHtml) 75 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name) 76 expect(res.body.title).to.equal(server.video.name)
40 expect(res.body.author_name).to.equal(server.video.account.name) 77 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
41 expect(res.body.width).to.equal(560) 78 expect(res.body.width).to.equal(560)
42 expect(res.body.height).to.equal(315) 79 expect(res.body.height).to.equal(315)
43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 80 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -45,6 +82,24 @@ describe('Test services', function () {
45 expect(res.body.thumbnail_height).to.equal(480) 82 expect(res.body.thumbnail_height).to.equal(480)
46 }) 83 })
47 84
85 it('Should have a valid playlist oEmbed response', async function () {
86 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/playlist/' + playlistUUID
87
88 const res = await getOEmbed(server.url, oembedUrl)
89 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
90 `src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
91 'frameborder="0" allowfullscreen></iframe>'
92
93 expect(res.body.html).to.equal(expectedHtml)
94 expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
95 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
96 expect(res.body.width).to.equal(560)
97 expect(res.body.height).to.equal(315)
98 expect(res.body.thumbnail_url).exist
99 expect(res.body.thumbnail_width).to.equal(223)
100 expect(res.body.thumbnail_height).to.equal(122)
101 })
102
48 it('Should have a valid oEmbed response with small max height query', async function () { 103 it('Should have a valid oEmbed response with small max height query', async function () {
49 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 104 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
50 const format = 'json' 105 const format = 'json'
@@ -58,7 +113,7 @@ describe('Test services', function () {
58 113
59 expect(res.body.html).to.equal(expectedHtml) 114 expect(res.body.html).to.equal(expectedHtml)
60 expect(res.body.title).to.equal(server.video.name) 115 expect(res.body.title).to.equal(server.video.name)
61 expect(res.body.author_name).to.equal(server.video.account.name) 116 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
62 expect(res.body.height).to.equal(50) 117 expect(res.body.height).to.equal(50)
63 expect(res.body.width).to.equal(50) 118 expect(res.body.width).to.equal(50)
64 expect(res.body).to.not.have.property('thumbnail_url') 119 expect(res.body).to.not.have.property('thumbnail_url')
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 () {