aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorDurgaraj Karki <raazkarkee405@gmail.com>2022-06-21 18:23:15 +0545
committerGitHub <noreply@github.com>2022-06-21 14:38:15 +0200
commitc8bac5396c4ed9ee82e0ef97b9051e9065d6a147 (patch)
treed3960b41819a260268a9f9dd097a2a36e510dcca /server/tests
parent6e391224d48e76bb2b26267dc3a8adeb27c99122 (diff)
downloadPeerTube-c8bac5396c4ed9ee82e0ef97b9051e9065d6a147.tar.gz
PeerTube-c8bac5396c4ed9ee82e0ef97b9051e9065d6a147.tar.zst
PeerTube-c8bac5396c4ed9ee82e0ef97b9051e9065d6a147.zip
fixes video not played from defined parameters in embed service (#5023)
* fixes video not played from defined parameters in embed service * adds parameters to the oembed services * Styling Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/services.ts34
1 files changed, 25 insertions, 9 deletions
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index 5fd2abda4..2f95f953b 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -13,6 +13,21 @@ describe('Test services', function () {
13 let playlistDisplayName: string 13 let playlistDisplayName: string
14 let video: Video 14 let video: Video
15 15
16 const urlSuffixes = [
17 {
18 input: '',
19 output: ''
20 },
21 {
22 input: '?param=1',
23 output: ''
24 },
25 {
26 input: '?muted=1&warningTitle=0&toto=1',
27 output: '?muted=1&warningTitle=0'
28 }
29 ]
30
16 before(async function () { 31 before(async function () {
17 this.timeout(30000) 32 this.timeout(30000)
18 33
@@ -52,14 +67,15 @@ describe('Test services', function () {
52 67
53 it('Should have a valid oEmbed video response', async function () { 68 it('Should have a valid oEmbed video response', async function () {
54 for (const basePath of [ '/videos/watch/', '/w/' ]) { 69 for (const basePath of [ '/videos/watch/', '/w/' ]) {
55 for (const suffix of [ '', '?param=1' ]) { 70 for (const suffix of urlSuffixes) {
56 const oembedUrl = server.url + basePath + video.uuid + suffix 71 const oembedUrl = server.url + basePath + video.uuid + suffix.input
57 72
58 const res = await server.services.getOEmbed({ oembedUrl }) 73 const res = await server.services.getOEmbed({ oembedUrl })
59 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' + 74 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' +
60 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` + 75 `title="${video.name}" src="http://${server.host}/videos/embed/${video.uuid}${suffix.output}" ` +
61 'frameborder="0" allowfullscreen></iframe>' 76 'frameborder="0" allowfullscreen></iframe>'
62 const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath 77
78 const expectedThumbnailUrl = 'http://' + server.host + video.previewPath
63 79
64 expect(res.body.html).to.equal(expectedHtml) 80 expect(res.body.html).to.equal(expectedHtml)
65 expect(res.body.title).to.equal(video.name) 81 expect(res.body.title).to.equal(video.name)
@@ -75,12 +91,12 @@ describe('Test services', function () {
75 91
76 it('Should have a valid playlist oEmbed response', async function () { 92 it('Should have a valid playlist oEmbed response', async function () {
77 for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) { 93 for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
78 for (const suffix of [ '', '?param=1' ]) { 94 for (const suffix of urlSuffixes) {
79 const oembedUrl = server.url + basePath + playlistUUID + suffix 95 const oembedUrl = server.url + basePath + playlistUUID + suffix.input
80 96
81 const res = await server.services.getOEmbed({ oembedUrl }) 97 const res = await server.services.getOEmbed({ oembedUrl })
82 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' + 98 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' +
83 `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` + 99 `title="${playlistDisplayName}" src="http://${server.host}/video-playlists/embed/${playlistUUID}${suffix.output}" ` +
84 'frameborder="0" allowfullscreen></iframe>' 100 'frameborder="0" allowfullscreen></iframe>'
85 101
86 expect(res.body.html).to.equal(expectedHtml) 102 expect(res.body.html).to.equal(expectedHtml)
@@ -97,14 +113,14 @@ describe('Test services', function () {
97 113
98 it('Should have a valid oEmbed response with small max height query', async function () { 114 it('Should have a valid oEmbed response with small max height query', async function () {
99 for (const basePath of [ '/videos/watch/', '/w/' ]) { 115 for (const basePath of [ '/videos/watch/', '/w/' ]) {
100 const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid 116 const oembedUrl = 'http://' + server.host + basePath + video.uuid
101 const format = 'json' 117 const format = 'json'
102 const maxHeight = 50 118 const maxHeight = 50
103 const maxWidth = 50 119 const maxWidth = 50
104 120
105 const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth }) 121 const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
106 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts allow-popups" ' + 122 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts allow-popups" ' +
107 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` + 123 `title="${video.name}" src="http://${server.host}/videos/embed/${video.uuid}" ` +
108 'frameborder="0" allowfullscreen></iframe>' 124 'frameborder="0" allowfullscreen></iframe>'
109 125
110 expect(res.body.html).to.equal(expectedHtml) 126 expect(res.body.html).to.equal(expectedHtml)