9adee6cc60
Keep the public Cupertino-compatible parameters while retaining only the Material implementations and tests. The app is Material-only, so deleting unreachable Cupertino branches reduces dead code without changing the active path.
107 lines
3.7 KiB
Dart
107 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,
|
|
cupertino: false,
|
|
);
|
|
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();
|
|
});
|
|
}
|