feat(app): select a search hit's recorded run section or visit
This commit is contained in:
@@ -89,6 +89,68 @@ Future<void> replyRunDetail(
|
||||
},
|
||||
);
|
||||
|
||||
Future<void> replyRunDetailFor(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
JsonMap detail, {
|
||||
int index = 0,
|
||||
}) => reply(
|
||||
tester,
|
||||
channel,
|
||||
'get_run',
|
||||
index: index,
|
||||
body: {'type': 'run', 'run_detail': detail},
|
||||
);
|
||||
|
||||
/// A run whose recorded sequences are the search target's identity: a plan
|
||||
/// visit 5 and a build visit 2, with run-level input and output sections.
|
||||
JsonMap searchSelectionDetail() => {
|
||||
'id': 7,
|
||||
'title': 'Run 7',
|
||||
'status': 'succeeded',
|
||||
'input': {'prompt': 'ship it'},
|
||||
'output': {'result': 'ok'},
|
||||
'steps': [
|
||||
{
|
||||
'stage': 'plan',
|
||||
'sequence': 5,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
},
|
||||
{
|
||||
'stage': 'build',
|
||||
'sequence': 2,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
JsonMap artifactHit() => {
|
||||
'kind': 'artifact',
|
||||
'target': '/artifacts/7/2/report.txt',
|
||||
'artifact': {
|
||||
'run_id': 7,
|
||||
'sequence': 2,
|
||||
'name': 'report.txt',
|
||||
'content_type': 'text/plain',
|
||||
'size_bytes': 12,
|
||||
'url': '/artifacts/7/2/report.txt',
|
||||
},
|
||||
};
|
||||
|
||||
JsonMap fieldHit() => {
|
||||
'kind': 'field',
|
||||
'target': 'run:7:5:output',
|
||||
'matched_field': 'output',
|
||||
'field': {
|
||||
'run_id': 7,
|
||||
'sequence': 5,
|
||||
'field': 'output',
|
||||
'snippet': 'release',
|
||||
},
|
||||
};
|
||||
|
||||
JsonMap runHit(int id) => {
|
||||
'kind': 'run',
|
||||
'target': 'run:$id',
|
||||
@@ -285,6 +347,174 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('field and artifact hits select their run detail selection', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs/7')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
|
||||
await pumpApp(
|
||||
tester,
|
||||
channel: channel,
|
||||
client: client,
|
||||
provider: provider,
|
||||
cupertino: false,
|
||||
);
|
||||
await replyRunList(tester, channel);
|
||||
await replyRunDetailFor(tester, channel, searchSelectionDetail());
|
||||
expect(find.text('Run 7'), findsWidgets);
|
||||
|
||||
Future<void> sendSearch({
|
||||
required String query,
|
||||
required int index,
|
||||
required JsonMap hit,
|
||||
}) async {
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.enterText(find.byKey(const ValueKey('search.field')), query);
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
final request = await waitForRequest(
|
||||
tester,
|
||||
channel,
|
||||
'search',
|
||||
index: index,
|
||||
);
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': request['id'],
|
||||
'type': 'search_results',
|
||||
'search_results': {
|
||||
'query': query,
|
||||
'kind': '',
|
||||
'results': [hit],
|
||||
'truncated': false,
|
||||
'scanned_steps': 2,
|
||||
'scanned_bytes': 64,
|
||||
'cap': 50,
|
||||
'scan_bound_bytes': 1 << 20,
|
||||
},
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
// An artifact hit opens the run and selects the visit that recorded it.
|
||||
await sendSearch(query: 'report', index: 0, hit: artifactHit());
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('search.result./artifacts/7/2/report.txt')),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
expect(find.byType(SearchScreen), findsNothing);
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.text('build · visit 2'), findsOneWidget);
|
||||
|
||||
// A field hit opens the same run at the Summary section holding the match.
|
||||
await sendSearch(query: 'release', index: 1, hit: fieldHit());
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('search.result.run:7:5:output')),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
expect(find.byType(SearchScreen), findsNothing);
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
||||
expect(find.textContaining('"result": "ok"'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('an artifact hit selects its visit after the run detail loads', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
|
||||
await pumpApp(
|
||||
tester,
|
||||
channel: channel,
|
||||
client: client,
|
||||
provider: provider,
|
||||
cupertino: false,
|
||||
);
|
||||
await replyRunList(tester, channel);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('search.field')),
|
||||
'report',
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
final request = await waitForRequest(tester, channel, 'search');
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': request['id'],
|
||||
'type': 'search_results',
|
||||
'search_results': {
|
||||
'query': 'report',
|
||||
'kind': '',
|
||||
'results': [artifactHit()],
|
||||
'truncated': false,
|
||||
'scanned_steps': 2,
|
||||
'scanned_bytes': 64,
|
||||
'cap': 50,
|
||||
'scan_bound_bytes': 1 << 20,
|
||||
},
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('search.result./artifacts/7/2/report.txt')),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
|
||||
// The run detail is still loading when the request arrives; the selection
|
||||
// is applied by the detail that mounts from this reply.
|
||||
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 0);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.text('build · visit 2'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses its native bar action and Back', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
|
||||
Reference in New Issue
Block a user