feat(app): artifact viewer previews the text family (logs, JSON, code, config) in bundled monospace
This commit is contained in:
@@ -93,14 +93,26 @@ void main() {
|
||||
('text/plain', 'memory.txt'),
|
||||
('text/plain', 'run.log'),
|
||||
('', 'output.md'),
|
||||
// The text family previews as selectable text, not an external file.
|
||||
('application/json', 'payload.json'),
|
||||
('text/x-python', 'main.py'),
|
||||
('application/octet-stream', 'config.yaml'),
|
||||
('', 'build.log'),
|
||||
]) {
|
||||
expect(isViewerArtifact(contentType, name), isTrue, reason: name);
|
||||
}
|
||||
expect(
|
||||
artifactPreviewFormat('application/json', 'payload.json'),
|
||||
ArtifactPreviewFormat.text,
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFormat('text/markdown', 'plan'),
|
||||
ArtifactPreviewFormat.markdown,
|
||||
);
|
||||
for (final (contentType, name) in <(String, String)>[
|
||||
('text/html', 'session.html'),
|
||||
('text/csv', 'rows.csv'),
|
||||
('application/json', 'payload.json'),
|
||||
('text/x-python', 'main.py'),
|
||||
('application/zip', 'bundle.zip'),
|
||||
('application/octet-stream', 'blob.bin'),
|
||||
('', ''),
|
||||
]) {
|
||||
|
||||
@@ -39,6 +39,7 @@ void main() {
|
||||
'input.md',
|
||||
'run.log',
|
||||
'shot.png',
|
||||
'main.py',
|
||||
'clip.mp4',
|
||||
'memory.txt',
|
||||
'output.md',
|
||||
@@ -161,7 +162,7 @@ void main() {
|
||||
sequence: 1,
|
||||
artifacts: <Map<String, dynamic>>[
|
||||
artifact('session.html', contentType: 'text/html'),
|
||||
artifact('main.py', contentType: 'text/x-python'),
|
||||
artifact('bundle.zip', contentType: 'application/zip'),
|
||||
artifact('result.csv', contentType: 'text/csv'),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
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';
|
||||
import 'package:pipelines_app/ui/text/monospace.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('a text-family preview is selectable bundled monospace', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ArtifactPreviewBody(
|
||||
plan: ArtifactPreviewPlan(
|
||||
kind: ArtifactPreviewKind.text,
|
||||
resolved: ResolvedArtifactUrl(
|
||||
uri: Uri.parse('http://127.0.0.1:8080/artifacts/1/main.py'),
|
||||
external: false,
|
||||
),
|
||||
message: '',
|
||||
),
|
||||
loading: false,
|
||||
markdownBuilder: defaultArtifactMarkdown,
|
||||
text: 'def main():\n return 0\n',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final text = tester.widget<SelectableText>(
|
||||
find.byKey(const Key('artifact-text-preview')),
|
||||
);
|
||||
expect(text.data, 'def main():\n return 0\n');
|
||||
expect(text.style?.fontFamily, appMonospaceFamily);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user