feat: read subscriptions from an Atom feed when a page lists no dated links

This commit is contained in:
randogoth 2026-10-11 13:35:19 +03:00
parent b0b86ef5b1
commit fa51d5793d
9 changed files with 411 additions and 4 deletions

View file

@ -240,4 +240,44 @@ void main() {
expect(quoteText, hasLength(3));
expect((quoteText[0] as MewsText).text, 'Quoted words ');
});
group('the atom feed link', () {
String pageWith(String link) => '''
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Signal Bars</title>
<meta name="mews-profile" content="0.1" />
$link
</head>
<body><h1>Signal Bars</h1></body>
</html>
''';
test('resolves against the page, so a relative href is usable', () {
final page = parseMewsPage(
source: pageWith(
'<link rel="alternate" type="application/atom+xml" href="feed.xml" />'),
url: 'https://example.com/posts/index.html',
);
expect(page.atomFeedHref, 'https://example.com/posts/feed.xml');
});
test('is refused when it points at another site', () {
// A client must not load another site's resources on its own
// (specs 7.4 and 8.1).
final page = parseMewsPage(
source: pageWith(
'<link rel="alternate" type="application/atom+xml" href="https://elsewhere.test/feed.xml" />'),
url: 'https://example.com/index.html',
);
expect(page.atomFeedHref, isNull);
});
test('is null when the page declares none', () {
final page = parseMewsPage(
source: pageWith(''), url: 'https://example.com/index.html');
expect(page.atomFeedHref, isNull);
});
});
}