8d2ca95057
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.
119 lines
4.1 KiB
Dart
119 lines
4.1 KiB
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/core/transport/pipelines_client.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;
|
|
import 'search_wiring_test.dart'
|
|
show
|
|
closeViewer,
|
|
expectArtifactsTabSelecting,
|
|
openArtifactHit,
|
|
pumpApp,
|
|
replyRunDetailFor,
|
|
replyRunList,
|
|
searchSelectionDetail;
|
|
|
|
/// The real Search screen, tapped on a phone-sized window.
|
|
///
|
|
/// On a narrow window the open run is its own page on the app's navigator
|
|
/// rather than a pane under the shell, which is where the search selection
|
|
/// once went missing: the run opened at its plain Summary. These tests drive
|
|
/// the whole path (Search tab, typed query, server results, row tap, run
|
|
/// read) rather than injecting a selection into the detail.
|
|
void main() {
|
|
Future<PlatformRouteInformationProvider> openPhoneApp(
|
|
WidgetTester tester,
|
|
FakeChannel channel, {
|
|
required bool cupertino,
|
|
}) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await pumpApp(
|
|
tester,
|
|
channel: channel,
|
|
client: PipelinesClient(channelFactory: (_) => channel),
|
|
provider: provider,
|
|
cupertino: cupertino,
|
|
);
|
|
await replyRunList(tester, channel);
|
|
return provider;
|
|
}
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final platform = cupertino ? 'Cupertino' : 'Material';
|
|
|
|
testWidgets('$platform phone: an artifact hit opens that artifact in the '
|
|
'viewer, and Back shows it on the run Artifacts tab', (tester) async {
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
final provider = await openPhoneApp(
|
|
tester,
|
|
channel,
|
|
cupertino: cupertino,
|
|
);
|
|
|
|
await openArtifactHit(tester, channel);
|
|
expect(provider.value.uri.path, '/runs/7');
|
|
await replyRunDetailFor(tester, channel, searchSelectionDetail());
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(SearchScreen), findsNothing);
|
|
final viewer = tester.widget<ArtifactViewerPage>(
|
|
find.byType(ArtifactViewerPage),
|
|
);
|
|
expect(viewer.selectedIdentity, contains('report.txt'));
|
|
expect(find.text('report.txt'), findsWidgets);
|
|
|
|
await closeViewer(tester);
|
|
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
testWidgets('$platform phone: an artifact the run no longer lists opens '
|
|
'its Artifacts tab with a notice', (tester) async {
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
await openPhoneApp(tester, channel, cupertino: cupertino);
|
|
|
|
await openArtifactHit(tester, channel);
|
|
final detail = searchSelectionDetail();
|
|
final steps = [
|
|
for (final step in detail['steps'] as List)
|
|
Map<String, dynamic>.from(step as Map),
|
|
];
|
|
steps[1]['artifacts'] = <JsonMap>[
|
|
{
|
|
'name': 'other.txt',
|
|
'content_type': 'text/plain',
|
|
'size_bytes': 3,
|
|
'url': '/artifacts/7/2/other.txt',
|
|
},
|
|
];
|
|
await replyRunDetailFor(tester, channel, {...detail, 'steps': steps});
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(ArtifactViewerPage), findsNothing);
|
|
expect(
|
|
find.byKey(const ValueKey('run-detail-artifacts-7')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.text('That artifact is no longer available.'),
|
|
findsOneWidget,
|
|
);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
}
|
|
}
|