merge(app): land artifacts-layout

This commit is contained in:
2026-10-22 15:07:11 +01:00
6 changed files with 550 additions and 64 deletions
@@ -53,20 +53,33 @@ Future<void> _pumpGallery(
WidgetTester tester,
_Platform platform,
List<JsonMap> steps, {
int? focusIndex,
String configuredEndpoint = '',
bool executing = false,
Future<bool> Function(Uri)? openExternal,
Size surface = const Size(800, 600),
double textScale = 1,
}) async {
tester.view.physicalSize = surface;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final page = ArtifactGalleryPage(
steps: steps,
focusIndex: focusIndex,
executing: executing,
configuredEndpoint: configuredEndpoint,
openExternal: openExternal ?? (_) async => true,
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(home: page)
: CupertinoApp(home: page),
MediaQuery(
data: MediaQueryData(
size: surface,
textScaler: TextScaler.linear(textScale),
),
child: platform == _Platform.material
? MaterialApp(home: page)
: CupertinoApp(home: page),
),
);
await tester.pumpAndSettle();
}
@@ -318,4 +331,177 @@ void main() {
], executing: true);
expect(find.text('Artifacts · capture pending'), findsOneWidget);
});
testWidgets('the run header names the visit each capture note belongs to', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
step(
stage: 'review',
visit: 1,
artifacts: [_recorded('first.csv')],
skipped: 2,
),
step(
stage: 'review',
sequence: 2,
visit: 2,
artifacts: [_recorded('second.csv')],
truncated: 3,
),
]);
expect(
find.text('review · visit 1 · 2 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
find.text(
'review · visit 2 · 3 files omitted by artifact capture limits.',
),
findsOneWidget,
);
expect(find.text('2 files excluded from artifact capture.'), findsNothing);
});
testWidgets('a focused visit header states its own notes without a prefix', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
step(
stage: 'review',
visit: 1,
artifacts: [_recorded('result.csv')],
skipped: 2,
truncated: 3,
),
step(
stage: 'review',
sequence: 2,
visit: 2,
artifacts: [_recorded('later.csv')],
),
], focusIndex: 0);
expect(
find.text('Artifacts · 1 recorded · partial capture'),
findsOneWidget,
);
expect(
find.text('2 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
find.text('3 files omitted by artifact capture limits.'),
findsOneWidget,
);
expect(find.text('later.csv'), findsNothing);
});
testWidgets('a complete capture adds no header notes', (tester) async {
await _pumpGallery(tester, _Platform.material, [
step(stage: 'review', visit: 1, artifacts: [_recorded('result.csv')]),
]);
expect(find.text('Artifact · 1 recorded'), findsOneWidget);
expect(find.textContaining('files excluded'), findsNothing);
expect(find.textContaining('files omitted'), findsNothing);
});
for (final platform in _Platform.values) {
testWidgets(
'${platform.name}: a long run header scrolls with the gallery rows',
(tester) async {
// Ten partial visits at a phone surface: the header is taller than the
// free space a fixed sibling could get without taking the list's.
await _pumpGallery(tester, platform, <JsonMap>[
for (var visit = 1; visit <= 10; visit += 1)
step(
stage: 'review',
sequence: visit,
visit: visit,
artifacts: [_recorded('file$visit.csv')],
skipped: 1,
),
], surface: const Size(360, 640));
expect(tester.takeException(), isNull);
final list = find.byType(ListView);
expect(tester.getSize(list).height, greaterThan(0));
// The header belongs to that scroll view, so it scrolls away instead of
// shrinking the list.
expect(
find.descendant(
of: list,
matching: find.text('Artifacts · 10 recorded · partial capture'),
),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('file10.csv'), 200);
expect(find.text('file10.csv'), findsOneWidget);
},
);
testWidgets(
'${platform.name}: focused notes at 2x text keep the artifact list',
(tester) async {
await _pumpGallery(
tester,
platform,
[
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('result.csv', url: '/artifacts/1/1/result.csv'),
],
skipped: 12,
truncated: 34,
),
],
focusIndex: 0,
surface: const Size(320, 568),
textScale: 2,
);
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(ListView)).height, greaterThan(0));
expect(
find.text('12 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
find.text('34 files omitted by artifact capture limits.'),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('result.csv'), 200);
expect(find.text('result.csv'), findsOneWidget);
},
);
testWidgets(
'${platform.name}: sheet actions keep Close, Copy, Open order',
(tester) async {
await _pumpGallery(tester, platform, [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('result.csv', url: '/artifacts/1/1/result.csv'),
],
),
], configuredEndpoint: 'ws://127.0.0.1:8081/connect');
await tester.tap(find.text('result.csv'));
await tester.pumpAndSettle();
double orderOf(String label) {
final offset = tester.getTopLeft(_inDialog(platform, label));
return platform == _Platform.material ? offset.dx : offset.dy;
}
expect(orderOf('Close'), lessThan(orderOf('Copy link')));
expect(orderOf('Copy link'), lessThan(orderOf('Open')));
},
);
}
}
@@ -0,0 +1,86 @@
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<void> _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 <bool>[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<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));
},
);
}
}
@@ -227,4 +227,99 @@ void main() {
expect(find.text('No stage artifacts recorded.'), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
});
testWidgets('Material sections get a muted heading and hairline row rules', (
tester,
) async {
final first = visitGroup(
visit: 1,
artifacts: [
recordedArtifact('first.csv', url: '/artifacts/7/1/first.csv'),
recordedArtifact('second.csv', url: '/artifacts/7/1/second.csv'),
],
);
final second = visitGroup(
visit: 2,
artifacts: [
recordedArtifact('third.csv', url: '/artifacts/7/2/third.csv'),
],
);
await tester.pumpWidget(
artifactListHost(cupertino: false, groups: [first, second]),
);
// One rule between the two rows of the first visit; the single-row visit
// neither opens nor closes on a rule.
expect(find.byType(Divider), findsOneWidget);
final divider = tester.widget<Divider>(find.byType(Divider));
expect(divider.height, 1);
expect(divider.indent, 16);
expect(divider.endIndent, 16);
final context = tester.element(find.text('review · visit 1'));
final heading = tester.widget<Text>(find.text('review · visit 1'));
expect(
heading.style?.color,
Theme.of(context).colorScheme.onSurfaceVariant,
);
});
testWidgets('a page header scrolls inside the list, not above it', (
tester,
) async {
final group = visitGroup(
visit: 1,
artifacts: [
recordedArtifact('first.csv', url: '/artifacts/7/1/first.csv'),
],
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ArtifactVisitList(
groups: [group],
header: const Text('Artifacts · 1 recorded'),
),
),
),
);
final list = find.byType(ListView);
expect(list, findsOneWidget);
expect(
find.descendant(of: list, matching: find.text('Artifacts · 1 recorded')),
findsOneWidget,
);
expect(find.text('first.csv'), findsOneWidget);
});
testWidgets('a header still leads the honest empty list', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ArtifactVisitList(
groups: <ArtifactGroup>[],
header: Text('Artifacts · 0 recorded'),
),
),
),
);
expect(find.text('Artifacts · 0 recorded'), findsOneWidget);
expect(find.text('No stage artifacts recorded.'), findsOneWidget);
});
testWidgets('Cupertino keeps its native section separators', (tester) async {
final group = visitGroup(
visit: 1,
artifacts: [
recordedArtifact('first.csv', url: '/artifacts/7/1/first.csv'),
recordedArtifact('second.csv', url: '/artifacts/7/1/second.csv'),
],
);
await tester.pumpWidget(artifactListHost(cupertino: true, groups: [group]));
expect(find.byType(Divider), findsNothing);
expect(find.byType(CupertinoListSection), findsOneWidget);
});
}