merge(app): land artifact grid
This commit is contained in:
@@ -382,6 +382,8 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
|||||||
groups: groups,
|
groups: groups,
|
||||||
selectedIdentity: _selectedIdentity,
|
selectedIdentity: _selectedIdentity,
|
||||||
onSelected: _select,
|
onSelected: _select,
|
||||||
|
configuredEndpoint: widget.configuredEndpoint,
|
||||||
|
fetch: widget.fetch,
|
||||||
);
|
);
|
||||||
if (widget.embedded) return body;
|
if (widget.embedded) return body;
|
||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../domain/artifact_groups.dart';
|
||||||
|
import '../domain/artifact_kind.dart';
|
||||||
|
import '../domain/artifact_record.dart';
|
||||||
|
import '../domain/artifact_url.dart';
|
||||||
|
import 'artifact_row_labels.dart';
|
||||||
|
import 'artifact_viewer_fetch.dart';
|
||||||
|
|
||||||
|
/// One artifact in the gallery grid: a thumbnail for an image, otherwise an
|
||||||
|
/// icon for its kind of file, with its name and facts underneath.
|
||||||
|
class ArtifactTile extends StatefulWidget {
|
||||||
|
const ArtifactTile({
|
||||||
|
super.key,
|
||||||
|
required this.group,
|
||||||
|
required this.artifact,
|
||||||
|
required this.selected,
|
||||||
|
required this.configuredEndpoint,
|
||||||
|
required this.fetch,
|
||||||
|
this.onSelected,
|
||||||
|
});
|
||||||
|
|
||||||
|
final ArtifactGroup group;
|
||||||
|
final ArtifactRecord artifact;
|
||||||
|
final bool selected;
|
||||||
|
final String configuredEndpoint;
|
||||||
|
final ArtifactFetch fetch;
|
||||||
|
final ArtifactSelected? onSelected;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ArtifactTile> createState() => _ArtifactTileState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ArtifactTileState extends State<ArtifactTile> {
|
||||||
|
Future<ArtifactFetchResult>? _thumbnail;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final artifact = widget.artifact;
|
||||||
|
final format = artifactPreviewFormat(artifact.contentType, artifact.name);
|
||||||
|
final resolved = artifact.hasUrl
|
||||||
|
? resolveArtifactUrl(widget.configuredEndpoint, artifact.url)
|
||||||
|
: null;
|
||||||
|
// Only same-origin images load a thumbnail, through the app's own fetch.
|
||||||
|
if (format == ArtifactPreviewFormat.image &&
|
||||||
|
resolved != null &&
|
||||||
|
!resolved.external) {
|
||||||
|
_thumbnail = widget.fetch(resolved.uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoHost(context);
|
||||||
|
final artifact = widget.artifact;
|
||||||
|
final secondary = cupertino
|
||||||
|
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||||
|
final surface = cupertino
|
||||||
|
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||||
|
final border = widget.selected
|
||||||
|
? (cupertino
|
||||||
|
? CupertinoTheme.of(context).primaryColor
|
||||||
|
: Theme.of(context).colorScheme.primary)
|
||||||
|
: (cupertino
|
||||||
|
? CupertinoColors.separator.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.outlineVariant);
|
||||||
|
final icon = Icon(
|
||||||
|
artifactKindIcon(artifact, cupertino: cupertino),
|
||||||
|
size: 40,
|
||||||
|
color: secondary,
|
||||||
|
);
|
||||||
|
final preview = _thumbnail == null
|
||||||
|
? Center(child: icon)
|
||||||
|
: FutureBuilder<ArtifactFetchResult>(
|
||||||
|
future: _thumbnail,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final result = snapshot.data;
|
||||||
|
if (result == null || !result.ok || result.bytes.isEmpty) {
|
||||||
|
return Center(child: icon);
|
||||||
|
}
|
||||||
|
return Image.memory(
|
||||||
|
result.bytes,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
gaplessPlayback: true,
|
||||||
|
errorBuilder: (_, _, _) => Center(child: icon),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final name = artifactDisplayName(artifact);
|
||||||
|
final facts = artifactFactsLabel(artifact);
|
||||||
|
final body = Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
AspectRatio(
|
||||||
|
aspectRatio: 4 / 3,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(11)),
|
||||||
|
child: ColoredBox(color: surface, child: preview),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(8, 6, 8, 8),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(name, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
Text(
|
||||||
|
facts,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(color: secondary, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final onSelected = widget.onSelected;
|
||||||
|
void tap() => onSelected?.call(widget.group, artifact);
|
||||||
|
final decorated = DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: border, width: widget.selected ? 2 : 1),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: body,
|
||||||
|
);
|
||||||
|
return Semantics(
|
||||||
|
button: onSelected != null,
|
||||||
|
selected: widget.selected,
|
||||||
|
label: '$name, $facts',
|
||||||
|
excludeSemantics: true,
|
||||||
|
onTap: onSelected == null ? null : tap,
|
||||||
|
child: cupertino
|
||||||
|
? GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: onSelected == null ? null : tap,
|
||||||
|
child: decorated,
|
||||||
|
)
|
||||||
|
: Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
onTap: onSelected == null ? null : tap,
|
||||||
|
child: decorated,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The icon for an artifact's kind of file, when it has no thumbnail.
|
||||||
|
IconData artifactKindIcon(ArtifactRecord artifact, {required bool cupertino}) {
|
||||||
|
final name = artifact.name.toLowerCase();
|
||||||
|
final format = artifactPreviewFormat(artifact.contentType, artifact.name);
|
||||||
|
if (name.endsWith('.zip') || name.endsWith('.tar') || name.endsWith('.gz')) {
|
||||||
|
return cupertino ? CupertinoIcons.archivebox : Icons.folder_zip_outlined;
|
||||||
|
}
|
||||||
|
if (name.endsWith('.pdf')) {
|
||||||
|
return cupertino ? CupertinoIcons.doc_richtext : Icons.picture_as_pdf;
|
||||||
|
}
|
||||||
|
return switch (format) {
|
||||||
|
ArtifactPreviewFormat.image =>
|
||||||
|
cupertino ? CupertinoIcons.photo : Icons.image_outlined,
|
||||||
|
ArtifactPreviewFormat.video =>
|
||||||
|
cupertino ? CupertinoIcons.film : Icons.movie_outlined,
|
||||||
|
ArtifactPreviewFormat.markdown =>
|
||||||
|
cupertino ? CupertinoIcons.doc_text : Icons.article_outlined,
|
||||||
|
ArtifactPreviewFormat.text =>
|
||||||
|
cupertino ? CupertinoIcons.doc_plaintext : Icons.description_outlined,
|
||||||
|
ArtifactPreviewFormat.table =>
|
||||||
|
cupertino ? CupertinoIcons.table : Icons.table_chart_outlined,
|
||||||
|
ArtifactPreviewFormat.html => cupertino ? CupertinoIcons.globe : Icons.html,
|
||||||
|
ArtifactPreviewFormat.none =>
|
||||||
|
cupertino ? CupertinoIcons.doc : Icons.insert_drive_file_outlined,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../domain/artifact_groups.dart';
|
import '../domain/artifact_groups.dart';
|
||||||
import '../domain/artifact_record.dart';
|
|
||||||
import 'artifact_document_section.dart';
|
import 'artifact_document_section.dart';
|
||||||
import 'artifact_record_row.dart';
|
import 'artifact_tile.dart';
|
||||||
|
import 'artifact_viewer_fetch.dart';
|
||||||
import 'artifact_row_labels.dart';
|
import 'artifact_row_labels.dart';
|
||||||
|
|
||||||
export 'artifact_row_labels.dart'
|
export 'artifact_row_labels.dart'
|
||||||
@@ -33,8 +33,14 @@ class ArtifactVisitList extends StatelessWidget {
|
|||||||
this.header,
|
this.header,
|
||||||
this.selectedIdentity,
|
this.selectedIdentity,
|
||||||
this.onSelected,
|
this.onSelected,
|
||||||
|
this.configuredEndpoint = '',
|
||||||
|
this.fetch = fetchArtifact,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Resolves an image's url for its thumbnail; [fetch] loads it.
|
||||||
|
final String configuredEndpoint;
|
||||||
|
final ArtifactFetch fetch;
|
||||||
|
|
||||||
/// An optional page header rendered above the first section, inside the same
|
/// An optional page header rendered above the first section, inside the same
|
||||||
/// scroll view.
|
/// scroll view.
|
||||||
///
|
///
|
||||||
@@ -62,21 +68,21 @@ class ArtifactVisitList extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
?header,
|
?header,
|
||||||
for (final group in groups) ...[
|
for (final group in groups) ...[
|
||||||
CupertinoListSection.insetGrouped(
|
Padding(
|
||||||
// `container` keeps the heading a separate semantics node. Without
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 4),
|
||||||
// it the heading merges into the neighbouring row button, so it is
|
// `container` keeps the heading a separate semantics node.
|
||||||
// not navigable as a heading and activating it selects the row.
|
child: Semantics(
|
||||||
header: Semantics(
|
|
||||||
container: true,
|
container: true,
|
||||||
header: true,
|
header: true,
|
||||||
child: Text(artifactGroupLabel(group)),
|
child: Text(
|
||||||
|
artifactGroupLabel(group),
|
||||||
|
style: TextStyle(
|
||||||
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
hasLeading: false,
|
|
||||||
children: [
|
|
||||||
for (var index = 0; index < group.artifacts.length; index += 1)
|
|
||||||
_row(group, group.artifacts[index], index),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
_grid(group),
|
||||||
if (group.documents.isNotEmpty)
|
if (group.documents.isNotEmpty)
|
||||||
ArtifactDocumentSection(
|
ArtifactDocumentSection(
|
||||||
group: group,
|
group: group,
|
||||||
@@ -103,13 +109,7 @@ class ArtifactVisitList extends StatelessWidget {
|
|||||||
child: Text(artifactGroupLabel(group), style: headingStyle),
|
child: Text(artifactGroupLabel(group), style: headingStyle),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
for (var index = 0; index < group.artifacts.length; index += 1) ...[
|
_grid(group),
|
||||||
// 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)
|
if (group.documents.isNotEmpty)
|
||||||
ArtifactDocumentSection(
|
ArtifactDocumentSection(
|
||||||
group: group,
|
group: group,
|
||||||
@@ -121,17 +121,43 @@ class ArtifactVisitList extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _row(ArtifactGroup group, ArtifactRecord artifact, int index) {
|
/// A group's artifacts as a grid: two tiles across on a phone, more as the
|
||||||
return ArtifactRecordRow(
|
/// pane widens.
|
||||||
key: ValueKey<String>(
|
Widget _grid(ArtifactGroup group) => LayoutBuilder(
|
||||||
'${artifactVisitIdentity(group, artifact)}\u0000$index',
|
builder: (context, constraints) {
|
||||||
),
|
const gap = 12.0;
|
||||||
group: group,
|
final width = constraints.maxWidth - 32;
|
||||||
artifact: artifact,
|
final columns = (width / 170).floor().clamp(2, 6);
|
||||||
selected: selectedIdentity == artifactVisitIdentity(group, artifact),
|
final tile = (width - gap * (columns - 1)) / columns;
|
||||||
onSelected: onSelected,
|
return Padding(
|
||||||
);
|
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
|
||||||
}
|
child: Wrap(
|
||||||
|
spacing: gap,
|
||||||
|
runSpacing: gap,
|
||||||
|
children: [
|
||||||
|
for (var index = 0; index < group.artifacts.length; index += 1)
|
||||||
|
SizedBox(
|
||||||
|
width: tile,
|
||||||
|
child: ArtifactTile(
|
||||||
|
key: ValueKey<String>(
|
||||||
|
'${artifactVisitIdentity(group, group.artifacts[index])}'
|
||||||
|
'\u0000$index',
|
||||||
|
),
|
||||||
|
group: group,
|
||||||
|
artifact: group.artifacts[index],
|
||||||
|
selected:
|
||||||
|
selectedIdentity ==
|
||||||
|
artifactVisitIdentity(group, group.artifacts[index]),
|
||||||
|
configuredEndpoint: configuredEndpoint,
|
||||||
|
fetch: fetch,
|
||||||
|
onSelected: onSelected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NoArtifacts extends StatelessWidget {
|
class _NoArtifacts extends StatelessWidget {
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../artifacts/ui/artifact_gallery_page.dart';
|
||||||
import '../../artifacts/domain/artifact_groups.dart';
|
|
||||||
import '../../artifacts/domain/artifact_record.dart';
|
|
||||||
import '../../artifacts/domain/artifact_summary.dart';
|
|
||||||
import '../../artifacts/ui/artifact_gallery_action.dart';
|
|
||||||
import '../../artifacts/ui/artifact_visit_list.dart';
|
|
||||||
|
|
||||||
/// The visit's recorded stage artifacts, in recorded order.
|
/// The visit's recorded stage artifacts, in recorded order.
|
||||||
///
|
///
|
||||||
@@ -36,77 +30,16 @@ class RunVisitArtifacts extends StatelessWidget {
|
|||||||
final List<JsonMap> runSteps;
|
final List<JsonMap> runSteps;
|
||||||
final String configuredEndpoint;
|
final String configuredEndpoint;
|
||||||
|
|
||||||
|
/// The same gallery as the run's Artifacts tab, focused on this visit.
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => KeyedSubtree(
|
||||||
final artifacts = visitArtifacts(step, runSteps);
|
key: const Key('run-visit-body-artifacts'),
|
||||||
final notes = artifactCaptureNotes(step);
|
child: ArtifactGalleryPage(
|
||||||
if (artifacts.isEmpty) {
|
key: ValueKey('run-visit-artifacts-$visitIndex'),
|
||||||
return ListView(
|
|
||||||
key: const Key('run-visit-body-artifacts'),
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
children: [
|
|
||||||
Text(artifactsSummary(step, count: 0)),
|
|
||||||
for (final note in notes)
|
|
||||||
Padding(padding: const EdgeInsets.only(top: 4), child: Text(note)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
void open() => showArtifactGallery(
|
|
||||||
context,
|
|
||||||
steps: runSteps.isEmpty ? <JsonMap>[step] : runSteps,
|
steps: runSteps.isEmpty ? <JsonMap>[step] : runSteps,
|
||||||
focusIndex: runSteps.isEmpty ? 0 : visitIndex,
|
focusIndex: runSteps.isEmpty ? 0 : visitIndex,
|
||||||
configuredEndpoint: configuredEndpoint,
|
configuredEndpoint: configuredEndpoint,
|
||||||
);
|
embedded: true,
|
||||||
final noteRows = [
|
),
|
||||||
for (final note in notes)
|
);
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
|
||||||
child: Text(note),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
if (usesCupertinoHost(context)) {
|
|
||||||
return ListView(
|
|
||||||
key: const Key('run-visit-body-artifacts'),
|
|
||||||
children: [
|
|
||||||
...noteRows,
|
|
||||||
CupertinoListSection.insetGrouped(
|
|
||||||
children: [
|
|
||||||
for (final artifact in artifacts)
|
|
||||||
_CupertinoArtifactRow(artifact: artifact, onTap: open),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ListView(
|
|
||||||
key: const Key('run-visit-body-artifacts'),
|
|
||||||
children: [
|
|
||||||
...noteRows,
|
|
||||||
for (final artifact in artifacts)
|
|
||||||
ListTile(
|
|
||||||
title: Text(artifactDisplayName(artifact)),
|
|
||||||
subtitle: Text(artifactFactsLabel(artifact)),
|
|
||||||
trailing: const Icon(Icons.chevron_right),
|
|
||||||
onTap: open,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CupertinoArtifactRow extends StatelessWidget {
|
|
||||||
const _CupertinoArtifactRow({required this.artifact, required this.onTap});
|
|
||||||
|
|
||||||
final ArtifactRecord artifact;
|
|
||||||
final VoidCallback onTap;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return CupertinoListTile(
|
|
||||||
title: Text(artifactDisplayName(artifact)),
|
|
||||||
subtitle: Text(artifactFactsLabel(artifact)),
|
|
||||||
trailing: const Icon(CupertinoIcons.chevron_forward),
|
|
||||||
onTap: onTap,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ Future<void> _pumpGallery(
|
|||||||
String configuredEndpoint = '',
|
String configuredEndpoint = '',
|
||||||
bool executing = false,
|
bool executing = false,
|
||||||
Future<bool> Function(Uri)? openExternal,
|
Future<bool> Function(Uri)? openExternal,
|
||||||
Size surface = const Size(800, 600),
|
// Tall enough that every visit's grid is built.
|
||||||
|
Size surface = const Size(800, 1600),
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
}) async {
|
}) async {
|
||||||
tester.view.physicalSize = surface;
|
tester.view.physicalSize = surface;
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/artifacts/ui/artifact_tile.dart';
|
||||||
|
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
||||||
|
|
||||||
|
import 'artifact_visit_list_fixture.dart';
|
||||||
|
|
||||||
|
/// A 1x1 transparent PNG.
|
||||||
|
final _png = Uint8List.fromList(const [
|
||||||
|
0x89,
|
||||||
|
0x50,
|
||||||
|
0x4E,
|
||||||
|
0x47,
|
||||||
|
0x0D,
|
||||||
|
0x0A,
|
||||||
|
0x1A,
|
||||||
|
0x0A,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0D,
|
||||||
|
0x49,
|
||||||
|
0x48,
|
||||||
|
0x44,
|
||||||
|
0x52,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x08,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x1F,
|
||||||
|
0x15,
|
||||||
|
0xC4,
|
||||||
|
0x89,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0D,
|
||||||
|
0x49,
|
||||||
|
0x44,
|
||||||
|
0x41,
|
||||||
|
0x54,
|
||||||
|
0x78,
|
||||||
|
0x9C,
|
||||||
|
0x63,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x05,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x0D,
|
||||||
|
0x0A,
|
||||||
|
0x2D,
|
||||||
|
0xB4,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x49,
|
||||||
|
0x45,
|
||||||
|
0x4E,
|
||||||
|
0x44,
|
||||||
|
0xAE,
|
||||||
|
0x42,
|
||||||
|
0x60,
|
||||||
|
0x82,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Widget _host(Widget tile) => MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: Center(child: SizedBox(width: 180, child: tile)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('an image tile shows its thumbnail through the app fetch', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final fetched = <Uri>[];
|
||||||
|
final image = recordedArtifact(
|
||||||
|
'shot.png',
|
||||||
|
url: '/artifacts/1/1/shot.png',
|
||||||
|
contentType: 'image/png',
|
||||||
|
sizeBytes: 70,
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_host(
|
||||||
|
ArtifactTile(
|
||||||
|
group: visitGroup(artifacts: [image]),
|
||||||
|
artifact: image,
|
||||||
|
selected: false,
|
||||||
|
configuredEndpoint: 'ws://127.0.0.1:8081/connect',
|
||||||
|
fetch: (uri) async {
|
||||||
|
fetched.add(uri);
|
||||||
|
return ArtifactFetchResult(status: 200, bytes: _png);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(fetched, [
|
||||||
|
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png'),
|
||||||
|
]);
|
||||||
|
expect(find.byType(Image), findsOneWidget);
|
||||||
|
expect(find.text('shot.png'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a file without a thumbnail shows its kind of file', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
var fetches = 0;
|
||||||
|
final archive = recordedArtifact(
|
||||||
|
'result.zip',
|
||||||
|
url: '/artifacts/1/1/result.zip',
|
||||||
|
contentType: 'application/zip',
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_host(
|
||||||
|
ArtifactTile(
|
||||||
|
group: visitGroup(artifacts: [archive]),
|
||||||
|
artifact: archive,
|
||||||
|
selected: false,
|
||||||
|
configuredEndpoint: 'ws://127.0.0.1:8081/connect',
|
||||||
|
fetch: (uri) async {
|
||||||
|
fetches++;
|
||||||
|
return ArtifactFetchResult(status: 200, bytes: _png);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(fetches, 0);
|
||||||
|
expect(find.byIcon(Icons.folder_zip_outlined), findsOneWidget);
|
||||||
|
expect(find.byType(Image), findsNothing);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -148,9 +148,12 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||||
expect(fetched, [
|
// The gallery's thumbnail and the viewer read the same recorded file.
|
||||||
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png'),
|
expect(fetched, isNotEmpty);
|
||||||
]);
|
expect(
|
||||||
|
fetched.toSet(),
|
||||||
|
{Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png')},
|
||||||
|
);
|
||||||
expect(find.byType(Image), findsOneWidget);
|
expect(find.byType(Image), findsOneWidget);
|
||||||
expect(find.text('1 of 1 · image/png'), findsOneWidget);
|
expect(find.text('1 of 1 · image/png'), findsOneWidget);
|
||||||
expect(find.text('image/png · 1.0\u00a0KiB'), findsOneWidget);
|
expect(find.text('image/png · 1.0\u00a0KiB'), findsOneWidget);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/semantics.dart';
|
import 'package:flutter/semantics.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/artifacts/ui/artifact_tile.dart';
|
||||||
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
||||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ void main() {
|
|||||||
reason: 'a heading must never activate the artifact below it',
|
reason: 'a heading must never activate the artifact below it',
|
||||||
);
|
);
|
||||||
|
|
||||||
final button = tester.getSemantics(find.byType(CupertinoButton));
|
final button = tester.getSemantics(find.byType(ArtifactTile));
|
||||||
expect(button, isSemantics(isButton: true, hasTapAction: true));
|
expect(button, isSemantics(isButton: true, hasTapAction: true));
|
||||||
expect(button.label, contains('result.csv'));
|
expect(button.label, contains('result.csv'));
|
||||||
expect(
|
expect(
|
||||||
@@ -93,7 +93,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final headingRect = tester.getRect(find.text('review · visit 2'));
|
final headingRect = tester.getRect(find.text('review · visit 2'));
|
||||||
final rowRect = tester.getRect(find.byType(CupertinoButton));
|
final rowRect = tester.getRect(find.byType(ArtifactTile));
|
||||||
expect(
|
expect(
|
||||||
rowRect.top,
|
rowRect.top,
|
||||||
greaterThanOrEqualTo(headingRect.bottom),
|
greaterThanOrEqualTo(headingRect.bottom),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/artifacts/ui/artifact_tile.dart';
|
||||||
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.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/domain/artifact_record.dart';
|
||||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||||
@@ -102,7 +102,13 @@ void main() {
|
|||||||
expect(find.text('result.csv'), findsNWidgets(2));
|
expect(find.text('result.csv'), findsNWidgets(2));
|
||||||
expect(find.text('text/csv · 2.0${nonBreakingSpace}KiB'), findsOneWidget);
|
expect(find.text('text/csv · 2.0${nonBreakingSpace}KiB'), findsOneWidget);
|
||||||
expect(find.text('text/csv · 4.0${nonBreakingSpace}KiB'), findsOneWidget);
|
expect(find.text('text/csv · 4.0${nonBreakingSpace}KiB'), findsOneWidget);
|
||||||
expect(find.byIcon(Icons.check), findsOneWidget);
|
// The selected tile is marked; the other is not.
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widgetList<ArtifactTile>(find.byType(ArtifactTile))
|
||||||
|
.where((tile) => tile.selected),
|
||||||
|
hasLength(1),
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(find.text('result.csv').first);
|
await tester.tap(find.text('result.csv').first);
|
||||||
expect(pickedGroup, same(first));
|
expect(pickedGroup, same(first));
|
||||||
@@ -113,7 +119,7 @@ void main() {
|
|||||||
expect(pickedArtifact!.url, '/artifacts/7/2/result.csv');
|
expect(pickedArtifact!.url, '/artifacts/7/2/result.csv');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino uses grouped native controls and selects per visit', (
|
testWidgets('Cupertino shows a grid of tiles and selects per visit', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final first = visitGroup(
|
final first = visitGroup(
|
||||||
@@ -138,16 +144,23 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(find.byType(CupertinoListSection), findsNWidgets(2));
|
// A grid tile per artifact, no Material list tiles.
|
||||||
expect(find.byType(CupertinoButton), findsNWidgets(2));
|
expect(find.byType(ArtifactTile), findsNWidgets(2));
|
||||||
expect(find.byType(ListTile), findsNothing);
|
expect(find.byType(ListTile), findsNothing);
|
||||||
expect(find.byIcon(CupertinoIcons.check_mark), findsOneWidget);
|
expect(
|
||||||
|
tester
|
||||||
|
.widgetList<ArtifactTile>(find.byType(ArtifactTile))
|
||||||
|
.where((tile) => tile.selected),
|
||||||
|
hasLength(1),
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(find.text('result.csv').last);
|
await tester.tap(find.text('result.csv').last);
|
||||||
expect(pickedGroup, same(second));
|
expect(pickedGroup, same(second));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('long names wrap at 2x under both native hosts', (tester) async {
|
testWidgets('long names fit their tile at 2x under both native hosts', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
tester.view.devicePixelRatio = 2;
|
tester.view.devicePixelRatio = 2;
|
||||||
tester.view.physicalSize = const Size(780, 1560);
|
tester.view.physicalSize = const Size(780, 1560);
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
@@ -175,17 +188,9 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
final name = tester.renderObject<RenderBox>(find.text(longArtifactName));
|
// A tile shows one line of the name; its accessible name is whole.
|
||||||
expect(
|
expect(
|
||||||
name.size.height,
|
find.bySemanticsLabel(RegExp(RegExp.escape(longArtifactName))),
|
||||||
greaterThan(120),
|
|
||||||
reason: 'the recorded name must wrap over several lines, not one',
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
find.text(
|
|
||||||
'application/vnd.openxmlformats-officedocument.'
|
|
||||||
'spreadsheetml.sheet · 120.6${nonBreakingSpace}KiB',
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -228,42 +233,6 @@ void main() {
|
|||||||
expect(find.byType(ListTile), findsNothing);
|
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', (
|
testWidgets('a page header scrolls inside the list, not above it', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
@@ -308,18 +277,4 @@ void main() {
|
|||||||
expect(find.text('Artifacts · 0 recorded'), findsOneWidget);
|
expect(find.text('Artifacts · 0 recorded'), findsOneWidget);
|
||||||
expect(find.text('No stage artifacts 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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,18 +52,11 @@ void main() {
|
|||||||
expect(find.text('ok'), findsOneWidget);
|
expect(find.text('ok'), findsOneWidget);
|
||||||
|
|
||||||
await openVisitTab(tester, RunVisitSection.artifacts);
|
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||||
expect(find.text('plan.csv'), findsOneWidget);
|
// The section is the run's gallery, focused on this visit: exactly the
|
||||||
await tester.tap(find.text('plan.csv'));
|
// stage's files, without the session evidence file.
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
|
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
|
||||||
// The opened page lists exactly the pane's stage files: the session
|
|
||||||
// evidence file is not stage output and stays out of both.
|
|
||||||
expect(find.text('plan · visit 1'), findsOneWidget);
|
|
||||||
expect(find.text('plan.csv'), findsOneWidget);
|
expect(find.text('plan.csv'), findsOneWidget);
|
||||||
expect(find.text('session.html'), findsNothing);
|
expect(find.text('session.html'), findsNothing);
|
||||||
expect(find.text('Artifacts · 1 recorded'), findsOneWidget);
|
|
||||||
await tester.pageBack();
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
await openVisitTab(tester, RunVisitSection.session);
|
await openVisitTab(tester, RunVisitSection.session);
|
||||||
expect(find.text('Session'), findsWidgets);
|
expect(find.text('Session'), findsWidgets);
|
||||||
@@ -172,14 +165,7 @@ void main() {
|
|||||||
await openVisitTab(tester, RunVisitSection.artifacts);
|
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||||
expect(find.text('plan-2.csv'), findsOneWidget);
|
expect(find.text('plan-2.csv'), findsOneWidget);
|
||||||
expect(find.text('public/shared.csv'), findsNothing);
|
expect(find.text('public/shared.csv'), findsNothing);
|
||||||
|
|
||||||
await tester.tap(find.text('plan-2.csv'));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
|
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
|
||||||
expect(find.text('plan · visit 2'), findsOneWidget);
|
|
||||||
expect(find.text('plan-2.csv'), findsOneWidget);
|
|
||||||
expect(find.text('public/shared.csv'), findsNothing);
|
|
||||||
expect(find.text('Artifacts · 1 recorded'), findsOneWidget);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('${platform.name} missing definition uses exact wording', (
|
testWidgets('${platform.name} missing definition uses exact wording', (
|
||||||
|
|||||||
Reference in New Issue
Block a user