11/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
22
33import { expect } from 'chai'
4- import { HttpStatusCode , VideoPlaylistCreateResult } from '@peertube/peertube-models'
4+ import { HttpStatusCode , ServerConfig , VideoPlaylistCreateResult } from '@peertube/peertube-models'
55import { cleanupTests , makeGetRequest , makeHTMLRequest , PeerTubeServer } from '@peertube/peertube-server-commands'
66import { checkIndexTags , getWatchPlaylistBasePaths , getWatchVideoBasePaths , prepareClientTests } from '@tests/shared/client.js'
77
@@ -25,6 +25,8 @@ describe('Test index HTML generation', function () {
2525 shortDescription : string
2626 }
2727
28+ const getTitleWithSuffix = ( title : string , config : ServerConfig ) => `${ title } - ${ config . instance . name } `
29+
2830 before ( async function ( ) {
2931 this . timeout ( 120000 ) ;
3032
@@ -49,7 +51,7 @@ describe('Test index HTML generation', function () {
4951 const config = await servers [ 0 ] . config . getConfig ( )
5052 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
5153
52- checkIndexTags ( res . text , instanceConfig . name , instanceConfig . shortDescription , '' , config )
54+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , instanceConfig . shortDescription , '' , config )
5355 } )
5456
5557 it ( 'Should update the customized configuration and have the correct index html tags' , async function ( ) {
@@ -73,20 +75,25 @@ describe('Test index HTML generation', function () {
7375 const config = await servers [ 0 ] . config . getConfig ( )
7476 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
7577
76- checkIndexTags ( res . text , 'PeerTube updated' , 'my short description' , 'body { background-color: red; }' , config )
78+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , 'my short description' , 'body { background-color: red; }' , config )
7779 } )
7880
7981 it ( 'Should have valid index html updated tags (title, description...)' , async function ( ) {
8082 const config = await servers [ 0 ] . config . getConfig ( )
8183 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
8284
83- checkIndexTags ( res . text , 'PeerTube updated' , 'my short description' , 'body { background-color: red; }' , config )
85+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , 'my short description' , 'body { background-color: red; }' , config )
8486 } )
8587 } )
8688
8789 describe ( 'Canonical tags' , function ( ) {
8890
8991 it ( 'Should use the original video URL for the canonical tag' , async function ( ) {
92+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending?page=2' )
93+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /videos/trending?page=2" />` )
94+ } )
95+
96+ it ( 'Should use pagination in video URL for the canonical tag' , async function ( ) {
9097 for ( const basePath of getWatchVideoBasePaths ( ) ) {
9198 for ( const id of videoIds ) {
9299 const res = await makeHTMLRequest ( servers [ 0 ] . url , basePath + id )
@@ -114,6 +121,18 @@ describe('Test index HTML generation', function () {
114121 accountURLtest ( await makeHTMLRequest ( servers [ 0 ] . url , '/@root@' + servers [ 0 ] . host ) )
115122 } )
116123
124+ it ( 'Should use pagination in account video channels URL for the canonical tag' , async function ( ) {
125+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/a/root/video-channels?page=2' )
126+
127+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /a/root/video-channels?page=2" />` )
128+ } )
129+
130+ it ( 'Should use pagination in account videos URL for the canonical tag' , async function ( ) {
131+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/a/root/videos?page=2' )
132+
133+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /a/root/videos?page=2" />` )
134+ } )
135+
117136 it ( 'Should use the original channel URL for the canonical tag' , async function ( ) {
118137 const channelURLtests = res => {
119138 expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/videos" />` )
@@ -123,6 +142,19 @@ describe('Test index HTML generation', function () {
123142 channelURLtests ( await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel@' + servers [ 0 ] . host ) )
124143 channelURLtests ( await makeHTMLRequest ( servers [ 0 ] . url , '/@root_channel@' + servers [ 0 ] . host ) )
125144 } )
145+
146+ it ( 'Should use pagination in channel videos URL for the canonical tag' , async function ( ) {
147+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel/videos?page=2' )
148+
149+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/videos?page=2" />` )
150+ } )
151+
152+ it ( 'Should use pagination in channel playlists URL for the canonical tag' , async function ( ) {
153+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel/video-playlists?page=2' )
154+ console . log ( res . text )
155+
156+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/video-playlists?page=2" />` )
157+ } )
126158 } )
127159
128160 describe ( 'Indexation tags' , function ( ) {
0 commit comments