feat(app): artifact viewer renders HTML documents inertly (sandboxed iframe on web, script-free web view on mobile)

This commit is contained in:
2026-10-23 15:05:44 +01:00
parent 0fe3bfb5bb
commit e77628ac46
10 changed files with 188 additions and 3 deletions
@@ -109,6 +109,14 @@ void main() {
artifactPreviewFormat('text/markdown', 'plan'),
ArtifactPreviewFormat.markdown,
);
expect(
artifactPreviewFormat('text/html', 'report.html'),
ArtifactPreviewFormat.html,
);
expect(
artifactPreviewFormat('', 'session-repair-3-ab12.html'),
ArtifactPreviewFormat.none,
);
for (final (contentType, name) in <(String, String)>[
('text/html', 'session.html'),
('application/zip', 'bundle.zip'),
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_preview.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_url.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_content.dart';
void main() {
testWidgets('an HTML preview hands the fetched document to the renderer', (
tester,
) async {
final rendered = <String>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ArtifactPreviewBody(
plan: ArtifactPreviewPlan(
kind: ArtifactPreviewKind.html,
resolved: ResolvedArtifactUrl(
uri: Uri.parse('http://127.0.0.1:8080/artifacts/1/report.html'),
external: false,
),
message: '',
),
loading: false,
markdownBuilder: defaultArtifactMarkdown,
text: '<h1>Report</h1>',
htmlBuilder: (context, html) {
rendered.add(html);
return const Text('rendered');
},
),
),
),
);
expect(rendered, ['<h1>Report</h1>']);
expect(find.text('rendered'), findsOneWidget);
});
}