feat(app): select a search hit's recorded run section or visit
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
import 'package:flutter/cupertino.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/run_search_selection.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
|
||||
import 'run_detail_graph_support.dart';
|
||||
|
||||
/// plan visits 5 and 1 around one build visit 2: the server's sequence is not
|
||||
/// the step's row index, so resolution must read the recorded sequence.
|
||||
JsonMap searchSelectionRun() => <String, dynamic>{
|
||||
'id': 77,
|
||||
'title': 'Search selection run',
|
||||
'name': 'release',
|
||||
'status': 'succeeded',
|
||||
'input': <String, dynamic>{'prompt': 'ship it'},
|
||||
'output': <String, dynamic>{'result': 'ok'},
|
||||
'steps': <dynamic>[
|
||||
<String, dynamic>{
|
||||
'stage': 'plan',
|
||||
'sequence': 5,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
},
|
||||
<String, dynamic>{
|
||||
'stage': 'build',
|
||||
'sequence': 2,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
},
|
||||
<String, dynamic>{
|
||||
'stage': 'plan',
|
||||
'sequence': 1,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Future<void> pumpSelection(
|
||||
WidgetTester tester,
|
||||
RunDetailTestPlatform platform,
|
||||
RunSearchSelection selection, {
|
||||
VoidCallback? onConsumed,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final gateway = RunDetailFakeGateway(searchSelectionRun());
|
||||
final controller = RunsController(RunsRepository(gateway));
|
||||
addTearDown(controller.dispose);
|
||||
await controller.select(77);
|
||||
final page = MediaQuery(
|
||||
data: MediaQueryData.fromView(tester.view),
|
||||
child: RunSearchSelectionScope(
|
||||
selection: selection,
|
||||
onConsumed: onConsumed ?? () {},
|
||||
child: RunDetailView(
|
||||
controller: controller,
|
||||
gateway: gateway,
|
||||
onBack: () {},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(
|
||||
platform == RunDetailTestPlatform.material
|
||||
? MaterialApp(home: Scaffold(body: page))
|
||||
: CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: page)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name} artifact hit opens its recorded visit', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpSelection(
|
||||
tester,
|
||||
platform,
|
||||
const RunSearchSelection(runId: 77, sequence: 2),
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.text('build · visit 2'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('an unknown artifact sequence opens the plain run', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(runId: 77, sequence: 99),
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('an input field hit expands the Summary input section', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(runId: 77, sequence: 5, field: 'input'),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('"prompt": "ship it"'), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name} output field expands the Summary section', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpSelection(
|
||||
tester,
|
||||
platform,
|
||||
const RunSearchSelection(runId: 77, sequence: 5, field: 'output'),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('"result": "ok"'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a retired field opens the plain Summary', (tester) async {
|
||||
await pumpSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(runId: 77, sequence: 5, field: 'evidence'),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('"prompt": "ship it"'), findsNothing);
|
||||
expect(find.textContaining('"result": "ok"'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the search request is consumed once it has been applied', (
|
||||
tester,
|
||||
) async {
|
||||
var consumed = 0;
|
||||
await pumpSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(runId: 77, sequence: 2),
|
||||
onConsumed: () => consumed++,
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(consumed, 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user