aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/config.ts6
-rw-r--r--server/tests/api/server/config.ts14
-rw-r--r--server/tests/client.ts30
3 files changed, 49 insertions, 1 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 58b780f38..6aa31e38d 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -26,6 +26,12 @@ describe('Test config API validators', function () {
26 css: 'body { background-color: red; }' 26 css: 'body { background-color: red; }'
27 } 27 }
28 }, 28 },
29 services: {
30 twitter: {
31 username: '@MySuperUsername',
32 whitelisted: true
33 }
34 },
29 cache: { 35 cache: {
30 previews: { 36 previews: {
31 size: 2 37 size: 2
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 3f1b1532c..f24961b85 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -62,6 +62,8 @@ describe('Test config', function () {
62 expect(data.instance.defaultNSFWPolicy).to.equal('display') 62 expect(data.instance.defaultNSFWPolicy).to.equal('display')
63 expect(data.instance.customizations.css).to.be.empty 63 expect(data.instance.customizations.css).to.be.empty
64 expect(data.instance.customizations.javascript).to.be.empty 64 expect(data.instance.customizations.javascript).to.be.empty
65 expect(data.services.twitter.username).to.equal('@Chocobozzz')
66 expect(data.services.twitter.whitelisted).to.be.false
65 expect(data.cache.previews.size).to.equal(1) 67 expect(data.cache.previews.size).to.equal(1)
66 expect(data.signup.enabled).to.be.true 68 expect(data.signup.enabled).to.be.true
67 expect(data.signup.limit).to.equal(4) 69 expect(data.signup.limit).to.equal(4)
@@ -90,6 +92,12 @@ describe('Test config', function () {
90 css: 'body { background-color: red; }' 92 css: 'body { background-color: red; }'
91 } 93 }
92 }, 94 },
95 services: {
96 twitter: {
97 username: '@Kuja',
98 whitelisted: true
99 }
100 },
93 cache: { 101 cache: {
94 previews: { 102 previews: {
95 size: 2 103 size: 2
@@ -130,6 +138,8 @@ describe('Test config', function () {
130 expect(data.instance.defaultNSFWPolicy).to.equal('blur') 138 expect(data.instance.defaultNSFWPolicy).to.equal('blur')
131 expect(data.instance.customizations.javascript).to.equal('alert("coucou")') 139 expect(data.instance.customizations.javascript).to.equal('alert("coucou")')
132 expect(data.instance.customizations.css).to.equal('body { background-color: red; }') 140 expect(data.instance.customizations.css).to.equal('body { background-color: red; }')
141 expect(data.services.twitter.username).to.equal('@Kuja')
142 expect(data.services.twitter.whitelisted).to.be.true
133 expect(data.cache.previews.size).to.equal(2) 143 expect(data.cache.previews.size).to.equal(2)
134 expect(data.signup.enabled).to.be.false 144 expect(data.signup.enabled).to.be.false
135 expect(data.signup.limit).to.equal(5) 145 expect(data.signup.limit).to.equal(5)
@@ -162,6 +172,8 @@ describe('Test config', function () {
162 expect(data.instance.defaultNSFWPolicy).to.equal('blur') 172 expect(data.instance.defaultNSFWPolicy).to.equal('blur')
163 expect(data.instance.customizations.javascript).to.equal('alert("coucou")') 173 expect(data.instance.customizations.javascript).to.equal('alert("coucou")')
164 expect(data.instance.customizations.css).to.equal('body { background-color: red; }') 174 expect(data.instance.customizations.css).to.equal('body { background-color: red; }')
175 expect(data.services.twitter.username).to.equal('@Kuja')
176 expect(data.services.twitter.whitelisted).to.be.true
165 expect(data.cache.previews.size).to.equal(2) 177 expect(data.cache.previews.size).to.equal(2)
166 expect(data.signup.enabled).to.be.false 178 expect(data.signup.enabled).to.be.false
167 expect(data.signup.limit).to.equal(5) 179 expect(data.signup.limit).to.equal(5)
@@ -205,6 +217,8 @@ describe('Test config', function () {
205 expect(data.instance.defaultNSFWPolicy).to.equal('display') 217 expect(data.instance.defaultNSFWPolicy).to.equal('display')
206 expect(data.instance.customizations.css).to.be.empty 218 expect(data.instance.customizations.css).to.be.empty
207 expect(data.instance.customizations.javascript).to.be.empty 219 expect(data.instance.customizations.javascript).to.be.empty
220 expect(data.services.twitter.username).to.equal('@Chocobozzz')
221 expect(data.services.twitter.whitelisted).to.be.false
208 expect(data.cache.previews.size).to.equal(1) 222 expect(data.cache.previews.size).to.equal(1)
209 expect(data.signup.enabled).to.be.true 223 expect(data.signup.enabled).to.be.true
210 expect(data.signup.limit).to.equal(4) 224 expect(data.signup.limit).to.equal(4)
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 2be1cf5dd..2adb39c5e 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -11,7 +11,7 @@ import {
11 runServer, 11 runServer,
12 serverLogin, 12 serverLogin,
13 uploadVideo, 13 uploadVideo,
14 getVideosList 14 getVideosList, updateCustomConfig, getCustomConfig
15} from './utils' 15} from './utils'
16 16
17describe('Test a client controllers', function () { 17describe('Test a client controllers', function () {
@@ -73,6 +73,34 @@ describe('Test a client controllers', function () {
73 expect(res.text).to.contain(expectedLink) 73 expect(res.text).to.contain(expectedLink)
74 }) 74 })
75 75
76 it('Should have valid twitter card', async function () {
77 const res = await request(server.url)
78 .get('/videos/watch/' + server.video.uuid)
79 .set('Accept', 'text/html')
80 .expect(200)
81
82 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
83 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
84 })
85
86 it('Should have valid twitter card if Twitter is whitelisted', async function () {
87 const res1 = await getCustomConfig(server.url, server.accessToken)
88 const config = res1.body
89 config.services.twitter = {
90 username: '@Kuja',
91 whitelisted: true
92 }
93 await updateCustomConfig(server.url, server.accessToken, config)
94
95 const res = await request(server.url)
96 .get('/videos/watch/' + server.video.uuid)
97 .set('Accept', 'text/html')
98 .expect(200)
99
100 expect(res.text).to.contain('<meta property="twitter:card" content="player" />')
101 expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
102 })
103
76 after(async function () { 104 after(async function () {
77 process.kill(-server.app.pid) 105 process.kill(-server.app.pid)
78 106