mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Fix client tests
This commit is contained in:
parent
54adc6f038
commit
ef1732e5b9
5 changed files with 38 additions and 28 deletions
|
@ -24,7 +24,7 @@ describe('Test embed HTML generation', function () {
|
||||||
let playlistName: string
|
let playlistName: string
|
||||||
let playlistDescription: string
|
let playlistDescription: string
|
||||||
|
|
||||||
let instanceConfig: { shortDescription: string }
|
let instanceConfig: { name: string, shortDescription: string }
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(120000);
|
this.timeout(120000);
|
||||||
|
@ -59,7 +59,7 @@ describe('Test embed HTML generation', function () {
|
||||||
it('Should have the correct embed html instance tags', async function () {
|
it('Should have the correct embed html instance tags', async function () {
|
||||||
const res = await makeHTMLRequest(servers[0].url, '/videos/embed/toto')
|
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":`)
|
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 config = await servers[0].config.getConfig()
|
||||||
const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
|
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}",`)
|
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 config = await servers[0].config.getConfig()
|
||||||
const res = await makeHTMLRequest(servers[0].url, '/video-playlists/embed/' + playlistIds[0])
|
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}",`)
|
expect(res.text).to.contain(`"name":"${playlistName}",`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,10 @@ describe('Test index HTML generation', function () {
|
||||||
let privatePlaylistId: string
|
let privatePlaylistId: string
|
||||||
let unlistedPlaylistId: string
|
let unlistedPlaylistId: string
|
||||||
|
|
||||||
let instanceDescription: string
|
let instanceConfig: {
|
||||||
|
name: string
|
||||||
|
shortDescription: string
|
||||||
|
}
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(120000);
|
this.timeout(120000);
|
||||||
|
@ -35,7 +38,8 @@ describe('Test index HTML generation', function () {
|
||||||
passwordProtectedVideoId,
|
passwordProtectedVideoId,
|
||||||
unlistedVideoId,
|
unlistedVideoId,
|
||||||
privatePlaylistId,
|
privatePlaylistId,
|
||||||
unlistedPlaylistId
|
unlistedPlaylistId,
|
||||||
|
instanceConfig
|
||||||
} = await prepareClientTests())
|
} = await prepareClientTests())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ describe('Test index HTML generation', function () {
|
||||||
const config = await servers[0].config.getConfig()
|
const config = await servers[0].config.getConfig()
|
||||||
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
|
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 () {
|
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:description" content="${instanceConfig.shortDescription}" />`)
|
||||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
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: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) {
|
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:description" content="${account.description}" />`)
|
||||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
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.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) {
|
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:description" content="${channelDescription}" />`)
|
||||||
expect(text).to.contain('<meta property="og:type" content="website" />')
|
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: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) {
|
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:description" content="${videoDescriptionPlainText}" />`)
|
||||||
expect(text).to.contain('<meta property="og:type" content="video" />')
|
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: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) {
|
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:description" content="${playlistDescription}" />`)
|
||||||
expect(text).to.contain('<meta property="og:type" content="video" />')
|
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: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 () {
|
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:card" content="summary" />')
|
||||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
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) {
|
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:card" content="summary" />')
|
||||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
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) {
|
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:card" content="player" />')
|
||||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
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) {
|
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:card" content="player" />')
|
||||||
expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
|
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 () {
|
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,
|
forbidIndexation: !playlist.isOwned() || playlist.privacy !== VideoPlaylistPrivacy.PUBLIC,
|
||||||
|
|
||||||
image: playlist.Thumbnail
|
image: playlist.hasThumbnail()
|
||||||
? { url: playlist.getThumbnailUrl(), width: playlist.Thumbnail.width, height: playlist.Thumbnail.height }
|
? { url: playlist.getThumbnailUrl(), width: playlist.Thumbnail.width, height: playlist.Thumbnail.height }
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ export class TagsHtml {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SEO, use origin URL
|
// SEO, use origin URL
|
||||||
if (forbidIndexation === true && url) {
|
if (forbidIndexation !== true && url) {
|
||||||
tagsStr += `<link rel="canonical" href="${url}" />`
|
tagsStr += `<link rel="canonical" href="${url}" />`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,11 +145,14 @@ export class TagsHtml {
|
||||||
const metaTags = {
|
const metaTags = {
|
||||||
'og:type': tags.ogType,
|
'og:type': tags.ogType,
|
||||||
'og:site_name': tags.escapedSiteName,
|
'og:site_name': tags.escapedSiteName,
|
||||||
'og:title': tags.escapedTitle,
|
'og:title': tags.escapedTitle
|
||||||
'og:image': tags.image.url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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:width'] = tags.image.width
|
||||||
metaTags['og:image:height'] = tags.image.height
|
metaTags['og:image:height'] = tags.image.height
|
||||||
}
|
}
|
||||||
|
@ -183,11 +186,14 @@ export class TagsHtml {
|
||||||
'twitter:card': tags.twitterCard,
|
'twitter:card': tags.twitterCard,
|
||||||
'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME,
|
'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME,
|
||||||
'twitter:title': tags.escapedTitle,
|
'twitter:title': tags.escapedTitle,
|
||||||
'twitter:description': tags.escapedTruncatedDescription,
|
'twitter:description': tags.escapedTruncatedDescription
|
||||||
'twitter:image': tags.image.url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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:width'] = tags.image.width
|
||||||
metaTags['twitter:image:height'] = tags.image.height
|
metaTags['twitter:image:height'] = tags.image.height
|
||||||
}
|
}
|
||||||
|
@ -219,7 +225,7 @@ export class TagsHtml {
|
||||||
'@type': 'Person',
|
'@type': 'Person',
|
||||||
'name': tags.escapedTitle,
|
'name': tags.escapedTitle,
|
||||||
'description': tags.escapedTruncatedDescription,
|
'description': tags.escapedTruncatedDescription,
|
||||||
'image': tags.image.url
|
'image': tags.image?.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,13 +237,13 @@ export class TagsHtml {
|
||||||
'@type': tags.schemaType,
|
'@type': tags.schemaType,
|
||||||
'name': tags.escapedTitle,
|
'name': tags.escapedTitle,
|
||||||
'description': tags.escapedTruncatedDescription,
|
'description': tags.escapedTruncatedDescription,
|
||||||
'image': tags.image.url,
|
'image': tags.image?.url,
|
||||||
'url': tags.url
|
'url': tags.url
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.list) {
|
if (tags.list) {
|
||||||
schema['numberOfItems'] = tags.list.numberOfItems
|
schema['numberOfItems'] = tags.list.numberOfItems
|
||||||
schema['thumbnailUrl'] = tags.image.url
|
schema['thumbnailUrl'] = tags.image?.url
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.embed) {
|
if (tags.embed) {
|
||||||
|
@ -246,7 +252,7 @@ export class TagsHtml {
|
||||||
|
|
||||||
if (tags.embed.duration) schema['duration'] = tags.embed.duration
|
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)
|
return Hooks.wrapObject(schema, 'filter:html.client.json-ld.result', context)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue