75929a0a41
Keep the Material-only run detail implementation while preserving public parameters for callers. Narrow the corresponding widget tests to the supported Material host and remove unused Cupertino-only code.
97 lines
3.0 KiB
Dart
97 lines
3.0 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/features/runs/data/runs_repository.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
|
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_pipeline_link.dart';
|
|
|
|
class _FakeGateway implements ApiGateway {
|
|
_FakeGateway(this.detail);
|
|
final JsonMap detail;
|
|
|
|
@override
|
|
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
|
|
|
|
@override
|
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
|
if (type != 'get_run') throw UnsupportedError(type);
|
|
return Future.value({'run_detail': detail});
|
|
}
|
|
}
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester,
|
|
String status, {
|
|
OpenPipeline? onOpenPipeline,
|
|
}) async {
|
|
tester.view.physicalSize = const Size(390, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final controller = RunsController(
|
|
RunsRepository(
|
|
_FakeGateway({
|
|
'id': 21,
|
|
'title': 'Nightly build',
|
|
'name': 'nightly',
|
|
'status': status,
|
|
'executing': false,
|
|
'pipeline_id': 10,
|
|
'version': 3,
|
|
}),
|
|
),
|
|
);
|
|
await controller.select(21);
|
|
final view = RunDetailView(
|
|
controller: controller,
|
|
gateway: _FakeGateway(const {}),
|
|
onBack: () {},
|
|
onOpenPipeline: onOpenPipeline,
|
|
);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: view)));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<bool> _menuOffersRetry(WidgetTester tester) async {
|
|
await tester.tap(find.byKey(runMoreMenuKey));
|
|
await tester.pumpAndSettle();
|
|
return find.text('Retry').evaluate().isNotEmpty;
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('Retry is a more-menu option for a failed run', (tester) async {
|
|
await _pump(tester, 'failed');
|
|
// Not in the header itself.
|
|
expect(find.text('Retry'), findsNothing);
|
|
expect(await _menuOffersRetry(tester), isTrue);
|
|
});
|
|
|
|
testWidgets('the pipeline name opens that pipeline at the run\'s '
|
|
'version', (tester) async {
|
|
final opened = <(int, int)>[];
|
|
await _pump(
|
|
tester,
|
|
'succeeded',
|
|
onOpenPipeline: (id, version) => opened.add((id, version)),
|
|
);
|
|
// The title expands first; the pipeline action is intentionally only
|
|
// available in that expanded state.
|
|
await tester.tap(find.text('Nightly build').first);
|
|
await tester.pump();
|
|
await tester.tap(find.byKey(runPipelineLinkKey));
|
|
await tester.pump();
|
|
expect(opened, [(10, 3)]);
|
|
// The run's title pill is the link, announced as opening the pipeline.
|
|
expect(
|
|
find.bySemanticsLabel(RegExp('Open pipeline nightly')),
|
|
findsOneWidget,
|
|
);
|
|
});
|
|
|
|
testWidgets('a succeeded run offers no Retry', (tester) async {
|
|
await _pump(tester, 'succeeded');
|
|
expect(await _menuOffersRetry(tester), isFalse);
|
|
});
|
|
}
|