Files
pipelines/app/test/features/artifacts/ui/artifact_selection_facts_test.dart
alan f46b82e207 Remove Cupertino branches from artifact features
Keep the Material implementation while preserving public parameters needed by callers. Remove Cupertino-only tests and variants because the app runs exclusively under MaterialApp.
2026-11-11 04:36:57 +00:00

72 lines
2.3 KiB
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<void> _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<Text>(find.text(metadata)).style;
final visitStyle = tester.widget<Text>(find.text(visit)).style;
final summaryStyle = tester.widget<Text>(find.text(summary)).style;
expect(metadataStyle?.color, secondary);
expect(visitStyle?.color, secondary);
expect(summaryStyle?.color, isNot(secondary));
});
}