feat(app): artifact viewer shows CSV and TSV files as tables
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_table.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_table_view.dart';
|
||||
|
||||
Widget _host(String text, {String delimiter = ','}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: ArtifactTableView(text: text, delimiter: delimiter),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('a CSV draws its header and cells, padding short rows', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(_host('id,name,score\n1,alpha,9\n2,"beta, b"\n'));
|
||||
final table = tester.widget<Table>(find.byType(Table));
|
||||
expect(table.children, hasLength(3));
|
||||
expect(table.children.every((row) => row.children.length == 3), isTrue);
|
||||
for (final text in ['id', 'name', 'score', 'alpha', 'beta, b']) {
|
||||
expect(find.text(text), findsOneWidget, reason: text);
|
||||
}
|
||||
expect(
|
||||
(table.children.first.decoration as BoxDecoration?)?.color,
|
||||
isNotNull,
|
||||
);
|
||||
expect(find.textContaining('Showing'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a capped table says how many rows it omits', (tester) async {
|
||||
final text = List.generate(
|
||||
artifactTableRowLimit + 20,
|
||||
(i) => 'r$i,v$i',
|
||||
).join('\n');
|
||||
await tester.pumpWidget(_host(text));
|
||||
expect(
|
||||
find.text(
|
||||
'Showing $artifactTableRowLimit of ${artifactTableRowLimit + 20} '
|
||||
'rows. Open the file for the rest.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('an empty table says so', (tester) async {
|
||||
await tester.pumpWidget(_host(''));
|
||||
expect(find.text('The table is empty.'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user