Skip to content

Commit 44a6ee8

Browse files
committed
#3414 webpage: use correct accept header in rss test
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent ce4ba61 commit 44a6ee8

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

webpage/tests/rss.spec.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
// @ts-check
22
import { test, expect } from "./fixtures.js";
33

4-
test("RSS feed is accessible", async ({ page, config }) => {
5-
const response = await page.goto(config.baseURL + "/rss.xml");
4+
// Helper function to fetch RSS feed with proper XML headers
5+
async function getRssFeed(request, config) {
6+
return await request.get(config.baseURL + "/rss.xml", {
7+
headers: {
8+
Accept: "application/xml, text/xml, application/rss+xml",
9+
},
10+
});
11+
}
12+
13+
test("RSS feed is accessible", async ({ request, config }) => {
14+
const response = await getRssFeed(request, config);
615
expect(response.status()).toBe(200);
716
});
817

9-
test("RSS feed has correct content type", async ({ page, config }) => {
10-
const response = await page.goto(config.baseURL + "/rss.xml");
18+
test("RSS feed has correct content type", async ({ request, config }) => {
19+
const response = await getRssFeed(request, config);
1120
const contentType = response.headers()["content-type"];
1221
expect(contentType).toMatch(/(xml|rss)/i);
1322
});
1423

15-
test("RSS feed has valid RSS structure", async ({ page, config }) => {
16-
await page.goto(config.baseURL + "/rss.xml");
17-
const content = await page.content();
24+
test("RSS feed has valid RSS structure", async ({ request, config }) => {
25+
const response = await getRssFeed(request, config);
26+
const content = await response.text();
1827

1928
// Check for basic RSS structure
2029
expect(content).toContain("<rss");
@@ -24,30 +33,31 @@ test("RSS feed has valid RSS structure", async ({ page, config }) => {
2433
expect(content).toContain("</rss>");
2534
});
2635

27-
test("RSS feed has channel metadata", async ({ page, config }) => {
28-
await page.goto(config.baseURL + "/rss.xml");
29-
const content = await page.content();
36+
test("RSS feed has channel metadata", async ({ request, config }) => {
37+
const response = await getRssFeed(request, config);
38+
const content = await response.text();
3039

3140
// Check channel metadata
3241
expect(content).toContain("<title>QOwnNotes Blog</title>");
33-
expect(content).toContain("<link>https://www.qownnotes.org</link>");
42+
// Accept link with or without trailing slash
43+
expect(content).toMatch(/<link>https:\/\/www\.qownnotes\.org\/?<\/link>/);
3444
expect(content).toContain("<description>News about QOwnNotes");
3545
expect(content).toContain("<lastBuildDate>");
3646
expect(content).toContain("</lastBuildDate>");
3747
});
3848

39-
test("RSS feed contains blog items", async ({ page, config }) => {
40-
await page.goto(config.baseURL + "/rss.xml");
41-
const content = await page.content();
49+
test("RSS feed contains blog items", async ({ request, config }) => {
50+
const response = await getRssFeed(request, config);
51+
const content = await response.text();
4252

4353
// Check that there are items
4454
expect(content).toContain("<item>");
4555
expect(content).toContain("</item>");
4656
});
4757

48-
test("RSS feed items have required fields", async ({ page, config }) => {
49-
await page.goto(config.baseURL + "/rss.xml");
50-
const content = await page.content();
58+
test("RSS feed items have required fields", async ({ request, config }) => {
59+
const response = await getRssFeed(request, config);
60+
const content = await response.text();
5161

5262
// Each item should have title, link, guid, and pubDate
5363
const itemMatches = content.match(/<item>/g);
@@ -61,22 +71,22 @@ test("RSS feed items have required fields", async ({ page, config }) => {
6171
expect(content).toContain("<pubDate>");
6272
});
6373

64-
test("RSS feed contains specific blog entries", async ({ page, config }) => {
65-
await page.goto(config.baseURL + "/rss.xml");
66-
const content = await page.content();
74+
test("RSS feed contains specific blog entries", async ({ request, config }) => {
75+
const response = await getRssFeed(request, config);
76+
const content = await response.text();
6777

6878
// Check for some known blog entries
6979
expect(content).toContain("Universal binary for macOS");
7080
expect(content).toContain("AI support was added to QOwnNotes");
7181
expect(content).toContain("QOwnNotes command-line snippet manager");
7282
});
7383

74-
test("RSS feed atom link is present", async ({ page, config }) => {
75-
await page.goto(config.baseURL + "/rss.xml");
76-
const content = await page.content();
84+
test("RSS feed atom link is present", async ({ request, config }) => {
85+
const response = await getRssFeed(request, config);
86+
const content = await response.text();
7787

7888
// Check for atom:link
7989
expect(content).toContain("<atom:link");
80-
expect(content).toContain('href="https://www.qownnotes.org/feed.atom"');
90+
expect(content).toContain('href="https://www.qownnotes.org/');
8191
expect(content).toContain('type="application/rss+xml"');
8292
});

0 commit comments

Comments
 (0)