feat: offer a non-Mews web page as a simplified view or in the browser

This commit is contained in:
randogoth 2026-10-12 11:13:34 +03:00
parent cea66fbb42
commit 00e42c925c
24 changed files with 863 additions and 152 deletions

View file

@ -35,15 +35,35 @@ void main() {
expect(ok.notModified, isFalse);
});
test('ParseSource reports broken markup with its source', () async {
test('ParseSource offers a web page as a simplified page', () async {
final actor = Actor.create(FetchHandler.new);
addTearDown(actor.close);
final result = await actor.send(
const ParseSource(url: 'https://example.com/broken.html', source: '<p>nope'));
final result = await actor.send(const ParseSource(
url: 'https://example.com/broken.html',
source: '<h1>Loose</h1><p>Never closed'));
expect(result, isA<FetchParseError>());
expect((result as FetchParseError).source, '<p>nope');
final error = result as FetchParseError;
// No conformance marker, so this is an ordinary web page rather than a
// Mews page with a markup error.
expect(error.declaresMews, isFalse);
expect(error.simplified, isNotNull);
expect(error.simplified!.body.whereType<HeadingBlock>(), isNotEmpty);
});
test('ParseSource reports a markup error on a page claiming Mews', () async {
final actor = Actor.create(FetchHandler.new);
addTearDown(actor.close);
final result = await actor.send(const ParseSource(
url: 'https://example.com/broken.html',
source: '<html><head><title>T</title>'
'<meta name="mews-profile" content="0.1"></head>'
'<body><p>Never closed</body></html>'));
expect(result, isA<FetchParseError>());
expect((result as FetchParseError).declaresMews, isTrue);
});
// The protocol transports are exercised through the same handler a fetch