Merge branch 'main' into run-chat-info-header
This commit is contained in:
@@ -52,7 +52,9 @@ void main() {
|
||||
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
|
||||
expect(find.bySemanticsLabel(needingAttention), findsNothing);
|
||||
|
||||
await tester.tap(find.text('Pipelines').last);
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('shell.destination.pipelines')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
await waitForRequest(tester, channel, 'list_pipelines');
|
||||
|
||||
@@ -159,7 +159,9 @@ void main() {
|
||||
expect(tester.getSize(list).width, closeTo(before, 0.01));
|
||||
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
|
||||
expect(
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
|
||||
tester
|
||||
.state<NavigatorState>(find.byType(Navigator).first)
|
||||
.canPop(),
|
||||
isFalse,
|
||||
);
|
||||
for (final rowKey in rowKeys) {
|
||||
@@ -224,7 +226,9 @@ void main() {
|
||||
tester.view.physicalSize = const Size(390, 900);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
|
||||
tester
|
||||
.state<NavigatorState>(find.byType(Navigator).first)
|
||||
.canPop(),
|
||||
isTrue,
|
||||
reason: '$destination should push its selected item on a phone',
|
||||
);
|
||||
@@ -235,7 +239,9 @@ void main() {
|
||||
tester.view.physicalSize = Size(width, 900);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
|
||||
tester
|
||||
.state<NavigatorState>(find.byType(Navigator).first)
|
||||
.canPop(),
|
||||
isFalse,
|
||||
);
|
||||
expect(tester.getSize(list).width, closeTo(before, 0.01));
|
||||
|
||||
@@ -239,7 +239,7 @@ void main() {
|
||||
final pipelinesRunsId =
|
||||
pipelineRequest(channel, 'list_runs')!['id'] as String;
|
||||
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../features/runs/ui/run_detail_finders.dart';
|
||||
import '../native_back.dart';
|
||||
@@ -87,15 +86,11 @@ Future<void> replyRun7List(WidgetTester tester, FakeChannel channel) => reply(
|
||||
},
|
||||
);
|
||||
|
||||
/// Taps a tab by its label: the bottom bar or, on a wide window, the rail.
|
||||
/// Taps a shell tab by its label (the tabs show icons only, keyed by name).
|
||||
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.byKey(ValueKey('shell.destination.${label.toLowerCase()}')),
|
||||
);
|
||||
await tester.tap(find.descendant(of: bar, matching: find.text(label)));
|
||||
}
|
||||
|
||||
/// Opens Search, sends `report` and answers with the artifact hit for run 7.
|
||||
@@ -300,7 +295,7 @@ void main() {
|
||||
// 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 fifth tab.
|
||||
// Search is the fourth tab.
|
||||
await tapTab(tester, 'Search');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import 'pipelines_app_test.dart' show webServer;
|
||||
import 'pipelines_replies.dart';
|
||||
|
||||
/// Settings is not a tab: it opens as a page from the gear in the Pipelines
|
||||
/// bar, keeps its `/settings` route (and deep link), and closes back to
|
||||
/// Pipelines. The tab bar keeps Pipelines selected meanwhile.
|
||||
void main() {
|
||||
Future<PlatformRouteInformationProvider> pumpApp(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
required String location,
|
||||
required Size size,
|
||||
}) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse(location)),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
server: webServer(),
|
||||
client: PipelinesClient(channelFactory: (_) => channel),
|
||||
cupertino: cupertino,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
if (location == '/pipelines') {
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
int selectedTab(WidgetTester tester) => tester
|
||||
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
|
||||
.currentIndex;
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
|
||||
testWidgets('$host ${size.width}: the Pipelines bar gear opens Settings '
|
||||
'as a page and Back returns', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
location: '/pipelines',
|
||||
size: size,
|
||||
);
|
||||
// Four tabs; Settings is none of them.
|
||||
expect(
|
||||
tester
|
||||
.widget<FloatingDestinationBar>(
|
||||
find.byType(FloatingDestinationBar),
|
||||
)
|
||||
.items
|
||||
.map((item) => item.label),
|
||||
['Pipelines', 'Runs', 'Chat', 'Search'],
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('shell.destination.settings')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
expect(find.text('Server URL'), findsOneWidget);
|
||||
// A page of Pipelines: Back in its bar, Pipelines still selected.
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
||||
expect(selectedTab(tester), 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('$host: the /settings deep link opens the Settings page and '
|
||||
'the system Back closes it to Pipelines', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
location: '/settings',
|
||||
size: const Size(390, 844),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(selectedTab(tester), 0);
|
||||
|
||||
final handled = await tester.binding.handlePopRoute();
|
||||
expect(handled, isTrue, reason: 'Back closes the page, not the app');
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
);
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
|
||||
await tester.tap(find.text('Settings').last);
|
||||
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
|
||||
@@ -93,7 +93,7 @@ Future<void> openSettings(
|
||||
FakeChannel channel,
|
||||
PlatformRouteInformationProvider provider,
|
||||
) async {
|
||||
await tester.tap(find.text('Settings').last);
|
||||
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
@@ -354,7 +354,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(templatesPageBackKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Pipelines').last);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
|
||||
@@ -64,7 +64,9 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('First chat'));
|
||||
await tester.pumpAndSettle();
|
||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||
final navigator = tester.state<NavigatorState>(
|
||||
find.byType(Navigator).first,
|
||||
);
|
||||
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||
@@ -106,7 +108,7 @@ void main() {
|
||||
expect(navigator.canPop(), isFalse);
|
||||
|
||||
// The rail still switches destinations with a chat open.
|
||||
await tester.tap(find.text('Runs'));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('chat-thread-b')), findsNothing);
|
||||
|
||||
@@ -120,7 +122,9 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('First chat'));
|
||||
await tester.pumpAndSettle();
|
||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||
final navigator = tester.state<NavigatorState>(
|
||||
find.byType(Navigator).first,
|
||||
);
|
||||
expect(navigator.canPop(), isTrue);
|
||||
expect(findNativeBack(), findsOneWidget);
|
||||
expect(find.byType(NavigationBar), findsNothing);
|
||||
|
||||
@@ -46,9 +46,11 @@ Future<void> _pumpScreen(WidgetTester tester) async {
|
||||
Future<void> _openGraphTab(WidgetTester tester, int pipelineId) async {
|
||||
await tester.tap(find.byKey(Key('pipeline-row-$pipelineId')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.ensureVisible(find.text('Graph'));
|
||||
await tester.ensureVisible(
|
||||
find.byKey(const Key('pipeline-detail-tab-graph')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
@@ -61,9 +61,11 @@ Future<void> _openGraphTab(WidgetTester tester, int pipelineId) async {
|
||||
// The detail header scrolls when content-driven title/tab height needs it
|
||||
// (the header gained the native Run action), so reach the tab like an
|
||||
// operator would instead of requiring it to fit without scrolling.
|
||||
await tester.ensureVisible(find.text('Graph'));
|
||||
await tester.ensureVisible(
|
||||
find.byKey(const Key('pipeline-detail-tab-graph')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
@@ -203,9 +205,9 @@ void main() {
|
||||
|
||||
// The selection belongs to the panel, so an in-place tab round trip keeps
|
||||
// the same node marked (the web keeps its graph selection across tabs).
|
||||
await tester.tap(find.text('Summary'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(tester.widget<GraphStageNode>(_node('review')).selected, isTrue);
|
||||
@@ -227,14 +229,14 @@ void main() {
|
||||
|
||||
// The selection belongs to the pinned definition: changing version must not
|
||||
// carry a same-named node's mark into the other version.
|
||||
await tester.tap(find.text('Summary'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.ensureVisible(find.byKey(const Key('pipeline-version-1')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipeline-version-1')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(tester.widget<GraphStageNode>(_node('review')).selected, isFalse);
|
||||
|
||||
@@ -75,14 +75,14 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1});
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(find.text('name: alpha'), findsOneWidget);
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.byKey(scheduleAddKey), findsNothing);
|
||||
await tester.tap(find.text('Summary'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||
}
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, PipelineDetailTab.source);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
@@ -68,9 +68,11 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.ensureVisible(find.text('Source'));
|
||||
await tester.ensureVisible(
|
||||
find.byKey(const Key('pipeline-detail-tab-source')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(
|
||||
@@ -153,7 +155,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('pipeline-version-1')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
@@ -199,9 +201,11 @@ void main() {
|
||||
// The header scrolls instead of squeezing the tab out; the tabs stay
|
||||
// reachable inside it and the tab keeps a bounded slot.
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.ensureVisible(find.text('Graph'));
|
||||
await tester.ensureVisible(
|
||||
find.byKey(const Key('pipeline-detail-tab-graph')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Graph'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
@@ -45,7 +45,7 @@ void main() {
|
||||
'version': 2,
|
||||
});
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText('name: Alpha review\nstages:\n review:\n type: model'),
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
});
|
||||
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Summary'));
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(const Key('pipeline-latest-version')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -112,7 +112,10 @@ void main() {
|
||||
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Changes'), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const ValueKey('run-detail-tab-changes')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('lib/feature.dart'), findsOneWidget);
|
||||
expect(
|
||||
find.text('1 file changed · +2 -2 · capture incomplete'),
|
||||
|
||||
@@ -24,21 +24,31 @@ void main() {
|
||||
RunDetailTab.changes,
|
||||
]);
|
||||
final strip = find.byKey(const Key('run-detail-tabs'));
|
||||
for (final label in ['Summary', 'Timeline', 'Artifacts', 'Changes']) {
|
||||
// Icon-only tabs, each keyed by its name.
|
||||
for (final name in ['summary', 'timeline', 'artifacts', 'changes']) {
|
||||
expect(
|
||||
find.descendant(of: strip, matching: find.text(label)),
|
||||
find.descendant(
|
||||
of: strip,
|
||||
matching: find.byKey(ValueKey('run-detail-tab-$name')),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
expect(
|
||||
find.descendant(of: strip, matching: find.text('Graph')),
|
||||
find.descendant(
|
||||
of: strip,
|
||||
matching: find.byKey(const ValueKey('run-detail-tab-graph')),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byKey(runGraphPreviewKey), findsOneWidget);
|
||||
// Input and Output are Summary sections now, never separate tabs.
|
||||
for (final label in ['Input', 'Output']) {
|
||||
for (final name in ['input', 'output']) {
|
||||
expect(
|
||||
find.descendant(of: strip, matching: find.text(label)),
|
||||
find.descendant(
|
||||
of: strip,
|
||||
matching: find.byKey(ValueKey('run-detail-tab-$name')),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -165,9 +165,12 @@ void main() {
|
||||
}
|
||||
|
||||
Future<void> tapTab(String label) async {
|
||||
await tester.ensureVisible(find.text(label));
|
||||
final tab = find.byKey(
|
||||
ValueKey('run-detail-tab-${label.toLowerCase()}'),
|
||||
);
|
||||
await tester.ensureVisible(tab);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(label));
|
||||
await tester.tap(tab);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@ void main() {
|
||||
|
||||
testWidgets('the badge stays visible from every destination', (tester) async {
|
||||
await pumpShell(tester, width: 1000, cupertino: false, count: 2);
|
||||
for (final label in ['Runs', 'Chat', 'Settings']) {
|
||||
await tester.tap(find.text(label).last);
|
||||
for (final name in ['runs', 'chat', 'search']) {
|
||||
await tester.tap(find.byKey(ValueKey('shell.destination.$name')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.descendant(of: find.byType(Badge), matching: find.text('2')),
|
||||
findsOneWidget,
|
||||
reason: 'badge missing on $label',
|
||||
reason: 'badge missing on $name',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,11 +14,6 @@ void main() {
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
|
||||
Finder barText(String label) => find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
matching: find.text(label),
|
||||
);
|
||||
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -74,7 +69,14 @@ void main() {
|
||||
expect(rect.right, 1200 - 16);
|
||||
expect(rect.bottom, 800 - 16);
|
||||
expect(rect.width, lessThan(1200 * 0.6));
|
||||
expect(rect.width, greaterThan(5 * 72));
|
||||
// Four icon-only tabs (Settings opens from the Pipelines bar).
|
||||
expect(
|
||||
rect.width,
|
||||
4 *
|
||||
(cupertino
|
||||
? FloatingDestinationBar.cupertinoTabWidth
|
||||
: FloatingDestinationBar.materialTabWidth),
|
||||
);
|
||||
// No rail or sidebar: the content starts at the left edge.
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(find.byType(CupertinoListTile), findsNothing);
|
||||
@@ -143,12 +145,16 @@ void main() {
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.getSemantics(barText('Runs')),
|
||||
isSemantics(isSelected: true),
|
||||
final runs = tester.getSemantics(
|
||||
find.byKey(const ValueKey('shell.destination.runs')),
|
||||
);
|
||||
expect(runs, isSemantics(isSelected: true));
|
||||
// Icon-only, yet the tab keeps its name for assistive technology.
|
||||
expect(runs.label, startsWith('Runs'));
|
||||
expect(
|
||||
tester.getSemantics(barText('Chat')),
|
||||
tester.getSemantics(
|
||||
find.byKey(const ValueKey('shell.destination.chat')),
|
||||
),
|
||||
isNot(isSemantics(isSelected: true)),
|
||||
);
|
||||
semantics.dispose();
|
||||
|
||||
@@ -151,7 +151,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
|
||||
'pane, beside the shell\'s tab bar', (tester) async {
|
||||
'pane, above the shell\'s tab bar', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
@@ -174,8 +174,11 @@ void main() {
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
// Near the bottom of the detail pane, never on the shell's tabs.
|
||||
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
// The shell's tabs keep the bottom right; the item's float a gap
|
||||
// above them in the detail pane, never on them.
|
||||
expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.bottom, closeTo(shellTabs.top - kStackedBarGap, 0.5));
|
||||
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(itemTabs.overlaps(shellTabs), isFalse);
|
||||
// The item's list starts below its bar and clears its tabs at rest.
|
||||
|
||||
@@ -52,13 +52,28 @@ void main() {
|
||||
expect(find.byKey(const Key('run-more')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host: Search is the fifth tab', (tester) async {
|
||||
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(find.text('Search'), findsOneWidget);
|
||||
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);
|
||||
});
|
||||
@@ -76,7 +91,7 @@ void main() {
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
expect(tester.getSize(destinationPill).width, 358);
|
||||
await tester.tap(find.text('Chat'));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pump();
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -5,11 +5,13 @@ import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/list_detail.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
/// While a tab shows its list beside an open item, the shell's destination
|
||||
/// bar floats over the list pane only: it never covers the item, and the
|
||||
/// item's own bottom control (a composer) owns the pane's bottom edge.
|
||||
/// bar keeps its place at the bottom right (near the thumb). The item's own
|
||||
/// bottom control (its tabs, or a composer) floats above it with a gap, and
|
||||
/// the item's content clears both.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
@@ -43,9 +45,36 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
/// A detail with its own floating tabs over a list, like run detail.
|
||||
Widget tabsDetail(bool cupertino) => FloatingBarOverlay(
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('detail-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
FloatingDestinationItem(icon: Icon(Icons.summarize), label: 'One'),
|
||||
FloatingDestinationItem(icon: Icon(Icons.timeline), label: 'Two'),
|
||||
FloatingDestinationItem(icon: Icon(Icons.inventory), label: 'Three'),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Builder(
|
||||
builder: (context) => ListView(
|
||||
key: const Key('detail-list'),
|
||||
children: [
|
||||
for (var index = 0; index < 40; index++)
|
||||
SizedBox(height: 40, child: Text('item $index')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget shell({
|
||||
required bool cupertino,
|
||||
bool split = true,
|
||||
bool tabs = false,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
final app = AdaptiveShell(
|
||||
@@ -53,7 +82,10 @@ void main() {
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => split
|
||||
? ListDetailPanes(list: listBody(), detail: composerDetail())
|
||||
? ListDetailPanes(
|
||||
list: listBody(),
|
||||
detail: tabs ? tabsDetail(cupertino) : composerDetail(),
|
||||
)
|
||||
: listBody(),
|
||||
},
|
||||
);
|
||||
@@ -78,8 +110,8 @@ void main() {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
for (final width in [1200.0, 1600.0]) {
|
||||
testWidgets('$host $width split: the destination bar stays over the '
|
||||
'list pane and the composer owns the detail bottom', (tester) async {
|
||||
testWidgets('$host $width split: the destination bar stays bottom '
|
||||
'right and the composer floats above it', (tester) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
@@ -92,23 +124,59 @@ void main() {
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.right, lessThanOrEqualTo(list.right));
|
||||
expect(pill.left, greaterThanOrEqualTo(list.left));
|
||||
expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail');
|
||||
// Compact at the window's right edge, over the detail pane only.
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(pill.width, lessThan(body.width / 2));
|
||||
expect(pill.overlaps(list), isFalse, reason: 'never over the list');
|
||||
expect(pill.left, greaterThan(body.left));
|
||||
|
||||
// The detail keeps only the system inset (none here): its composer
|
||||
// reaches the bottom edge, below the level of the shell's pill.
|
||||
// The composer's box starts a gap above the shell's pill (the real
|
||||
// composer pads its pill by another 12 inside that box).
|
||||
final composer = tester.getRect(find.byKey(const Key('composer')));
|
||||
expect(composer.bottom, 800);
|
||||
expect(composer.left, body.left);
|
||||
expect(composer.top, greaterThan(pill.top));
|
||||
expect(composer.overlaps(pill), isFalse);
|
||||
expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
|
||||
// The list still clears the bar.
|
||||
// The list is not under the bar: it clears only the system inset.
|
||||
final listContext = tester.element(find.byKey(const Key('list')));
|
||||
expect(MediaQuery.paddingOf(listContext).bottom, 0);
|
||||
});
|
||||
|
||||
testWidgets('$host $width split: the item tabs float above the '
|
||||
'destination bar with a gap, and its content clears both', (
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, tabs: true));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
final tabs = tester.getRect(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('detail-tabs')),
|
||||
matching: find.byType(GlassPill),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.left, greaterThan(body.left));
|
||||
expect(tabs.overlaps(pill), isFalse);
|
||||
expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
|
||||
// The item's list pads its end clear of both pills.
|
||||
final listContext = tester.element(
|
||||
find.byKey(const Key('detail-list')),
|
||||
);
|
||||
expect(
|
||||
MediaQuery.paddingOf(listContext).bottom,
|
||||
greaterThanOrEqualTo(pill.height),
|
||||
closeTo(800 - tabs.top, 0.5),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -134,17 +202,21 @@ void main() {
|
||||
});
|
||||
|
||||
for (final width in [600.0, 840.0]) {
|
||||
testWidgets('$host $width split at 2x: the narrow list pane bar lays '
|
||||
'out without overflow', (tester) async {
|
||||
testWidgets('$host $width split at 2x: both bars lay out over the '
|
||||
'detail pane without overflow', (tester) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2));
|
||||
await tester.pumpWidget(
|
||||
shell(cupertino: cupertino, tabs: true, textScale: 2),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
expect(destinationPill(tester).right, lessThanOrEqualTo(list.right));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.left, greaterThanOrEqualTo(body.left));
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
import 'package:pipelines_app/shell/list_detail.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
import '../features/runs/ui/run_detail_graph_support.dart';
|
||||
import '../features/runs/ui/run_detail_visit_support.dart';
|
||||
|
||||
/// On a wide split window (unfolded foldable, desktop) the real run detail
|
||||
/// and the stage page it opens keep the shell's tab bar at the bottom right
|
||||
/// and float their own tabs above it with a gap; the stage page opens inside
|
||||
/// the detail pane instead of covering the shell.
|
||||
void main() {
|
||||
Rect pillOf(WidgetTester tester, Finder owner) => tester.getRect(
|
||||
find.descendant(of: owner, matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
|
||||
Rect shellPill(WidgetTester tester) => tester.getRect(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byType(GlassPill),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
|
||||
Future<void> pumpSplitRun(WidgetTester tester, bool cupertino) async {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final gateway = RunDetailFakeGateway(visitRunFixture());
|
||||
final controller = RunsController(RunsRepository(gateway));
|
||||
addTearDown(controller.dispose);
|
||||
await controller.select(77);
|
||||
final shell = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.runs,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ListDetailPanes(
|
||||
list: ListView(
|
||||
children: [for (var i = 0; i < 30; i++) Text('run row $i')],
|
||||
),
|
||||
detail: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
implyBack: false,
|
||||
builder: (_) => RunDetailView(
|
||||
controller: controller,
|
||||
gateway: gateway,
|
||||
onBack: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: shell)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: shell,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host 1200: run tabs float above the shell bar, and the '
|
||||
'stage page opens in the pane with its tabs above it too', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpSplitRun(tester, cupertino);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
var main = shellPill(tester);
|
||||
expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
|
||||
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
|
||||
expect(runTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(runTabs.overlaps(main), isFalse);
|
||||
expect(main.top - runTabs.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
|
||||
// Open the stage page from the timeline.
|
||||
await openRunDetailTab(tester, RunDetailTab.timeline);
|
||||
final row = find.byKey(const ValueKey('run-timeline-visit-1'));
|
||||
await tester.ensureVisible(row);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(row);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
|
||||
// The page covers only the detail pane: the root navigator has nothing
|
||||
// pushed, and the list and the shell's tab bar stay in place.
|
||||
expect(
|
||||
tester.state<NavigatorState>(find.byType(Navigator).first).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
expect(find.text('run row 0'), findsOneWidget);
|
||||
final back = tester.getRect(find.byKey(const Key('run-visit-back')));
|
||||
expect(back.left, greaterThanOrEqualTo(body.left));
|
||||
main = shellPill(tester);
|
||||
expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
final visitTabs = pillOf(
|
||||
tester,
|
||||
find.byKey(const Key('run-visit-tabs')).last,
|
||||
);
|
||||
expect(visitTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(visitTabs.overlaps(main), isFalse);
|
||||
expect(main.top - visitTabs.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
// The shell's tabs still work over the open stage page.
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Back closes the page inside the pane, back to the run.
|
||||
await tester.tap(find.byKey(const Key('run-visit-back')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('run-visit-back')), findsNothing);
|
||||
expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,19 @@ import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||
/// On a wide split window (an unfolded foldable) under a system status bar,
|
||||
/// every pane's bar sits below the status-bar inset while content still
|
||||
/// reaches the top edge; and the open item's tabs float at the bottom of the
|
||||
/// detail pane, beside (never on) the shell's tab bar over the list.
|
||||
/// detail pane, above (never on) the shell's tab bar at the bottom right.
|
||||
void main() {
|
||||
const statusBar = 40.0;
|
||||
|
||||
Future<void> setUp(WidgetTester tester, Size size) async {
|
||||
Future<void> setUp(
|
||||
WidgetTester tester,
|
||||
Size size, {
|
||||
double bottom = 0,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.padding = const FakeViewPadding(top: statusBar);
|
||||
tester.view.viewPadding = const FakeViewPadding(top: statusBar);
|
||||
tester.view.padding = FakeViewPadding(top: statusBar, bottom: bottom);
|
||||
tester.view.viewPadding = FakeViewPadding(top: statusBar, bottom: bottom);
|
||||
addTearDown(tester.view.reset);
|
||||
}
|
||||
|
||||
@@ -156,9 +160,10 @@ void main() {
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
});
|
||||
|
||||
testWidgets('$host split: the item tabs float at the bottom of the '
|
||||
'detail pane, beside the shell tab bar over the list', (tester) async {
|
||||
await setUp(tester, const Size(1200, 800));
|
||||
testWidgets('$host split: the item tabs float above the shell tab bar '
|
||||
'at the bottom right of the detail pane', (tester) async {
|
||||
// A gesture-navigation inset as on the unfolded foldable.
|
||||
await setUp(tester, const Size(1200, 800), bottom: 24);
|
||||
await tester.pumpWidget(shell(cupertino, tabbedItem));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
@@ -167,7 +172,6 @@ void main() {
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single;
|
||||
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(tabs.right, lessThanOrEqualTo(body.right));
|
||||
final shellTabs = tester.getRect(
|
||||
@@ -178,8 +182,13 @@ void main() {
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// The shell's bar keeps the bottom right, above the system inset; the
|
||||
// item's tabs sit a gap above it, both at the trailing edge.
|
||||
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
|
||||
expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.overlaps(tabs), isFalse);
|
||||
expect(shellTabs.right, lessThanOrEqualTo(body.left));
|
||||
expect(shellTabs.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
// The item's list clears its tabs at rest.
|
||||
final list = tester.element(find.byKey(const Key('item-list')));
|
||||
expect(
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
|
||||
/// assistive technology (and a Material tooltip), its selected state and its
|
||||
/// test key; the icons within a bar, and against the shell's tabs a detail's
|
||||
/// bar floats above, are distinct.
|
||||
void main() {
|
||||
Widget host(bool cupertino, Widget bar) {
|
||||
final body = Align(alignment: Alignment.bottomCenter, child: bar);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
|
||||
final bars = <String, (Widget, List<(String, String)>)>{
|
||||
'run detail': (
|
||||
RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}),
|
||||
[
|
||||
for (final tab in renderedRunDetailTabs)
|
||||
('run-detail-tab-${tab.name}', tab.label),
|
||||
],
|
||||
),
|
||||
'stage page': (
|
||||
RunVisitSectionStrip(
|
||||
selected: RunVisitSection.summary,
|
||||
onSelected: (_) {},
|
||||
),
|
||||
[
|
||||
for (final section in shownVisitSections)
|
||||
('run-visit-tab-${section.name}', section.label),
|
||||
],
|
||||
),
|
||||
'pipeline detail': (
|
||||
PipelineDetailTabs(
|
||||
selected: PipelineDetailTab.summary,
|
||||
onSelected: (_) {},
|
||||
),
|
||||
[
|
||||
for (final tab in PipelineDetailTab.values)
|
||||
('pipeline-detail-tab-${tab.name}', tab.label),
|
||||
],
|
||||
),
|
||||
};
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final name = cupertino ? 'Cupertino' : 'Material';
|
||||
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
||||
testWidgets('$name $label tabs are icons named for assistive '
|
||||
'technology', (tester) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(host(cupertino, bar));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final floating = find.byType(FloatingDestinationBar);
|
||||
if (cupertino) {
|
||||
// No label is drawn at all.
|
||||
expect(
|
||||
find.descendant(of: floating, matching: find.byType(Text)),
|
||||
findsNothing,
|
||||
);
|
||||
} else {
|
||||
// NavigationBar keeps its label hidden (for semantics only).
|
||||
expect(
|
||||
NavigationBarTheme.of(
|
||||
tester.element(find.byType(NavigationDestination).first),
|
||||
).labelBehavior,
|
||||
NavigationDestinationLabelBehavior.alwaysHide,
|
||||
);
|
||||
}
|
||||
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
||||
final node = tester.getSemantics(find.byKey(ValueKey(key)));
|
||||
expect(node.label, startsWith(tabLabel), reason: key);
|
||||
expect(
|
||||
node,
|
||||
index == 0
|
||||
? isSemantics(isSelected: true)
|
||||
: isNot(isSemantics(isSelected: true)),
|
||||
reason: key,
|
||||
);
|
||||
}
|
||||
// Distinct glyphs within the bar.
|
||||
final icons = tester
|
||||
.widgetList<Icon>(
|
||||
find.descendant(of: floating, matching: find.byType(Icon)),
|
||||
)
|
||||
.map((icon) => icon.icon)
|
||||
.toSet();
|
||||
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test('detail tab icons differ from the shell tabs they float above', () {
|
||||
final shell = {
|
||||
for (final destination in shellTabDestinations) ...[
|
||||
destinationDetails(destination).icon,
|
||||
destinationDetails(destination).cupertinoIcon,
|
||||
],
|
||||
};
|
||||
final details = [
|
||||
for (final tab in renderedRunDetailTabs) ...[tab.icon, tab.cupertinoIcon],
|
||||
for (final section in shownVisitSections) ...[
|
||||
section.icon,
|
||||
section.cupertinoIcon,
|
||||
],
|
||||
for (final tab in PipelineDetailTab.values) ...[
|
||||
tab.icon,
|
||||
tab.cupertinoIcon,
|
||||
],
|
||||
];
|
||||
for (final icon in details) {
|
||||
expect(shell.contains(icon), isFalse, reason: '$icon');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -28,7 +28,7 @@ void main() {
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
||||
},
|
||||
@@ -104,9 +104,9 @@ void main() {
|
||||
);
|
||||
await tester.tap(find.text('Builds: 0'));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Pipelines').last);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Builds: 1'), findsOneWidget);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user