a1c4c1c402
Settings leaves the tab bar (Pipelines, Runs, Chat, Search) and opens as a page from a gear in the Pipelines bar, keeping /settings, its keys and a Back to Pipelines (also the system Back). Every floating tab bar shows icons only, named for assistive technology. On wide windows the shell's tab bar stays at the bottom right; a split detail learns its height plus a 12px gap, so its tabs or the chat composer float above it, and pages the detail opens (the stage page) stay in its pane through its own navigator.
170 lines
5.8 KiB
Dart
170 lines
5.8 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/shell/shell_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
|
|
Widget _app({required bool cupertino, required bool open, VoidCallback? back}) {
|
|
final shell = AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {
|
|
AppDestination.runs: (_) => open
|
|
? ShellBar(
|
|
title: 'Run 7',
|
|
onBack: back,
|
|
actions: const [Icon(Icons.more_vert, key: Key('run-more'))],
|
|
child: const Text('detail'),
|
|
)
|
|
: const Text('list'),
|
|
},
|
|
);
|
|
return cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);
|
|
}
|
|
|
|
void main() {
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'cupertino' : 'material';
|
|
testWidgets('$host: an open screen takes over the bar and gives it back', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
var backs = 0;
|
|
await tester.pumpWidget(
|
|
_app(cupertino: cupertino, open: true, back: () => backs++),
|
|
);
|
|
await tester.pump();
|
|
|
|
expect(find.text('Run 7'), findsOneWidget);
|
|
expect(find.byKey(const Key('run-more')), findsOneWidget);
|
|
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
|
expect(backs, 1);
|
|
|
|
await tester.pumpWidget(_app(cupertino: cupertino, open: false));
|
|
await tester.pump();
|
|
expect(find.text('Run 7'), findsNothing);
|
|
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
|
expect(find.byKey(const Key('run-more')), findsNothing);
|
|
});
|
|
|
|
testWidgets('$host: Search is the fourth tab; Settings is not a tab', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(_app(cupertino: cupertino, open: false));
|
|
expect(AppDestination.values, hasLength(5));
|
|
expect(shellTabDestinations, [
|
|
AppDestination.pipelines,
|
|
AppDestination.runs,
|
|
AppDestination.chat,
|
|
AppDestination.search,
|
|
]);
|
|
expect(
|
|
find.byKey(const ValueKey('shell.destination.search')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('shell.destination.settings')),
|
|
findsNothing,
|
|
);
|
|
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
|
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('$host: floating tabs stay inset and select destinations', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(_app(cupertino: cupertino, open: false));
|
|
|
|
final destinationPill = find.descendant(
|
|
of: find.byType(FloatingDestinationBar),
|
|
matching: find.byType(GlassPill),
|
|
);
|
|
expect(tester.getSize(destinationPill).width, 358);
|
|
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
|
await tester.pump();
|
|
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
|
});
|
|
}
|
|
|
|
testWidgets('tabs show the running and unread counts their screens publish', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptiveShell(
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {
|
|
AppDestination.runs: (_) => const ShellBadge(
|
|
kind: ShellBadgeKind.running,
|
|
count: 2,
|
|
child: Text('runs'),
|
|
),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
final running = find.byKey(const ValueKey('shell.badge.runs.running'));
|
|
expect(
|
|
find.descendant(of: running, matching: find.text('2')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('shell.badge.chat.unread')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.descendant(
|
|
of: find.byKey(const ValueKey('shell.badge.chat.unread')),
|
|
matching: find.textContaining(RegExp(r'\d')),
|
|
),
|
|
findsNothing,
|
|
);
|
|
});
|
|
|
|
testWidgets(
|
|
'a pushed detail covers tabs without unmounting the Back destination',
|
|
(tester) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
Widget shell() => MaterialApp(
|
|
home: AdaptiveShell(
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {AppDestination.runs: (_) => const Text('runs')},
|
|
),
|
|
);
|
|
await tester.pumpWidget(shell());
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
|
navigator.push(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => const Scaffold(body: Text('detail')),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(NavigationBar), findsNothing);
|
|
expect(find.byType(NavigationBar, skipOffstage: false), findsOneWidget);
|
|
await navigator.maybePop();
|
|
await tester.pump(const Duration(milliseconds: 16));
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
},
|
|
);
|
|
}
|