Files
pipelines/app/test/application/search_artifact_open_test.dart
alan 9bdabb32d9 Remove Cupertino shell branches
Keep the Material-only shell path while preserving public cupertino parameters for callers. Narrow matching tests to Material hosts and behavior because the app always runs under MaterialApp.
2026-11-11 03:48:41 +00:00

106 lines
3.7 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,
) 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,
);
await replyRunList(tester, channel);
return provider;
}
testWidgets('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);
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('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);
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();
});
}