feat(app): run and stage artifacts share one gallery grid with image thumbnails and file-type icons
This commit is contained in:
@@ -57,7 +57,8 @@ Future<void> _pumpGallery(
|
||||
String configuredEndpoint = '',
|
||||
bool executing = false,
|
||||
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,
|
||||
}) async {
|
||||
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();
|
||||
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
expect(fetched, [
|
||||
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png'),
|
||||
]);
|
||||
// The gallery's thumbnail and the viewer read the same recorded file.
|
||||
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.text('1 of 1 · image/png'), 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_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/ui/artifact_visit_list.dart';
|
||||
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
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.label, contains('result.csv'));
|
||||
expect(
|
||||
@@ -93,7 +93,7 @@ void main() {
|
||||
);
|
||||
|
||||
final headingRect = tester.getRect(find.text('review · visit 2'));
|
||||
final rowRect = tester.getRect(find.byType(CupertinoButton));
|
||||
final rowRect = tester.getRect(find.byType(ArtifactTile));
|
||||
expect(
|
||||
rowRect.top,
|
||||
greaterThanOrEqualTo(headingRect.bottom),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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/domain/artifact_groups.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_record.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('text/csv · 2.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);
|
||||
expect(pickedGroup, same(first));
|
||||
@@ -113,7 +119,7 @@ void main() {
|
||||
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,
|
||||
) async {
|
||||
final first = visitGroup(
|
||||
@@ -138,16 +144,23 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoListSection), findsNWidgets(2));
|
||||
expect(find.byType(CupertinoButton), findsNWidgets(2));
|
||||
// A grid tile per artifact, no Material list tiles.
|
||||
expect(find.byType(ArtifactTile), findsNWidgets(2));
|
||||
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);
|
||||
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.physicalSize = const Size(780, 1560);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
@@ -175,17 +188,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
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(
|
||||
name.size.height,
|
||||
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',
|
||||
),
|
||||
find.bySemanticsLabel(RegExp(RegExp.escape(longArtifactName))),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
@@ -228,42 +233,6 @@ void main() {
|
||||
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 {
|
||||
@@ -308,18 +277,4 @@ void main() {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,18 +52,11 @@ void main() {
|
||||
expect(find.text('ok'), findsOneWidget);
|
||||
|
||||
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||
expect(find.text('plan.csv'), findsOneWidget);
|
||||
await tester.tap(find.text('plan.csv'));
|
||||
await tester.pumpAndSettle();
|
||||
// The section is the run's gallery, focused on this visit: exactly the
|
||||
// stage's files, without the session evidence file.
|
||||
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('session.html'), findsNothing);
|
||||
expect(find.text('Artifacts · 1 recorded'), findsOneWidget);
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await openVisitTab(tester, RunVisitSection.session);
|
||||
expect(find.text('Session'), findsWidgets);
|
||||
@@ -172,14 +165,7 @@ void main() {
|
||||
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||
expect(find.text('plan-2.csv'), findsOneWidget);
|
||||
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.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', (
|
||||
|
||||
Reference in New Issue
Block a user