@@ -1133,7 +1133,7 @@ describe('GET /sitemaps/archive-index.xml', () => {
11331133 rankingType : ArchiveRankingType . Best ,
11341134 } ;
11351135
1136- it ( 'should return index pages for tags and sources with archives' , async ( ) => {
1136+ it ( 'should return index pages for global, tag, and source archives' , async ( ) => {
11371137 const createdAt = new Date ( '2025-03-01T10:00:00.000Z' ) ;
11381138
11391139 await con . getRepository ( Archive ) . save ( [
@@ -1190,11 +1190,14 @@ describe('GET /sitemaps/archive-index.xml', () => {
11901190 expect ( res . text ) . toContain (
11911191 '<loc>http://localhost:5002/tags/rust/best-of</loc>' ,
11921192 ) ;
1193- // Global archives should not appear
1194- expect ( res . text ) . not . toContain ( '/best-of</loc>\n' ) ;
1193+ expect ( res . text ) . toContain (
1194+ '<loc>http://localhost:5002/posts/best-of</loc>' ,
1195+ ) ;
11951196 // Only one entry for rust (two archives but one index)
11961197 const rustMatches = res . text . match ( / \/ t a g s \/ r u s t \/ b e s t - o f < \/ l o c > / g) ;
11971198 expect ( rustMatches ) . toHaveLength ( 1 ) ;
1199+ const globalMatches = res . text . match ( / \/ p o s t s \/ b e s t - o f < \/ l o c > / g) ;
1200+ expect ( globalMatches ) . toHaveLength ( 1 ) ;
11981201 } ) ;
11991202
12001203 it ( 'should exclude source archives when the source has been deleted' , async ( ) => {
@@ -1334,6 +1337,52 @@ describe('GET /sitemaps/archive-pages-:scopeType-:periodType-:page.xml', () => {
13341337 ) ;
13351338 } ) ;
13361339
1340+ it ( 'should return global monthly archive pages' , async ( ) => {
1341+ const createdAt = new Date ( '2025-04-01T10:00:00.000Z' ) ;
1342+
1343+ await con . getRepository ( Archive ) . save ( [
1344+ {
1345+ ...archiveBase ,
1346+ scopeType : ArchiveScopeType . Global ,
1347+ scopeId : null ,
1348+ periodType : ArchivePeriodType . Month ,
1349+ periodStart : new Date ( '2025-03-01T00:00:00.000Z' ) ,
1350+ createdAt,
1351+ } ,
1352+ ] ) ;
1353+
1354+ const res = await request ( app . server )
1355+ . get ( '/sitemaps/archive-pages-global-month-0.xml' )
1356+ . expect ( 200 ) ;
1357+
1358+ expect ( res . text ) . toContain (
1359+ '<loc>http://localhost:5002/posts/best-of/2025/03</loc>' ,
1360+ ) ;
1361+ } ) ;
1362+
1363+ it ( 'should return global yearly archive pages' , async ( ) => {
1364+ const createdAt = new Date ( '2025-04-01T10:00:00.000Z' ) ;
1365+
1366+ await con . getRepository ( Archive ) . save ( [
1367+ {
1368+ ...archiveBase ,
1369+ scopeType : ArchiveScopeType . Global ,
1370+ scopeId : null ,
1371+ periodType : ArchivePeriodType . Year ,
1372+ periodStart : new Date ( '2024-01-01T00:00:00.000Z' ) ,
1373+ createdAt,
1374+ } ,
1375+ ] ) ;
1376+
1377+ const res = await request ( app . server )
1378+ . get ( '/sitemaps/archive-pages-global-year-0.xml' )
1379+ . expect ( 200 ) ;
1380+
1381+ expect ( res . text ) . toContain (
1382+ '<loc>http://localhost:5002/posts/best-of/2024</loc>' ,
1383+ ) ;
1384+ } ) ;
1385+
13371386 it ( 'should return 404 for invalid scopeType' , async ( ) => {
13381387 await request ( app . server )
13391388 . get ( '/sitemaps/archive-pages-invalid-month-0.xml' )
@@ -1416,6 +1465,14 @@ describe('GET /sitemaps/index.xml (archive entries)', () => {
14161465
14171466 it ( 'should include archive-index and paginated archive-pages sitemaps' , async ( ) => {
14181467 await con . getRepository ( Archive ) . save ( [
1468+ {
1469+ ...archiveBase ,
1470+ scopeType : ArchiveScopeType . Global ,
1471+ scopeId : null ,
1472+ periodType : ArchivePeriodType . Month ,
1473+ periodStart : new Date ( '2025-02-01T00:00:00.000Z' ) ,
1474+ createdAt : new Date ( ) ,
1475+ } ,
14191476 {
14201477 ...archiveBase ,
14211478 scopeType : ArchiveScopeType . Tag ,
@@ -1441,6 +1498,9 @@ describe('GET /sitemaps/index.xml (archive entries)', () => {
14411498 expect ( res . text ) . toContain (
14421499 '<loc>http://localhost:5002/api/sitemaps/archive-index.xml</loc>' ,
14431500 ) ;
1501+ expect ( res . text ) . toContain (
1502+ '<loc>http://localhost:5002/api/sitemaps/archive-pages-global-month-0.xml</loc>' ,
1503+ ) ;
14441504 expect ( res . text ) . toContain (
14451505 '<loc>http://localhost:5002/api/sitemaps/archive-pages-tag-month-0.xml</loc>' ,
14461506 ) ;
0 commit comments