Files
pipelines/app/test/shell/shell_bar_empty_actions_test.dart
T
alan 26bb583f10 Refine Settings destination shell integration
Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
2026-11-12 11:21:26 +00:00

99 lines
3.0 KiB
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/windows/window_manager.dart';
import 'windows/window_test_harness.dart';
/// The shell bar's trailing action island is drawn only with actions. The
/// Windows button is one of them only while a floating window is open, so
/// Search and Settings (and every other route) show no empty pill at any size.
void main() {
Future<void> pumpShell(
WidgetTester tester, {
required AppDestination destination,
required double width,
WindowManager? windowManager,
}) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: destination,
windowManager: windowManager,
destinationBodies: {
for (final value in AppDestination.values)
value: (_) => Text('${value.name} body'),
},
),
),
);
await tester.pumpAndSettle();
}
final actionIsland = find.byKey(const ValueKey('segmented.actions'));
for (final width in [1000.0, 430.0]) {
for (final destination in [
AppDestination.search,
AppDestination.settings,
AppDestination.pipelines,
]) {
testWidgets(
'${destination.name} at width ${width.toInt()} draws no empty action '
'island with no floating window',
(tester) async {
await pumpShell(
tester,
destination: destination,
width: width,
windowManager: probeManager(),
);
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
},
);
}
}
testWidgets('a shell without a window manager draws no action island', (
tester,
) async {
await pumpShell(tester, destination: AppDestination.settings, width: 1000);
expect(actionIsland, findsNothing);
});
testWidgets('the Windows button is the island only while a window is open', (
tester,
) async {
final manager = probeManager();
await pumpShell(
tester,
destination: AppDestination.search,
width: 1000,
windowManager: manager,
);
expect(actionIsland, findsNothing);
final entry = manager.open('probe', 'a');
await tester.pumpAndSettle();
expect(actionIsland, findsOneWidget);
expect(
find.descendant(
of: actionIsland,
matching: find.byKey(const ValueKey('shell.windows')),
),
findsOneWidget,
);
manager.close(entry.id);
await tester.pumpAndSettle();
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
});
}