Fetch RSS feeds via global fetch in browserless tests (#4879)

This commit is contained in:
Peter White
2026-12-03 08:14:04 +01:00
committed by GitHub
parent db7f9ffc71
commit c78d9bb669
+9 -6
View File
@@ -3,12 +3,18 @@ import Parser from 'rss-parser';
import { getContentTestURL } from './utils';
// Fetch via global fetch so the browserless preload attaches the Vercel protection bypass header.
async function parseFeed(url: string) {
const response = await fetch(url);
expect(response.status).toBe(200);
return new Parser().parseString(await response.text());
}
it('should expose a RSS feed for a page with updates', async () => {
const parser = new Parser();
const feedURL = getContentTestURL(
'https://gitbook.gitbook.io/test-gitbook-open/blocks/updates/rss.xml'
);
const feed = await parser.parseURL(feedURL);
const feed = await parseFeed(feedURL);
expect(feed.title).toBe('Updates | E2E Tests GitBook Open');
expect(feed.items.length).toBe(4);
@@ -16,10 +22,7 @@ it('should expose a RSS feed for a page with updates', async () => {
});
it('should keep list structure in RSS feed items', async () => {
const parser = new Parser();
const feed = await parser.parseURL(
getContentTestURL('https://gitbook.com/docs/changelog/rss.xml')
);
const feed = await parseFeed(getContentTestURL('https://gitbook.com/docs/changelog/rss.xml'));
const withList = feed.items.find((item) => item['content:encoded']?.includes('<ul>'));
expect(withList?.['content:encoded']).toMatch(/<ul><li>.+?<\/li><li>.+?<\/li>/);