mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-12-03 14:37:10 +00:00
Fetch RSS feeds via global fetch in browserless tests (#4879)
This commit is contained in:
@@ -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>/);
|
||||
|
||||
Reference in New Issue
Block a user