Open Search artifact hits in the viewer over the run's Artifacts tab
On a phone-width window the open run is its own page pushed on the app navigator, so RunDetailTabs was not a descendant of the shell's RunSearchSelectionScope (which wraps only the Runs tab body). The field or artifact selection was never seen and the run opened at its plain Summary. The previous widget tests injected the scope directly above RunDetailView at 900 px, where the detail is an inline pane, so they could not catch it. - RunsScreen relays the shell's search scope into the detail it builds, so the pushed page sees the selection too (also fixes field hits on phones). - An artifact hit now opens the run's Artifacts tab and the gallery opens that artifact exactly as a tap there does: selected, scrolled into view (ArtifactVisitReveal) and in the viewer. Back returns to the tab with the artifact highlighted. An unknown URL leaves the tab open with the existing "That artifact is no longer available." notice. - New test/application/search_artifact_open_test.dart drives the real Search tab -> typed query -> result tap -> run read -> viewer on a 390x844 phone, Material and Cupertino; it fails without the scope relay.
This commit is contained in:
@@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../features/runs/ui/run_detail_finders.dart';
|
||||
import '../native_back.dart';
|
||||
import 'package:pipelines_app/application/app_route.dart';
|
||||
import 'package:pipelines_app/application/app_router.dart';
|
||||
@@ -11,6 +10,8 @@ import 'package:pipelines_app/application/search_destination.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_tile.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
||||
import 'package:pipelines_app/features/search/search_screen.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
@@ -190,10 +191,35 @@ JsonMap searchSelectionDetail() => {
|
||||
'sequence': 2,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
'artifacts': [
|
||||
{
|
||||
'name': 'report.txt',
|
||||
'content_type': 'text/plain',
|
||||
'size_bytes': 12,
|
||||
'url': '/artifacts/7/2/report.txt',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/// Closes the open artifact viewer the way its own Back does.
|
||||
Future<void> closeViewer(WidgetTester tester) async {
|
||||
Navigator.of(tester.element(find.byType(ArtifactViewerPage))).pop();
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Run 7's Artifacts tab is shown with the hit's artifact selected.
|
||||
void expectArtifactsTabSelecting(WidgetTester tester, String url) {
|
||||
expect(find.byType(ArtifactViewerPage), findsNothing);
|
||||
expect(find.byKey(const ValueKey('run-detail-artifacts-7')), findsOneWidget);
|
||||
final tile = find.byWidgetPredicate(
|
||||
(widget) => widget is ArtifactTile && widget.artifact.url == url,
|
||||
);
|
||||
expect(tile, findsOneWidget);
|
||||
expect(tester.widget<ArtifactTile>(tile).selected, isTrue);
|
||||
}
|
||||
|
||||
JsonMap artifactHit() => {
|
||||
'kind': 'artifact',
|
||||
'target': '/artifacts/7/2/report.txt',
|
||||
@@ -480,24 +506,21 @@ void main() {
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
// An artifact hit opens the run and selects the visit that recorded it.
|
||||
// An artifact hit opens the run's Artifacts tab and that artifact's viewer.
|
||||
await sendSearch(query: 'report', index: 0, hit: artifactHit());
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('search.result./artifacts/7/2/report.txt')),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
expect(find.byType(SearchScreen), findsNothing);
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expectVisitHeading(tester, 'build', 1);
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
|
||||
// Leave the visit page (it covers the shell), then a retired field hit
|
||||
// opens the plain Summary with no visit.
|
||||
await tester.tap(find.byKey(const Key('run-visit-back')));
|
||||
await tester.pumpAndSettle();
|
||||
// Leave the viewer for the Artifacts tab, then a retired field hit opens
|
||||
// the plain Summary with no visit.
|
||||
await closeViewer(tester);
|
||||
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
|
||||
await sendSearch(query: 'retired', index: 1, hit: retiredFieldHit());
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('search.result.run:7:5:evidence')),
|
||||
@@ -536,7 +559,7 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('an artifact hit selects its visit after the run detail loads', (
|
||||
testWidgets('an artifact hit opens its viewer after the run detail loads', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
@@ -602,8 +625,9 @@ void main() {
|
||||
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 0);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expectVisitHeading(tester, 'build', 1);
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
await closeViewer(tester);
|
||||
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
@@ -693,10 +717,9 @@ void main() {
|
||||
await openArtifactHit(tester, channel);
|
||||
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 0);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('run-visit-back')));
|
||||
await tester.pumpAndSettle();
|
||||
await closeViewer(tester);
|
||||
await provider.didPushRouteInformation(
|
||||
RouteInformation(uri: Uri.parse('/runs')),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user