merge(app): land artifacts-layout
This commit is contained in:
@@ -83,7 +83,8 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
// The visit pane sees the same document-enriched group the gallery shows for
|
||||
// that visit, not only its recorded files.
|
||||
for (final enriched in galleryGroups(widget.steps)) {
|
||||
if (enriched.stageKey == group.stageKey && enriched.visit == group.visit) {
|
||||
if (enriched.stageKey == group.stageKey &&
|
||||
enriched.visit == group.visit) {
|
||||
// The visit pane's own Session section opens session.html, so the
|
||||
// per-visit Artifacts drill-down keeps only stage output and the other
|
||||
// turn documents; the run-wide gallery still shows every document.
|
||||
@@ -193,21 +194,21 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
if (resolved != null)
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => _copyLink(resolved, dialogContext),
|
||||
child: const Text('Copy link'),
|
||||
),
|
||||
if (resolved != null)
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => _open(resolved, dialogContext),
|
||||
child: const Text('Open'),
|
||||
),
|
||||
if (resolved != null)
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => _copyLink(resolved, dialogContext),
|
||||
child: const Text('Copy link'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -218,15 +219,15 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
content: SingleChildScrollView(child: content),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
if (resolved != null)
|
||||
TextButton(
|
||||
onPressed: () => _copyLink(resolved, dialogContext),
|
||||
child: const Text('Copy link'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
if (resolved != null)
|
||||
TextButton(
|
||||
onPressed: () => _open(resolved, dialogContext),
|
||||
@@ -267,14 +268,25 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
setState(() => _status = message);
|
||||
}
|
||||
|
||||
/// The step a focused page shows, or null when the page covers the whole run.
|
||||
///
|
||||
/// [focusIndex] comes from the opening visit pane, so it is validated once
|
||||
/// here rather than in each of the summary, notes and group builders.
|
||||
JsonMap? get _focusedStep {
|
||||
final focusIndex = widget.focusIndex;
|
||||
if (focusIndex == null ||
|
||||
focusIndex < 0 ||
|
||||
focusIndex >= widget.steps.length) {
|
||||
return null;
|
||||
}
|
||||
return widget.steps[focusIndex];
|
||||
}
|
||||
|
||||
/// The page's one summary line: a focused visit uses its own capture summary,
|
||||
/// a run-level page uses the run header, and an empty reply says so.
|
||||
String _summary(List<ArtifactGroup> groups) {
|
||||
final focusIndex = widget.focusIndex;
|
||||
if (focusIndex != null &&
|
||||
focusIndex >= 0 &&
|
||||
focusIndex < widget.steps.length) {
|
||||
final focused = widget.steps[focusIndex];
|
||||
final focused = _focusedStep;
|
||||
if (focused != null) {
|
||||
final count = groups.fold<int>(
|
||||
0,
|
||||
(total, group) => total + group.artifacts.length,
|
||||
@@ -285,32 +297,87 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
return artifactsHeader(widget.steps, executing: widget.executing);
|
||||
}
|
||||
|
||||
/// The partial-capture notes shown under the page's summary.
|
||||
///
|
||||
/// A focused visit states its own capture facts, matching the web client's
|
||||
/// per-visit artifact section. The run-wide page keeps each visit's recorded
|
||||
/// wording and names the visit it belongs to, because the same count means
|
||||
/// different files in a different visit. Complete captures add nothing.
|
||||
List<String> _captureNotes() {
|
||||
final focused = _focusedStep;
|
||||
if (focused != null) return artifactCaptureNotes(focused);
|
||||
return <String>[
|
||||
for (final group in _groups)
|
||||
for (final note in artifactCaptureNotes(
|
||||
_stepsByGroup[artifactGroupKey(group.stageKey, group.visit)] ??
|
||||
const <String, dynamic>{},
|
||||
))
|
||||
'${artifactGroupLabel(group)} · $note',
|
||||
];
|
||||
}
|
||||
|
||||
/// The compact page header: the recorded count on one line, then the visit's
|
||||
/// capture notes in the host's secondary label style, then any transient
|
||||
/// status.
|
||||
///
|
||||
/// The header is handed to [ArtifactVisitList] as its leading child, so a run
|
||||
/// with many partial visits — or a focused visit at large text — scrolls with
|
||||
/// the artifacts instead of taking height from them. It is content-driven:
|
||||
/// one line per recorded fact, never clamped or shortened.
|
||||
Widget _header(BuildContext context, String summary) {
|
||||
final notes = _captureNotes();
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final headingStyle = cupertino
|
||||
? textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final noteStyle = textStyle.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: Text(summary, style: headingStyle),
|
||||
),
|
||||
for (final note in notes)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Text(note, style: noteStyle),
|
||||
),
|
||||
if (_status != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Semantics(liveRegion: true, child: Text(_status!)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final groups = _groups;
|
||||
final summary = _summary(groups);
|
||||
final body = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
||||
child: Text(summary),
|
||||
),
|
||||
if (_status != null)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 4),
|
||||
child: Semantics(liveRegion: true, child: Text(_status!)),
|
||||
),
|
||||
if (groups.isNotEmpty)
|
||||
Expanded(
|
||||
child: ArtifactVisitList(
|
||||
groups: groups,
|
||||
selectedIdentity: _selectedIdentity,
|
||||
onSelected: _select,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
final header = _header(context, _summary(groups));
|
||||
// Header, status and rows share one scroll view: the page never splits a
|
||||
// fixed header from a shrinking list, so a long header always stays usable.
|
||||
final body = groups.isEmpty
|
||||
? ListView(children: [header])
|
||||
: ArtifactVisitList(
|
||||
header: header,
|
||||
groups: groups,
|
||||
selectedIdentity: _selectedIdentity,
|
||||
onSelected: _select,
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
// Sections paint the grouped background; the page must match it or a
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../graph/domain/stage_visits.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_record.dart';
|
||||
@@ -27,6 +29,12 @@ Map<String, JsonMap> recordedStepsByGroup(List<JsonMap> steps) {
|
||||
|
||||
/// The recorded facts of one selected artifact: name, MIME/size, its visit's
|
||||
/// capture summary and notes, and the url state. Nothing is inferred.
|
||||
///
|
||||
/// The same block heads the selection sheet and the viewer, so both surfaces
|
||||
/// read the same way: the artifact's name is the surface title, the recorded
|
||||
/// type/size and visit are muted metadata, and the visit's capture summary and
|
||||
/// notes sit below them. Typography is the host theme's own body and secondary
|
||||
/// label styles; no size, colour or spacing scale is declared here.
|
||||
class ArtifactSelectionFacts extends StatelessWidget {
|
||||
const ArtifactSelectionFacts({
|
||||
super.key,
|
||||
@@ -45,25 +53,43 @@ class ArtifactSelectionFacts extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final recordedStep = step;
|
||||
final url = resolved;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final primaryStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final secondaryStyle = primaryStyle.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(artifactFactsLabel(artifact)),
|
||||
const SizedBox(height: 8),
|
||||
Text(artifactGroupLabel(group)),
|
||||
Text(artifactFactsLabel(artifact), style: secondaryStyle),
|
||||
const SizedBox(height: 6),
|
||||
Text(artifactGroupLabel(group), style: secondaryStyle),
|
||||
if (recordedStep != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(artifactsSummary(recordedStep, count: group.recordedCount)),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
artifactsSummary(recordedStep, count: group.recordedCount),
|
||||
style: primaryStyle,
|
||||
),
|
||||
for (final note in artifactCaptureNotes(recordedStep))
|
||||
Padding(padding: const EdgeInsets.only(top: 4), child: Text(note)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Text(note, style: secondaryStyle),
|
||||
),
|
||||
],
|
||||
if (!artifact.hasUrl) ...[
|
||||
const SizedBox(height: 8),
|
||||
const Text('No artifact URL recorded.'),
|
||||
const SizedBox(height: 12),
|
||||
Text('No artifact URL recorded.', style: secondaryStyle),
|
||||
] else if (url == null) ...[
|
||||
const SizedBox(height: 8),
|
||||
const Text('The recorded artifact URL cannot be opened safely.'),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'The recorded artifact URL cannot be opened safely.',
|
||||
style: secondaryStyle,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@@ -23,16 +23,27 @@ export 'artifact_row_labels.dart'
|
||||
/// content type and size; a turn document the visit did not record stays a
|
||||
/// non-actionable row with the exact absence wording. Rendering uses the host's
|
||||
/// own controls: Material list tiles under [MaterialApp] and grouped Cupertino
|
||||
/// list sections under [CupertinoApp]. It never resolves a url, opens a preview,
|
||||
/// downloads, shares or filters.
|
||||
/// list sections under [CupertinoApp]. An optional [header] leads the same
|
||||
/// scroll view. It never resolves a url, opens a preview, downloads, shares or
|
||||
/// filters.
|
||||
class ArtifactVisitList extends StatelessWidget {
|
||||
const ArtifactVisitList({
|
||||
super.key,
|
||||
required this.groups,
|
||||
this.header,
|
||||
this.selectedIdentity,
|
||||
this.onSelected,
|
||||
});
|
||||
|
||||
/// An optional page header rendered above the first section, inside the same
|
||||
/// scroll view.
|
||||
///
|
||||
/// A header sized by recorded facts (a summary and one line per capture note)
|
||||
/// must not take height from the list: it scrolls away with the rows instead
|
||||
/// of shrinking the viewport, which keeps every artifact reachable at a small
|
||||
/// surface or a large text scale.
|
||||
final Widget? header;
|
||||
|
||||
final List<ArtifactGroup> groups;
|
||||
|
||||
/// [artifactVisitIdentity] of the selected artifact, or null for none.
|
||||
@@ -42,12 +53,14 @@ class ArtifactVisitList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final header = this.header;
|
||||
if (groups.isEmpty) {
|
||||
return const _NoArtifacts();
|
||||
return _NoArtifacts(header: header);
|
||||
}
|
||||
if (usesCupertinoHost(context)) {
|
||||
return ListView(
|
||||
children: [
|
||||
?header,
|
||||
for (final group in groups) ...[
|
||||
CupertinoListSection.insetGrouped(
|
||||
// `container` keeps the heading a separate semantics node. Without
|
||||
@@ -74,19 +87,29 @@ class ArtifactVisitList extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
final headingStyle = theme.textTheme.titleSmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return ListView(
|
||||
children: [
|
||||
?header,
|
||||
for (final group in groups) ...<Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 4),
|
||||
child: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: Text(artifactGroupLabel(group)),
|
||||
child: Text(artifactGroupLabel(group), style: headingStyle),
|
||||
),
|
||||
),
|
||||
for (var index = 0; index < group.artifacts.length; index += 1)
|
||||
for (var index = 0; index < group.artifacts.length; index += 1) ...[
|
||||
// A hairline between rows, inset to the row's own text, is the
|
||||
// Material list idiom the web list also uses; it never follows the
|
||||
// last row, so a section ends on its content, not on a rule.
|
||||
if (index > 0) const Divider(height: 1, indent: 16, endIndent: 16),
|
||||
_row(group, group.artifacts[index], index),
|
||||
],
|
||||
if (group.documents.isNotEmpty)
|
||||
ArtifactDocumentSection(
|
||||
group: group,
|
||||
@@ -112,13 +135,16 @@ class ArtifactVisitList extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _NoArtifacts extends StatelessWidget {
|
||||
const _NoArtifacts();
|
||||
const _NoArtifacts({this.header});
|
||||
|
||||
final Widget? header;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
children: const [
|
||||
Padding(
|
||||
children: [
|
||||
?header,
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('No stage artifacts recorded.'),
|
||||
),
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user