963adec122
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.
106 lines
3.8 KiB
Dart
106 lines
3.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';
|
|
|
|
/// The Runs tab mirrors the attention count in every mount of both hosts:
|
|
/// the floating tab bar at full width on a phone and right-aligned on a wide
|
|
/// window. Zero draws the
|
|
/// bare icon with no count and no attention semantics.
|
|
void main() {
|
|
final needingAttention = RegExp('Notifications, 3 needing attention');
|
|
final anyAttention = RegExp('needing attention');
|
|
|
|
Future<void> pumpShell(
|
|
WidgetTester tester, {
|
|
required double width,
|
|
required bool cupertino,
|
|
required int count,
|
|
}) async {
|
|
tester.view.physicalSize = Size(width, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final shell = AdaptiveShell(cupertino: cupertino, attentionCount: count);
|
|
await tester.pumpWidget(
|
|
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
|
|
);
|
|
}
|
|
|
|
for (final width in [390.0, 1000.0]) {
|
|
final mount = width < 600 ? 'bottom bar' : 'wide bar';
|
|
|
|
testWidgets('Material $mount shows the count on the Runs tab', (
|
|
tester,
|
|
) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, cupertino: false, count: 3);
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
expect(find.byType(NavigationRail), findsNothing);
|
|
final badge = find.byType(Badge);
|
|
expect(badge, findsOneWidget);
|
|
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
|
|
expect(
|
|
find.descendant(of: badge, matching: find.text('3')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
|
semantics.dispose();
|
|
});
|
|
|
|
testWidgets('Material $mount hides the badge at zero', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, cupertino: false, count: 0);
|
|
final badge = find.byType(Badge);
|
|
expect(badge, findsOneWidget);
|
|
expect(tester.widget<Badge>(badge).isLabelVisible, isFalse);
|
|
expect(
|
|
find.descendant(
|
|
of: badge,
|
|
matching: find.textContaining(RegExp(r'\d')),
|
|
),
|
|
findsNothing,
|
|
);
|
|
expect(find.bySemanticsLabel(anyAttention), findsNothing);
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
|
|
for (final width in [390.0, 1280.0]) {
|
|
final mount = width < 600 ? 'tab bar' : 'wide tab bar';
|
|
|
|
testWidgets('Cupertino $mount shows the count on the Runs item', (
|
|
tester,
|
|
) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, cupertino: true, count: 3);
|
|
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
|
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
|
|
expect(find.text('3'), findsOneWidget);
|
|
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
|
semantics.dispose();
|
|
});
|
|
|
|
testWidgets('Cupertino $mount hides the count at zero', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, cupertino: true, count: 0);
|
|
expect(find.text('0'), findsNothing);
|
|
expect(find.bySemanticsLabel(anyAttention), findsNothing);
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
|
|
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);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.descendant(of: find.byType(Badge), matching: find.text('2')),
|
|
findsOneWidget,
|
|
reason: 'badge missing on $label',
|
|
);
|
|
}
|
|
});
|
|
}
|