feat(app): an open run takes over the app bar (Back, run, more menu); Search is the fifth tab; tabs keep their last screen
This commit is contained in:
@@ -159,11 +159,11 @@ void main() {
|
||||
await replyDetail(tester, channel, 1);
|
||||
|
||||
expect(find.text('Run 1'), findsWidgets);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(provider.value.uri.path, '/runs/1');
|
||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||
|
||||
await tester.tap(find.text('Back to list'));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
expect(find.text('Deep-linked run'), findsWidgets);
|
||||
@@ -211,15 +211,17 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs/2');
|
||||
await replyDetail(tester, channel, 2);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
|
||||
// The engine's browser Back arrives as new route information.
|
||||
await provider.didPushRouteInformation(
|
||||
RouteInformation(uri: Uri.parse('/runs')),
|
||||
);
|
||||
await tester.pump();
|
||||
// The bar returns to the tab's own after the closed run hands it back.
|
||||
await tester.pump();
|
||||
expect(find.text('Beta run'), findsWidgets);
|
||||
expect(find.text('Back to list'), findsNothing);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
|
||||
// Forward re-opens the same run.
|
||||
await provider.didPushRouteInformation(
|
||||
@@ -227,7 +229,8 @@ void main() {
|
||||
);
|
||||
await tester.pump();
|
||||
await replyDetail(tester, channel, 2);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a malformed boot path is corrected to /pipelines', (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_route.dart';
|
||||
import 'package:pipelines_app/application/app_router.dart';
|
||||
@@ -85,13 +85,24 @@ Future<void> replyRun7List(WidgetTester tester, FakeChannel channel) => reply(
|
||||
},
|
||||
);
|
||||
|
||||
/// Taps a tab by its label: the bottom bar or, on a wide window, the rail.
|
||||
Future<void> tapTab(WidgetTester tester, String label) async {
|
||||
final bar = find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is NavigationBar ||
|
||||
widget is NavigationRail ||
|
||||
widget is CupertinoTabBar,
|
||||
);
|
||||
await tester.tap(find.descendant(of: bar, matching: find.text(label)));
|
||||
}
|
||||
|
||||
/// 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 tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -255,7 +266,7 @@ Future<void> pumpApp(
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'the shell action opens focused Search and Close keeps the open run',
|
||||
'the Search tab opens focused and the Runs tab keeps the open run',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -284,10 +295,10 @@ void main() {
|
||||
);
|
||||
await replyRunList(tester, channel);
|
||||
await replyRunDetail(tester, channel, 2);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
|
||||
// The shell's existing action opens Search without adding a fifth tab.
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
// Search is the fifth tab.
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -302,35 +313,22 @@ void main() {
|
||||
),
|
||||
);
|
||||
expect(editable.focusNode.hasFocus, isTrue);
|
||||
expect(find.byType(CloseButton), findsOneWidget);
|
||||
|
||||
// Closing is the native dialog action, not a second router or modal.
|
||||
await tester.tap(find.byType(CloseButton));
|
||||
// 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(find.text('Back to list'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), 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);
|
||||
|
||||
// Escape is the browser panel's close shortcut on this page too.
|
||||
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));
|
||||
expect(provider.value.uri.path, '/search');
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
expect(provider.value.uri.path, '/runs/2');
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
},
|
||||
@@ -367,7 +365,7 @@ void main() {
|
||||
await replyRunList(tester, channel);
|
||||
await replyRunDetail(tester, channel, 2);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -409,7 +407,7 @@ void main() {
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
await replyRunDetail(tester, channel, 7, index: 1);
|
||||
expect(find.byType(SearchScreen), findsNothing);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(find.text('Run 7'), findsWidgets);
|
||||
// One app socket carried the search and the run reads.
|
||||
expect(sockets, 1);
|
||||
@@ -450,7 +448,7 @@ void main() {
|
||||
required int index,
|
||||
required JsonMap hit,
|
||||
}) async {
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -568,7 +566,7 @@ void main() {
|
||||
);
|
||||
await replyRunList(tester, channel);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -651,8 +649,8 @@ void main() {
|
||||
// leaves from the loading placeholder instead.
|
||||
await openArtifactHit(tester, channel);
|
||||
expect(provider.value.uri.path, '/runs/7');
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
await tester.tap(find.text('Back to list'));
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
@@ -711,7 +709,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('run-visit-back')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Back to list'));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
@@ -732,7 +730,7 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses its native bar action and Back', (tester) async {
|
||||
testWidgets('Cupertino Search is a native tab', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
@@ -763,7 +761,7 @@ void main() {
|
||||
await replyRunList(tester, channel);
|
||||
expect(find.text('Preserved run'), findsWidgets);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.search')));
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
@@ -779,7 +777,7 @@ void main() {
|
||||
);
|
||||
expect(cupertinoField.focusNode.hasFocus, isTrue);
|
||||
|
||||
await tester.tap(find.text('Cancel'));
|
||||
await tapTab(tester, 'Runs');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
@@ -844,8 +842,8 @@ void main() {
|
||||
router.openSearch();
|
||||
expect(router.route, AppRoute.search);
|
||||
expect(router.searchOpen, isTrue);
|
||||
// Search is a page above the shell; the open run stays under it.
|
||||
expect(router.shellRoute, AppRoute.run(3));
|
||||
// Without a page builder Search is the shell's own tab.
|
||||
expect(router.shellRoute, AppRoute.search);
|
||||
|
||||
expect(await router.popRoute(), isTrue);
|
||||
expect(router.route, AppRoute.run(3));
|
||||
|
||||
Reference in New Issue
Block a user