import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart'; import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart'; import 'package:pipelines_app/features/artifacts/ui/artifact_selection_facts.dart'; import '../domain/artifact_fixtures.dart'; JsonMap _recorded() => artifact( 'result.csv', url: '/artifacts/1/1/result.csv', contentType: 'text/csv', sizeBytes: 2048, ); ArtifactGroup _group() => ArtifactGroup( stageKey: 'review', visit: 1, artifacts: [ArtifactRecord.fromJson(_recorded())], ); Future _pump(WidgetTester tester) async { final group = _group(); final facts = Padding( padding: const EdgeInsets.all(16), child: ArtifactSelectionFacts( group: group, artifact: group.artifacts.single, step: step( stage: 'review', visit: 1, artifacts: [_recorded()], skipped: 2, ), resolved: null, ), ); await tester.pumpWidget(MaterialApp(home: Scaffold(body: facts))); } void main() { testWidgets('facts lead with metadata, then the visit, then its capture', ( tester, ) async { await _pump(tester); const metadata = 'text/csv · 2.0\u00a0KiB'; const visit = 'review · visit 1'; const summary = 'Artifacts · 1 recorded · partial capture'; const note = '2 files excluded from artifact capture.'; const urlState = 'The recorded artifact URL cannot be opened safely.'; double topOf(String text) => tester.getTopLeft(find.text(text)).dy; expect(topOf(metadata), lessThan(topOf(visit))); expect(topOf(visit), lessThan(topOf(summary))); expect(topOf(summary), lessThan(topOf(note))); expect(topOf(note), lessThan(topOf(urlState))); final context = tester.element(find.text(metadata)); final secondary = Theme.of(context).colorScheme.onSurfaceVariant; final metadataStyle = tester.widget(find.text(metadata)).style; final visitStyle = tester.widget(find.text(visit)).style; final summaryStyle = tester.widget(find.text(summary)).style; expect(metadataStyle?.color, secondary); expect(visitStyle?.color, secondary); expect(summaryStyle?.color, isNot(secondary)); }); }