import 'package:flutter/cupertino.dart'; 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, {required bool cupertino}) 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( cupertino ? CupertinoApp( home: CupertinoPageScaffold( backgroundColor: CupertinoColors.systemGroupedBackground, child: facts, ), ) : MaterialApp(home: Scaffold(body: facts)), ); } void main() { for (final cupertino in [false, true]) { testWidgets( '${cupertino ? 'cupertino' : 'material'}: facts lead with metadata, then the visit, then its capture', (tester) async { await _pump(tester, cupertino: cupertino); 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 = cupertino ? CupertinoColors.secondaryLabel.resolveFrom(context) : 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)); }, ); } }