mirror of https://github.com/Chocobozzz/PeerTube
Fix client tests
parent
54adc6f038
commit
ef1732e5b9
|
@ -24,7 +24,7 @@ describe('Test embed HTML generation', function () {
|
|||
let playlistName: string
|
||||
let playlistDescription: string
|
||||
|
||||
let instanceConfig: { shortDescription: string }
|
||||
let instanceConfig: { name: string, shortDescription: string }
|
||||
|
||||
before(async function () {
|
||||
this.timeout(120000);
|
||||
|
@ -59,7 +59,7 @@ describe('Test embed HTML generation', function () {
|
|||
it('Should have the correct embed html instance tags', async function () {
|
||||
const res = await makeHTMLRequest(servers[0].url, '/videos/embed/toto')
|
||||
|
||||
checkIndexTags(res.text, `PeerTube`, instanceConfig.shortDescription, '', config)
|
||||
checkIndexTags(res.text, instanceConfig.name, instanceConfig.shortDescription, '', config)
|
||||
|
||||
expect(res.text).to.not.contain(`"name":`)
|
||||
})
|
||||
|
@ -68,7 +68,7 @@ describe('Test embed HTML generation', function () {
|
|||
const config = await servers[0].config.getConfig()
|
||||
const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
|
||||
|
||||
checkIndexTags(res.text, `${videoName} - PeerTube`, videoDescriptionPlainText, '', config)
|
||||
checkIndexTags(res.text, `${videoName} - ${instanceConfig.name}`, videoDescriptionPlainText, '', config)
|
||||
|
||||
expect(res.text).to.contain(`"name":"${videoName}",`)
|
||||
})
|
||||
|
@ -77,7 +77,7 @@ describe('Test embed HTML generation', function () {
|
|||
const config = await servers[0].config.getConfig()
|
||||
const res = await makeHTMLRequest(servers[0].url, '/video-playlists/embed/' + playlistIds[0])
|
||||
|
||||
checkIndexTags(res.text, `${playlistName} - PeerTube`, playlistDescription, '', config)
|
||||
checkIndexTags(res.text, `${playlistName} - ${instanceConfig.name}`, playlistDescription, '', config)
|
||||
expect(res.text).to.contain(`"name":"${playlistName}",`)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -20,7 +20,10 @@ describe('Test index HTML generation', function () {
|
|||
let privatePlaylistId: string
|
||||
let unlistedPlaylistId: string
|
||||
|
||||
let instanceDescription: string
|
||||
let instanceConfig: {
|
||||
name: string
|
||||
shortDescription: string
|
||||
}
|
||||
|
||||
before(async function () {
|
||||
this.timeout(120000);
|
||||
|
@ -35,7 +38,8 @@ describe('Test index HTML generation', function () {
|
|||
passwordProtectedVideoId,
|
||||
unlistedVideoId,
|
||||
privatePlaylistId,
|
||||
unlistedPlaylistId
|
||||
unlistedPlaylistId,
|
||||
instanceConfig
|
||||
} = await prepareClientTests())
|
||||
})
|
||||
|
||||
|
@ -45,7 +49,7 @@ describe('Test index HTML generation', function () {
|
|||
const config = await servers[0].config.getConfig()
|
||||
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
|
||||
|
||||
checkIndexTags(res.text, 'PeerTube', instanceDescription, '', config)
|
||||
checkIndexTags(res.text, instanceConfig.name, instanceConfig.shortDescription, '', config)
|
||||
})
|
||||
|
||||
it('Should update the customized configuration and have the correct index html tags', async function () {
|
||||
|
|
|
@ -59,7 +59,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
expect(text).to.contain(`<meta property="og:description" content="${instanceConfig.shortDescription}" />`)
|
||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
||||
expect(text).to.contain(`<meta property="og:url" content="${url}`)
|
||||
expect(text).to.contain(`<meta property="og:image" content="${servers[0].url}/`)
|
||||
expect(text).to.contain(`<meta property="og:image:url" content="${servers[0].url}/`)
|
||||
}
|
||||
|
||||
async function accountPageTest (path: string) {
|
||||
|
@ -70,7 +70,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`)
|
||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
||||
expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/a/${servers[0].store.user.username}/video-channels" />`)
|
||||
expect(text).to.not.contain(`<meta property="og:image"`)
|
||||
expect(text).to.not.contain(`<meta property="og:image:url"`)
|
||||
}
|
||||
|
||||
async function channelPageTest (path: string) {
|
||||
|
@ -81,7 +81,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
|
||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
||||
expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/c/${servers[0].store.channel.name}/videos" />`)
|
||||
expect(text).to.contain(`<meta property="og:image" content="${servers[0].url}/`)
|
||||
expect(text).to.contain(`<meta property="og:image:url" content="${servers[0].url}/`)
|
||||
}
|
||||
|
||||
async function watchVideoPageTest (path: string) {
|
||||
|
@ -92,7 +92,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`)
|
||||
expect(text).to.contain('<meta property="og:type" content="video" />')
|
||||
expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].store.video.shortUUID}" />`)
|
||||
expect(text).to.contain(`<meta property="og:image" content="${servers[0].url}/`)
|
||||
expect(text).to.contain(`<meta property="og:image:url" content="${servers[0].url}/`)
|
||||
}
|
||||
|
||||
async function watchPlaylistPageTest (path: string) {
|
||||
|
@ -103,7 +103,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
expect(text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
|
||||
expect(text).to.contain('<meta property="og:type" content="video" />')
|
||||
expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/p/${playlist.shortUUID}" />`)
|
||||
expect(text).to.contain(`<meta property="og:image" content="${servers[0].url}/`)
|
||||
expect(text).to.contain(`<meta property="og:image:url" content="${servers[0].url}/`)
|
||||
}
|
||||
|
||||
it('Should have valid Open Graph tags on the common page', async function () {
|
||||
|
@ -167,7 +167,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
|
||||
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
|
||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
||||
expect(text).to.not.contain(`<meta property="twitter:image"`)
|
||||
expect(text).to.not.contain(`<meta property="twitter:image:url"`)
|
||||
}
|
||||
|
||||
async function channelPageTest (path: string) {
|
||||
|
@ -176,7 +176,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
|
||||
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
|
||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
||||
expect(text).to.contain(`<meta property="twitter:image" content="${servers[0].url}`)
|
||||
expect(text).to.contain(`<meta property="twitter:image:url" content="${servers[0].url}`)
|
||||
}
|
||||
|
||||
async function watchVideoPageTest (path: string) {
|
||||
|
@ -185,7 +185,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
|
||||
expect(text).to.contain('<meta property="twitter:card" content="player" />')
|
||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
||||
expect(text).to.contain(`<meta property="twitter:image" content="${servers[0].url}`)
|
||||
expect(text).to.contain(`<meta property="twitter:image:url" content="${servers[0].url}`)
|
||||
}
|
||||
|
||||
async function watchPlaylistPageTest (path: string) {
|
||||
|
@ -194,7 +194,7 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
|
|||
|
||||
expect(text).to.contain('<meta property="twitter:card" content="player" />')
|
||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
||||
expect(text).to.contain(`<meta property="twitter:image" content="${servers[0].url}`)
|
||||
expect(text).to.contain(`<meta property="twitter:image:url" content="${servers[0].url}`)
|
||||
}
|
||||
|
||||
it('Should have valid twitter card on the watch video page', async function () {
|
||||
|
|
|
@ -115,7 +115,7 @@ export class PlaylistHtml {
|
|||
|
||||
forbidIndexation: !playlist.isOwned() || playlist.privacy !== VideoPlaylistPrivacy.PUBLIC,
|
||||
|
||||
image: playlist.Thumbnail
|
||||
image: playlist.hasThumbnail()
|
||||
? { url: playlist.getThumbnailUrl(), width: playlist.Thumbnail.width, height: playlist.Thumbnail.height }
|
||||
: undefined,
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ export class TagsHtml {
|
|||
}
|
||||
|
||||
// SEO, use origin URL
|
||||
if (forbidIndexation === true && url) {
|
||||
if (forbidIndexation !== true && url) {
|
||||
tagsStr += `<link rel="canonical" href="${url}" />`
|
||||
}
|
||||
|
||||
|
@ -145,11 +145,14 @@ export class TagsHtml {
|
|||
const metaTags = {
|
||||
'og:type': tags.ogType,
|
||||
'og:site_name': tags.escapedSiteName,
|
||||
'og:title': tags.escapedTitle,
|
||||
'og:image': tags.image.url
|
||||
'og:title': tags.escapedTitle
|
||||
}
|
||||
|
||||
if (tags.image.width && tags.image.height) {
|
||||
if (tags.image?.url) {
|
||||
metaTags['og:image:url'] = tags.image.url
|
||||
}
|
||||
|
||||
if (tags.image?.width && tags.image?.height) {
|
||||
metaTags['og:image:width'] = tags.image.width
|
||||
metaTags['og:image:height'] = tags.image.height
|
||||
}
|
||||
|
@ -183,11 +186,14 @@ export class TagsHtml {
|
|||
'twitter:card': tags.twitterCard,
|
||||
'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME,
|
||||
'twitter:title': tags.escapedTitle,
|
||||
'twitter:description': tags.escapedTruncatedDescription,
|
||||
'twitter:image': tags.image.url
|
||||
'twitter:description': tags.escapedTruncatedDescription
|
||||
}
|
||||
|
||||
if (tags.image.width && tags.image.height) {
|
||||
if (tags.image?.url) {
|
||||
metaTags['twitter:image:url'] = tags.image.url
|
||||
}
|
||||
|
||||
if (tags.image?.width && tags.image?.height) {
|
||||
metaTags['twitter:image:width'] = tags.image.width
|
||||
metaTags['twitter:image:height'] = tags.image.height
|
||||
}
|
||||
|
@ -219,7 +225,7 @@ export class TagsHtml {
|
|||
'@type': 'Person',
|
||||
'name': tags.escapedTitle,
|
||||
'description': tags.escapedTruncatedDescription,
|
||||
'image': tags.image.url
|
||||
'image': tags.image?.url
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,13 +237,13 @@ export class TagsHtml {
|
|||
'@type': tags.schemaType,
|
||||
'name': tags.escapedTitle,
|
||||
'description': tags.escapedTruncatedDescription,
|
||||
'image': tags.image.url,
|
||||
'image': tags.image?.url,
|
||||
'url': tags.url
|
||||
}
|
||||
|
||||
if (tags.list) {
|
||||
schema['numberOfItems'] = tags.list.numberOfItems
|
||||
schema['thumbnailUrl'] = tags.image.url
|
||||
schema['thumbnailUrl'] = tags.image?.url
|
||||
}
|
||||
|
||||
if (tags.embed) {
|
||||
|
@ -246,7 +252,7 @@ export class TagsHtml {
|
|||
|
||||
if (tags.embed.duration) schema['duration'] = tags.embed.duration
|
||||
|
||||
schema['thumbnailUrl'] = tags.image.url
|
||||
schema['thumbnailUrl'] = tags.image?.url
|
||||
}
|
||||
|
||||
return Hooks.wrapObject(schema, 'filter:html.client.json-ld.result', context)
|
||||
|
|
Loading…
Reference in New Issue