Files
pipelines/app/test/widget_test.dart
T
alan 963adec122 Float glass tab bars everywhere the app has bottom tabs
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the
shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the
run detail, stage page and pipeline detail tab strips. Below 600px it spans
the width minus 16px margins; wider it is sized to its tabs at the right edge.
Content keeps the full width, scrolls behind the bar and learns its height as
bottom media padding; lists pad their end clear of it and FABs sit above it.

The bar now sizes itself from its own constraints instead of the screen size,
which fixes the widget_test failure where a MediaQuery without a size gave it
negative width constraints.
2026-10-31 01:50:42 +00:00

127 lines
4.6 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/main.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
for (final width in [390.0, 1000.0]) {
testWidgets(
'Material shell adapts at width $width and supports large text',
(tester) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
const MaterialApp(
home: MediaQuery(
data: MediaQueryData(textScaler: TextScaler.linear(2)),
child: AdaptiveShell(),
),
),
);
expect(find.text('Pipelines'), findsWidgets);
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
// One floating tab bar at every width; no rail.
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
expect(tester.takeException(), isNull);
await tester.tap(find.text('Runs').last);
await tester.pumpAndSettle();
expect(find.text('Runs — Not implemented'), findsOneWidget);
},
);
}
testWidgets('Cupertino shell uses a tab bar on a narrow window', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(CupertinoNavigationBar), findsNothing);
expect(find.byType(CupertinoTabBar), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
});
testWidgets('Cupertino shell floats its tab bar on a wide window', (
tester,
) async {
tester.view.physicalSize = const Size(1280, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(CupertinoTabBar), findsOneWidget);
expect(find.byType(CupertinoListTile), findsNothing);
expect(
find.byKey(const ValueKey('shell.destination.pipelines')),
findsOneWidget,
);
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
expect(find.text('Runs — Not implemented'), findsOneWidget);
});
testWidgets('Cupertino content stays inside safe area', (tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
tester.view.padding = const FakeViewPadding(top: 36, bottom: 28);
addTearDown(tester.view.resetPadding);
await tester.pumpWidget(const MyApp(cupertino: true));
final tabBar = tester.getRect(find.byType(CupertinoTabBar));
expect(tabBar.bottom, lessThanOrEqualTo(900 - 28));
expect(tester.takeException(), isNull);
});
testWidgets('destination state survives switching tabs', (tester) async {
var builds = 0;
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) => StatefulBuilder(
builder: (context, setState) => TextButton(
onPressed: () => setState(() => builds++),
child: Text('Builds: $builds'),
),
),
AppDestination.runs: (_) => const Text('Runs screen'),
},
),
),
);
await tester.tap(find.text('Builds: 0'));
await tester.pump();
await tester.tap(find.text('Runs').last);
await tester.pumpAndSettle();
await tester.tap(find.text('Pipelines').last);
await tester.pumpAndSettle();
expect(find.text('Builds: 1'), findsOneWidget);
});
testWidgets('destination content can be supplied by integration', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) =>
const Text('Injected pipelines screen'),
},
),
),
);
expect(find.text('Injected pipelines screen'), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsNothing);
});
}