8d2ca95057
On a phone-width window the open run is its own page pushed on the app navigator, so RunDetailTabs was not a descendant of the shell's RunSearchSelectionScope (which wraps only the Runs tab body). The field or artifact selection was never seen and the run opened at its plain Summary. The previous widget tests injected the scope directly above RunDetailView at 900 px, where the detail is an inline pane, so they could not catch it. - RunsScreen relays the shell's search scope into the detail it builds, so the pushed page sees the selection too (also fixes field hits on phones). - An artifact hit now opens the run's Artifacts tab and the gallery opens that artifact exactly as a tap there does: selected, scrolled into view (ArtifactVisitReveal) and in the viewer. Back returns to the tab with the artifact highlighted. An unknown URL leaves the tab open with the existing "That artifact is no longer available." notice. - New test/application/search_artifact_open_test.dart drives the real Search tab -> typed query -> result tap -> run read -> viewer on a 390x844 phone, Material and Cupertino; it fails without the scope relay.
872 lines
26 KiB
Dart
872 lines
26 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import '../native_back.dart';
|
|
import 'package:pipelines_app/application/app_route.dart';
|
|
import 'package:pipelines_app/application/app_router.dart';
|
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
|
import 'package:pipelines_app/application/search_destination.dart';
|
|
import 'package:pipelines_app/application/server_endpoint.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_tile.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;
|
|
|
|
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
|
base: Uri.parse('http://127.0.0.1:8096/'),
|
|
web: true,
|
|
);
|
|
|
|
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
|
|
channel.outgoing
|
|
.map((frame) => jsonDecode(frame as String) as Map<String, dynamic>)
|
|
.where((frame) => frame['type'] == type)
|
|
.toList();
|
|
|
|
Map<String, dynamic>? requestOf(
|
|
FakeChannel channel,
|
|
String type, {
|
|
int index = 0,
|
|
}) {
|
|
final requests = requestsOf(channel, type);
|
|
return index < requests.length ? requests[index] : null;
|
|
}
|
|
|
|
Future<Map<String, dynamic>> waitForRequest(
|
|
WidgetTester tester,
|
|
FakeChannel channel,
|
|
String type, {
|
|
int index = 0,
|
|
}) async {
|
|
for (var attempt = 0; attempt < 80; attempt++) {
|
|
final request = requestOf(channel, type, index: index);
|
|
if (request != null) return request;
|
|
await tester.pump(const Duration(milliseconds: 5));
|
|
}
|
|
fail('Timed out waiting for $type #$index');
|
|
}
|
|
|
|
Future<void> reply(
|
|
WidgetTester tester,
|
|
FakeChannel channel,
|
|
String type, {
|
|
required Map<String, dynamic> body,
|
|
int index = 0,
|
|
}) async {
|
|
final request = await waitForRequest(tester, channel, type, index: index);
|
|
channel.incoming.add(jsonEncode({'id': request['id'], ...body}));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
}
|
|
|
|
Future<void> replyRunList(WidgetTester tester, FakeChannel channel) => reply(
|
|
tester,
|
|
channel,
|
|
'list_runs',
|
|
body: {
|
|
'type': 'runs',
|
|
'runs': [
|
|
{'id': 2, 'name': 'Preserved run', 'status': 'running'},
|
|
],
|
|
},
|
|
);
|
|
|
|
Future<void> replyRun7List(WidgetTester tester, FakeChannel channel) => reply(
|
|
tester,
|
|
channel,
|
|
'list_runs',
|
|
body: {
|
|
'type': 'runs',
|
|
'runs': [
|
|
{'id': 7, 'title': 'Run 7', 'status': 'succeeded'},
|
|
],
|
|
},
|
|
);
|
|
|
|
/// Taps a shell tab by its label (the tabs show icons only, keyed by name).
|
|
Future<void> tapTab(WidgetTester tester, String label) async {
|
|
await tester.tap(
|
|
find.byKey(ValueKey('shell.destination.${label.toLowerCase()}')),
|
|
);
|
|
}
|
|
|
|
/// Opens Search, sends `report` and answers with the artifact hit for run 7.
|
|
Future<void> searchArtifactHit(
|
|
WidgetTester tester,
|
|
FakeChannel channel, {
|
|
int index = 0,
|
|
}) async {
|
|
await tapTab(tester, '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', index: index);
|
|
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();
|
|
}
|
|
|
|
/// Selects the artifact hit, leaving run 7's `get_run` request unanswered.
|
|
Future<void> openArtifactHit(
|
|
WidgetTester tester,
|
|
FakeChannel channel, {
|
|
int index = 0,
|
|
}) async {
|
|
await searchArtifactHit(tester, channel, index: index);
|
|
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));
|
|
}
|
|
|
|
Future<void> replyRunDetail(
|
|
WidgetTester tester,
|
|
FakeChannel channel,
|
|
int id, {
|
|
int index = 0,
|
|
}) => reply(
|
|
tester,
|
|
channel,
|
|
'get_run',
|
|
index: index,
|
|
body: {
|
|
'type': 'run',
|
|
'run_detail': {'id': id, 'title': 'Run $id', 'status': 'running'},
|
|
},
|
|
);
|
|
|
|
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',
|
|
'artifacts': [
|
|
{
|
|
'name': 'report.txt',
|
|
'content_type': 'text/plain',
|
|
'size_bytes': 12,
|
|
'url': '/artifacts/7/2/report.txt',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
/// Closes the open artifact viewer the way its own Back does.
|
|
Future<void> closeViewer(WidgetTester tester) async {
|
|
Navigator.of(tester.element(find.byType(ArtifactViewerPage))).pop();
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
/// Run 7's Artifacts tab is shown with the hit's artifact selected.
|
|
void expectArtifactsTabSelecting(WidgetTester tester, String url) {
|
|
expect(find.byType(ArtifactViewerPage), findsNothing);
|
|
expect(find.byKey(const ValueKey('run-detail-artifacts-7')), findsOneWidget);
|
|
final tile = find.byWidgetPredicate(
|
|
(widget) => widget is ArtifactTile && widget.artifact.url == url,
|
|
);
|
|
expect(tile, findsOneWidget);
|
|
expect(tester.widget<ArtifactTile>(tile).selected, isTrue);
|
|
}
|
|
|
|
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 retiredFieldHit() => {
|
|
'kind': 'field',
|
|
'target': 'run:7:5:evidence',
|
|
'matched_field': 'evidence',
|
|
'field': {
|
|
'run_id': 7,
|
|
'sequence': 5,
|
|
'field': 'evidence',
|
|
'snippet': 'retired',
|
|
},
|
|
};
|
|
|
|
JsonMap runHit(int id) => {
|
|
'kind': 'run',
|
|
'target': 'run:$id',
|
|
'run': {
|
|
'id': id,
|
|
'pipeline_name': 'Preserved run',
|
|
'status': 'running',
|
|
'workspace': '/workspace/demo',
|
|
'created_at': '2026-10-21T12:00:00Z',
|
|
},
|
|
};
|
|
|
|
Future<void> pumpApp(
|
|
WidgetTester tester, {
|
|
required FakeChannel channel,
|
|
required PipelinesClient client,
|
|
required PlatformRouteInformationProvider provider,
|
|
required bool cupertino,
|
|
}) async {
|
|
await tester.pumpWidget(
|
|
PipelinesApp(
|
|
server: webServer(),
|
|
client: client,
|
|
cupertino: cupertino,
|
|
routeInformationProvider: provider,
|
|
),
|
|
);
|
|
await tester.pump();
|
|
}
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'the Search tab opens focused and the Runs tab keeps the open run',
|
|
(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();
|
|
var sockets = 0;
|
|
final client = PipelinesClient(
|
|
channelFactory: (_) {
|
|
sockets++;
|
|
return channel;
|
|
},
|
|
);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs/2')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
|
|
await pumpApp(
|
|
tester,
|
|
channel: channel,
|
|
client: client,
|
|
provider: provider,
|
|
cupertino: false,
|
|
);
|
|
await replyRunList(tester, channel);
|
|
await replyRunDetail(tester, channel, 2);
|
|
// On a phone an open run fills the screen and the tabs step aside, so
|
|
// switching tabs with a run open is a wide-window move.
|
|
|
|
// Search is the fourth tab.
|
|
await tapTab(tester, 'Search');
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 600));
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
|
|
expect(provider.value.uri.path, '/search');
|
|
expect(find.byType(SearchScreen), findsOneWidget);
|
|
expect(find.byKey(const ValueKey('search.field')), findsOneWidget);
|
|
final editable = tester.widget<EditableText>(
|
|
find.descendant(
|
|
of: find.byKey(const ValueKey('search.field')),
|
|
matching: find.byType(EditableText),
|
|
),
|
|
);
|
|
expect(editable.focusNode.hasFocus, isTrue);
|
|
|
|
// The Runs tab returns to the run that was open there.
|
|
await tapTab(tester, 'Runs');
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
|
|
expect(provider.value.uri.path, '/runs/2');
|
|
expect(find.byType(SearchScreen), findsNothing);
|
|
expect(findNativeBack(), findsNothing);
|
|
expect(find.byKey(const ValueKey('run-detail-pane')), findsOneWidget);
|
|
expect(find.text('Run 2'), findsWidgets);
|
|
// The shell was never remounted, so the open run was not re-read.
|
|
expect(requestsOf(channel, 'get_run'), hasLength(1));
|
|
expect(requestsOf(channel, 'list_runs'), hasLength(1));
|
|
expect(sockets, 1);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
},
|
|
);
|
|
|
|
testWidgets('a result opens through the existing run route over one socket', (
|
|
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();
|
|
var sockets = 0;
|
|
final client = PipelinesClient(
|
|
channelFactory: (_) {
|
|
sockets++;
|
|
return channel;
|
|
},
|
|
);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs/2')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
|
|
await pumpApp(
|
|
tester,
|
|
channel: channel,
|
|
client: client,
|
|
provider: provider,
|
|
cupertino: false,
|
|
);
|
|
await replyRunList(tester, channel);
|
|
await replyRunDetail(tester, channel, 2);
|
|
|
|
await tapTab(tester, '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')),
|
|
'release',
|
|
);
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
|
|
final request = await waitForRequest(tester, channel, 'search');
|
|
expect(request['search'], {'query': 'release', 'kind': '', 'limit': 0});
|
|
channel.incoming.add(
|
|
jsonEncode({
|
|
'id': request['id'],
|
|
'type': 'search_results',
|
|
'search_results': {
|
|
'query': 'release',
|
|
'kind': '',
|
|
'results': [runHit(7)],
|
|
'truncated': false,
|
|
'scanned_steps': 4,
|
|
'scanned_bytes': 512,
|
|
'cap': 50,
|
|
'scan_bound_bytes': 1 << 20,
|
|
},
|
|
}),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(find.text('Run 7 · Preserved run'), findsOneWidget);
|
|
await tester.tap(find.byKey(const ValueKey('search.result.run:7')));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
|
|
// The hit map's own run id uses the route Runs already owns.
|
|
expect(provider.value.uri.path, '/runs/7');
|
|
await replyRunDetail(tester, channel, 7, index: 1);
|
|
expect(find.byType(SearchScreen), findsNothing);
|
|
expect(findNativeBack(), findsNothing);
|
|
expect(find.byKey(const ValueKey('run-detail-pane')), findsOneWidget);
|
|
expect(find.text('Run 7'), findsWidgets);
|
|
// One app socket carried the search and the run reads.
|
|
expect(sockets, 1);
|
|
expect(requestsOf(channel, 'search'), hasLength(1));
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
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 tapTab(tester, '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's Artifacts tab and that artifact's viewer.
|
|
await sendSearch(query: 'report', index: 0, hit: artifactHit());
|
|
await tester.tap(
|
|
find.byKey(const ValueKey('search.result./artifacts/7/2/report.txt')),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(provider.value.uri.path, '/runs/7');
|
|
expect(find.byType(SearchScreen), findsNothing);
|
|
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
|
|
|
// Leave the viewer for the Artifacts tab, then a retired field hit opens
|
|
// the plain Summary with no visit.
|
|
await closeViewer(tester);
|
|
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
|
|
await sendSearch(query: 'retired', index: 1, hit: retiredFieldHit());
|
|
await tester.tap(
|
|
find.byKey(const ValueKey('search.result.run:7:5:evidence')),
|
|
);
|
|
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.byKey(const Key('run-detail-tab-body-summary')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.text('ship it'), findsNothing);
|
|
expect(find.text('ok'), findsNothing);
|
|
|
|
// A current field hit opens the same run at the Summary section holding the
|
|
// match, leaving the other section collapsed.
|
|
await sendSearch(query: 'release', index: 2, 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.text('ok'), findsOneWidget);
|
|
expect(find.text('ship it'), findsNothing);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
testWidgets('an artifact hit opens its viewer 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 tapTab(tester, '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.byType(ArtifactViewerPage), findsOneWidget);
|
|
await closeViewer(tester);
|
|
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
testWidgets('an abandoned selection does not replay on run reopen', (
|
|
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 replyRun7List(tester, channel);
|
|
|
|
// The hit navigates to run 7, but its detail is never loaded: the operator
|
|
// leaves from the loading placeholder instead.
|
|
await openArtifactHit(tester, channel);
|
|
expect(provider.value.uri.path, '/runs/7');
|
|
expect(find.byKey(const ValueKey('run-detail-pane')), findsOneWidget);
|
|
await tester.tap(find.text('Back to list'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(provider.value.uri.path, '/runs');
|
|
|
|
// The abandoned read's late reply is ignored; the request queue is free for
|
|
// the ordinary reopen.
|
|
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 0);
|
|
await tester.pump();
|
|
|
|
// Reopening the same run is an ordinary visit: no search named this visit.
|
|
await tester.tap(find.text('Run 7'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 1);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
|
expect(
|
|
find.byKey(const Key('run-detail-tab-body-summary')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.text('ok'), findsNothing);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
testWidgets('a consumed selection does not replay on run reopen', (
|
|
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 replyRun7List(tester, channel);
|
|
|
|
await openArtifactHit(tester, channel);
|
|
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 0);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
|
|
|
await closeViewer(tester);
|
|
await provider.didPushRouteInformation(
|
|
RouteInformation(uri: Uri.parse('/runs')),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(provider.value.uri.path, '/runs');
|
|
|
|
await tester.tap(find.text('Run 7'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 1);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
|
expect(
|
|
find.byKey(const Key('run-detail-tab-body-summary')),
|
|
findsOneWidget,
|
|
);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
testWidgets('Cupertino Search is a native tab', (tester) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
|
|
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
|
|
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
var sockets = 0;
|
|
final client = PipelinesClient(
|
|
channelFactory: (_) {
|
|
sockets++;
|
|
return channel;
|
|
},
|
|
);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
|
|
await pumpApp(
|
|
tester,
|
|
channel: channel,
|
|
client: client,
|
|
provider: provider,
|
|
cupertino: true,
|
|
);
|
|
await replyRunList(tester, channel);
|
|
expect(find.text('Preserved run'), findsWidgets);
|
|
|
|
await tapTab(tester, 'Search');
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 600));
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
|
|
expect(provider.value.uri.path, '/search');
|
|
expect(find.byKey(const ValueKey('search.field')), findsOneWidget);
|
|
expect(find.byType(Material), findsNothing);
|
|
final cupertinoField = tester.widget<EditableText>(
|
|
find.descendant(
|
|
of: find.byKey(const ValueKey('search.field')),
|
|
matching: find.byType(EditableText),
|
|
),
|
|
);
|
|
expect(cupertinoField.focusNode.hasFocus, isTrue);
|
|
|
|
await tapTab(tester, 'Runs');
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
|
|
expect(provider.value.uri.path, '/runs');
|
|
expect(find.byKey(const ValueKey('search.field')), findsNothing);
|
|
expect(find.text('Preserved run'), findsWidgets);
|
|
expect(sockets, 1);
|
|
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
await tester.pump();
|
|
});
|
|
|
|
test(
|
|
'the hit helper never guesses a route for pipeline or malformed hits',
|
|
() {
|
|
expect(searchHitRunId(runHit(3)), 3);
|
|
expect(
|
|
searchHitRunId({
|
|
'kind': 'step',
|
|
'step': {'run_id': 8, 'sequence': 2},
|
|
}),
|
|
8,
|
|
);
|
|
expect(
|
|
searchHitRunId({
|
|
'kind': 'field',
|
|
'field': {'run_id': '9', 'sequence': 1},
|
|
}),
|
|
9,
|
|
);
|
|
expect(
|
|
searchHitRunId({
|
|
'kind': 'pipeline',
|
|
'pipeline': {'id': 4, 'name': 'Alpha'},
|
|
}),
|
|
isNull,
|
|
);
|
|
expect(searchHitRunId({'kind': 'artifact', 'artifact': {}}), isNull);
|
|
expect(
|
|
searchHitRunId({
|
|
'kind': 'run',
|
|
'run': {'id': 0},
|
|
}),
|
|
isNull,
|
|
);
|
|
},
|
|
);
|
|
|
|
test('openSearch keeps the previous route and closing restores it', () async {
|
|
final router = AppRouterDelegate(
|
|
builder: (context, route) => const SizedBox.shrink(),
|
|
cupertino: false,
|
|
initial: AppRoute.run(3),
|
|
);
|
|
addTearDown(router.dispose);
|
|
|
|
router.openSearch();
|
|
expect(router.route, AppRoute.search);
|
|
expect(router.searchOpen, isTrue);
|
|
// Without a page builder Search is the shell's own tab.
|
|
expect(router.shellRoute, AppRoute.search);
|
|
|
|
router.closeSearch();
|
|
expect(router.route, AppRoute.run(3));
|
|
expect(router.searchOpen, isFalse);
|
|
});
|
|
|
|
test('the /search route is total and survives the parser', () {
|
|
expect(AppRoute.parse('/search'), AppRoute.search);
|
|
expect(
|
|
AppRoute.parse('http://127.0.0.1:8096/search?q=plan'),
|
|
AppRoute.search,
|
|
);
|
|
expect(AppRoute.parse('/search/2'), AppRoute.pipelines);
|
|
expect(AppRoute.search.path, '/search');
|
|
});
|
|
}
|