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
@@ -22,6 +22,8 @@ describe('Test index HTML generation', function () {
2222
2323 let instanceDescription : string
2424
25+ const getTitleWithSuffix = ( title : string , config : ServerConfig ) => `${ title } - ${ config . instance . name } `
26+
2527 before ( async function ( ) {
2628 this . timeout ( 120000 ) ;
2729
@@ -46,7 +48,7 @@ describe('Test index HTML generation', function () {
4648 const config = await servers [ 0 ] . config . getConfig ( )
4749 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
4850
49- checkIndexTags ( res . text , 'PeerTube' , instanceDescription , '' , config )
51+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , instanceDescription , '' , config )
5052 } )
5153
5254 it ( 'Should update the customized configuration and have the correct index html tags' , async function ( ) {
@@ -70,20 +72,25 @@ describe('Test index HTML generation', function () {
7072 const config = await servers [ 0 ] . config . getConfig ( )
7173 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
7274
73- checkIndexTags ( res . text , 'PeerTube updated' , 'my short description' , 'body { background-color: red; }' , config )
75+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , 'my short description' , 'body { background-color: red; }' , config )
7476 } )
7577
7678 it ( 'Should have valid index html updated tags (title, description...)' , async function ( ) {
7779 const config = await servers [ 0 ] . config . getConfig ( )
7880 const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending' )
7981
80- checkIndexTags ( res . text , 'PeerTube updated' , 'my short description' , 'body { background-color: red; }' , config )
82+ checkIndexTags ( res . text , getTitleWithSuffix ( 'Trending' , config ) , 'my short description' , 'body { background-color: red; }' , config )
8183 } )
8284 } )
8385
8486 describe ( 'Canonical tags' , function ( ) {
8587
8688 it ( 'Should use the original video URL for the canonical tag' , async function ( ) {
89+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/videos/trending?page=2' )
90+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /videos/trending?page=2" />` )
91+ } )
92+
93+ it ( 'Should use pagination in video URL for the canonical tag' , async function ( ) {
8794 for ( const basePath of getWatchVideoBasePaths ( ) ) {
8895 for ( const id of videoIds ) {
8996 const res = await makeHTMLRequest ( servers [ 0 ] . url , basePath + id )
@@ -111,6 +118,18 @@ describe('Test index HTML generation', function () {
111118 accountURLtest ( await makeHTMLRequest ( servers [ 0 ] . url , '/@root@' + servers [ 0 ] . host ) )
112119 } )
113120
121+ it ( 'Should use pagination in account video channels URL for the canonical tag' , async function ( ) {
122+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/a/root/video-channels?page=2' )
123+
124+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /a/root/video-channels?page=2" />` )
125+ } )
126+
127+ it ( 'Should use pagination in account videos URL for the canonical tag' , async function ( ) {
128+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/a/root/videos?page=2' )
129+
130+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /a/root/videos?page=2" />` )
131+ } )
132+
114133 it ( 'Should use the original channel URL for the canonical tag' , async function ( ) {
115134 const channelURLtests = res => {
116135 expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/videos" />` )
@@ -120,6 +139,19 @@ describe('Test index HTML generation', function () {
120139 channelURLtests ( await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel@' + servers [ 0 ] . host ) )
121140 channelURLtests ( await makeHTMLRequest ( servers [ 0 ] . url , '/@root_channel@' + servers [ 0 ] . host ) )
122141 } )
142+
143+ it ( 'Should use pagination in channel videos URL for the canonical tag' , async function ( ) {
144+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel/videos?page=2' )
145+
146+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/videos?page=2" />` )
147+ } )
148+
149+ it ( 'Should use pagination in channel playlists URL for the canonical tag' , async function ( ) {
150+ const res = await makeHTMLRequest ( servers [ 0 ] . url , '/c/root_channel/video-playlists?page=2' )
151+ console . log ( res . text )
152+
153+ expect ( res . text ) . to . contain ( `<link rel="canonical" href="${ servers [ 0 ] . url } /c/root_channel/video-playlists?page=2" />` )
154+ } )
123155 } )
124156
125157 describe ( 'Indexation tags' , function ( ) {
0 commit comments