aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/client.ts181
1 files changed, 166 insertions, 15 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 670bc6701..648d46414 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -13,8 +13,14 @@ import {
13 serverLogin, 13 serverLogin,
14 updateCustomConfig, 14 updateCustomConfig,
15 updateCustomSubConfig, 15 updateCustomSubConfig,
16 uploadVideo 16 uploadVideo,
17 createVideoPlaylist,
18 addVideoInPlaylist,
19 getAccount,
20 addVideoChannel
17} from '../../shared/extra-utils' 21} from '../../shared/extra-utils'
22import { VideoPlaylistPrivacy } from '@shared/models'
23import { MVideoPlaylist, MAccount, MChannel } from '@server/types/models'
18 24
19const expect = chai.expect 25const expect = chai.expect
20 26
@@ -26,6 +32,11 @@ function checkIndexTags (html: string, title: string, description: string, css:
26 32
27describe('Test a client controllers', function () { 33describe('Test a client controllers', function () {
28 let server: ServerInfo 34 let server: ServerInfo
35 let videoPlaylist: MVideoPlaylist
36 let account: MAccount
37 let videoChannel: MChannel
38 const name = 'my super name for server 1'
39 const description = 'my super description for server 1'
29 40
30 before(async function () { 41 before(async function () {
31 this.timeout(120000) 42 this.timeout(120000)
@@ -33,18 +44,56 @@ describe('Test a client controllers', function () {
33 server = await flushAndRunServer(1) 44 server = await flushAndRunServer(1)
34 server.accessToken = await serverLogin(server) 45 server.accessToken = await serverLogin(server)
35 46
36 const videoAttributes = { 47 // Video
37 name: 'my super name for server 1', 48
38 description: 'my super description for server 1' 49 const videoAttributes = { name, description }
39 } 50
40 await uploadVideo(server.url, server.accessToken, videoAttributes) 51 await uploadVideo(server.url, server.accessToken, videoAttributes)
41 52
42 const res = await getVideosList(server.url) 53 const resVideosRequest = await getVideosList(server.url)
43 const videos = res.body.data 54
55 const videos = resVideosRequest.body.data
44 56
45 expect(videos.length).to.equal(1) 57 expect(videos.length).to.equal(1)
46 58
47 server.video = videos[0] 59 server.video = videos[0]
60
61 // Playlist
62
63 const playlistAttrs = {
64 displayName: name,
65 description,
66 privacy: VideoPlaylistPrivacy.PUBLIC
67 }
68
69 const resVideoPlaylistRequest = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs })
70
71 videoPlaylist = resVideoPlaylistRequest.body.videoPlaylist
72
73 await addVideoInPlaylist({
74 url: server.url,
75 token: server.accessToken,
76 playlistId: videoPlaylist.id,
77 elementAttrs: { videoId: server.video.id }
78 })
79
80 // Account
81
82 const resAccountRequest = await getAccount(server.url, `${server.user.username}@${server.host}:${server.port}`)
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
96 videoChannel = resChannelRequest.body.videoChannel
48 }) 97 })
49 98
50 it('Should have valid Open Graph tags on the watch page with video id', async function () { 99 it('Should have valid Open Graph tags on the watch page with video id', async function () {
@@ -53,8 +102,10 @@ describe('Test a client controllers', function () {
53 .set('Accept', 'text/html') 102 .set('Accept', 'text/html')
54 .expect(200) 103 .expect(200)
55 104
56 expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') 105 expect(res.text).to.contain(`<meta property="og:title" content="${name}" />`)
57 expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') 106 expect(res.text).to.contain(`<meta property="og:description" content="${description}" />`)
107 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}" />`)
58 }) 109 })
59 110
60 it('Should have valid Open Graph tags on the watch page with video uuid', async function () { 111 it('Should have valid Open Graph tags on the watch page with video uuid', async function () {
@@ -63,8 +114,46 @@ describe('Test a client controllers', function () {
63 .set('Accept', 'text/html') 114 .set('Accept', 'text/html')
64 .expect(200) 115 .expect(200)
65 116
66 expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') 117 expect(res.text).to.contain(`<meta property="og:title" content="${name}" />`)
67 expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') 118 expect(res.text).to.contain(`<meta property="og:description" content="${description}" />`)
119 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}" />`)
121 })
122
123 it('Should have valid Open Graph tags on the watch playlist page', async function () {
124 const res = await request(server.url)
125 .get('/videos/watch/playlist/' + videoPlaylist.uuid)
126 .set('Accept', 'text/html')
127 .expect(200)
128
129 expect(res.text).to.contain(`<meta property="og:title" content="${videoPlaylist.name}" />`)
130 expect(res.text).to.contain(`<meta property="og:description" content="${videoPlaylist.description}" />`)
131 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}" />`)
133 })
134
135 it('Should have valid Open Graph tags on the account page', async function () {
136 const res = await request(server.url)
137 .get('/accounts/' + server.user.username)
138 .set('Accept', 'text/html')
139 .expect(200)
140
141 expect(res.text).to.contain(`<meta property="og:title" content="${account.getDisplayName()}" />`)
142 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`)
143 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}" />`)
145 })
146
147 it('Should have valid Open Graph tags on the channel page', async function () {
148 const res = await request(server.url)
149 .get('/video-channels/' + videoChannel.name)
150 .set('Accept', 'text/html')
151 .expect(200)
152
153 expect(res.text).to.contain(`<meta property="og:title" content="${videoChannel.getDisplayName()}" />`)
154 expect(res.text).to.contain(`<meta property="og:description" content="${videoChannel.description}" />`)
155 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}" />`)
68 }) 157 })
69 158
70 it('Should have valid oEmbed discovery tags', async function () { 159 it('Should have valid oEmbed discovery tags', async function () {
@@ -81,7 +170,7 @@ describe('Test a client controllers', function () {
81 expect(res.text).to.contain(expectedLink) 170 expect(res.text).to.contain(expectedLink)
82 }) 171 })
83 172
84 it('Should have valid twitter card', async function () { 173 it('Should have valid twitter card on the whatch video page', async function () {
85 const res = await request(server.url) 174 const res = await request(server.url)
86 .get('/videos/watch/' + server.video.uuid) 175 .get('/videos/watch/' + server.video.uuid)
87 .set('Accept', 'text/html') 176 .set('Accept', 'text/html')
@@ -89,6 +178,44 @@ describe('Test a client controllers', function () {
89 178
90 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" />')
91 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 180 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
181 expect(res.text).to.contain(`<meta property="twitter:title" content="${name}" />`)
182 expect(res.text).to.contain(`<meta property="twitter:description" content="${description}" />`)
183 })
184
185 it('Should have valid twitter card on the watch playlist page', async function () {
186 const res = await request(server.url)
187 .get('/videos/watch/playlist/' + videoPlaylist.uuid)
188 .set('Accept', 'text/html')
189 .expect(200)
190
191 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
192 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
193 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoPlaylist.name}" />`)
194 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoPlaylist.description}" />`)
195 })
196
197 it('Should have valid twitter card on the account page', async function () {
198 const res = await request(server.url)
199 .get('/accounts/' + account.name)
200 .set('Accept', 'text/html')
201 .expect(200)
202
203 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
204 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
205 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
206 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
207 })
208
209 it('Should have valid twitter card on the channel page', async function () {
210 const res = await request(server.url)
211 .get('/video-channels/' + videoChannel.name)
212 .set('Accept', 'text/html')
213 .expect(200)
214
215 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
216 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
217 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoChannel.name}" />`)
218 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoChannel.description}" />`)
92 }) 219 })
93 220
94 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 () {
@@ -100,13 +227,37 @@ describe('Test a client controllers', function () {
100 } 227 }
101 await updateCustomConfig(server.url, server.accessToken, config) 228 await updateCustomConfig(server.url, server.accessToken, config)
102 229
103 const res = await request(server.url) 230 const resVideoRequest = await request(server.url)
104 .get('/videos/watch/' + server.video.uuid) 231 .get('/videos/watch/' + server.video.uuid)
105 .set('Accept', 'text/html') 232 .set('Accept', 'text/html')
106 .expect(200) 233 .expect(200)
107 234
108 expect(res.text).to.contain('<meta property="twitter:card" content="player" />') 235 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />')
109 expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 236 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
237
238 const resVideoPlaylistRequest = await request(server.url)
239 .get('/videos/watch/playlist/' + videoPlaylist.uuid)
240 .set('Accept', 'text/html')
241 .expect(200)
242
243 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />')
244 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
245
246 const resAccountRequest = await request(server.url)
247 .get('/accounts/' + account.name)
248 .set('Accept', 'text/html')
249 .expect(200)
250
251 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="player" />')
252 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
253
254 const resChannelRequest = await request(server.url)
255 .get('/video-channels/' + videoChannel.name)
256 .set('Accept', 'text/html')
257 .expect(200)
258
259 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="player" />')
260 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
110 }) 261 })
111 262
112 it('Should have valid index html tags (title, description...)', async function () { 263 it('Should have valid index html tags (title, description...)', async function () {