Fix services tests

This commit is contained in:
Chocobozzz 2025-02-13 16:32:21 +01:00
parent 327360c6b1
commit a4d9c461bb
No known key found for this signature in database
GPG Key ID: 583A612D890159BE

View File

@ -12,8 +12,11 @@ import {
describe('Test services', function () { describe('Test services', function () {
let server: PeerTubeServer = null let server: PeerTubeServer = null
let playlistShortUUID: string
let playlistUUID: string let playlistUUID: string
let playlistDisplayName: string let playlistDisplayName: string
let video: Video let video: Video
const urlSuffixes = [ const urlSuffixes = [
@ -57,6 +60,7 @@ describe('Test services', function () {
}) })
playlistUUID = created.uuid playlistUUID = created.uuid
playlistShortUUID = created.shortUUID
playlistDisplayName = 'The Life and Times of Scrooge McDuck' playlistDisplayName = 'The Life and Times of Scrooge McDuck'
await server.playlists.addElement({ await server.playlists.addElement({
@ -75,7 +79,7 @@ describe('Test services', function () {
const res = await server.services.getOEmbed({ oembedUrl }) const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' + const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' +
`title="${video.name}" src="http://${server.host}/videos/embed/${video.uuid}${suffix.output}" ` + `title="${video.name}" src="http://${server.host}/videos/embed/${video.shortUUID}${suffix.output}" ` +
'frameborder="0" allowfullscreen></iframe>' 'frameborder="0" allowfullscreen></iframe>'
const expectedThumbnailUrl = 'http://' + server.host + video.previewPath const expectedThumbnailUrl = 'http://' + server.host + video.previewPath
@ -99,7 +103,7 @@ describe('Test services', function () {
const res = await server.services.getOEmbed({ oembedUrl }) const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' + const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' +
`title="${playlistDisplayName}" src="http://${server.host}/video-playlists/embed/${playlistUUID}${suffix.output}" ` + `title="${playlistDisplayName}" src="http://${server.host}/video-playlists/embed/${playlistShortUUID}${suffix.output}" ` +
'frameborder="0" allowfullscreen></iframe>' 'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml) expect(res.body.html).to.equal(expectedHtml)
@ -120,7 +124,7 @@ describe('Test services', function () {
const res = await server.services.getOEmbed({ oembedUrl }) const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' + const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' +
`title="${video.name}" src="http://${server.host}/videos/embed/${video.uuid}${query}" ` + `title="${video.name}" src="http://${server.host}/videos/embed/${video.shortUUID}${query}" ` +
'frameborder="0" allowfullscreen></iframe>' 'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml) expect(res.body.html).to.equal(expectedHtml)
@ -135,7 +139,7 @@ describe('Test services', function () {
const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth }) const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' + const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" ' +
`title="${video.name}" src="http://${server.host}/videos/embed/${video.uuid}" ` + `title="${video.name}" src="http://${server.host}/videos/embed/${video.shortUUID}" ` +
'frameborder="0" allowfullscreen></iframe>' 'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml) expect(res.body.html).to.equal(expectedHtml)