547d15c842
Replace wide-layout floating destination controls with a full-height Material navigation rail, keeping badges and existing navigation behavior. Pin Settings to the rail and preserve the phone layout and pane/window clearance.
86 lines
2.9 KiB
Dart
86 lines
2.9 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/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
/// The Runs tab keeps running work visible without an error counter.
|
|
void main() {
|
|
final needingAttention = RegExp('3 runs in progress');
|
|
final anyAttention = RegExp('runs in progress');
|
|
|
|
Future<void> pumpShell(
|
|
WidgetTester tester, {
|
|
required double width,
|
|
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(runningRunCount: count, attentionCount: 99);
|
|
await tester.pumpWidget(MaterialApp(home: shell));
|
|
}
|
|
|
|
for (final width in [390.0, 1000.0]) {
|
|
final mount = width < 600 ? 'bottom bar' : 'rail';
|
|
// The rail (wide) or the floating bar (phone) carries the same counts.
|
|
final navigation = width < 600
|
|
? find.byType(FloatingDestinationBar)
|
|
: find.byType(NavigationRail);
|
|
|
|
testWidgets('$mount shows the count on the Runs tab', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, count: 3);
|
|
expect(navigation, findsOneWidget);
|
|
final badge = find.byKey(const ValueKey('shell.badge.runs.running'));
|
|
expect(badge, findsOneWidget);
|
|
expect(
|
|
find.byKey(const ValueKey('shell.badge.runs.failed')),
|
|
findsNothing,
|
|
);
|
|
expect(
|
|
find.descendant(of: badge, matching: find.text('3')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
|
semantics.dispose();
|
|
});
|
|
|
|
testWidgets('$mount hides the badge at zero', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
await pumpShell(tester, width: width, count: 0);
|
|
final badge = find.byKey(const ValueKey('shell.badge.runs.running'));
|
|
expect(badge, findsOneWidget);
|
|
expect(
|
|
find.byKey(const ValueKey('shell.badge.runs.failed')),
|
|
findsNothing,
|
|
);
|
|
expect(
|
|
find.descendant(
|
|
of: badge,
|
|
matching: find.textContaining(RegExp(r'\d')),
|
|
),
|
|
findsNothing,
|
|
);
|
|
expect(find.bySemanticsLabel(anyAttention), findsNothing);
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
|
|
testWidgets('the badge stays visible from every destination', (tester) async {
|
|
await pumpShell(tester, width: 1000, count: 2);
|
|
for (final name in ['runs', 'chat', 'search']) {
|
|
await tester.tap(find.byKey(ValueKey('shell.destination.$name')));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.descendant(
|
|
of: find.byKey(const ValueKey('shell.badge.runs.running')),
|
|
matching: find.text('2'),
|
|
),
|
|
findsOneWidget,
|
|
reason: 'badge missing on $name',
|
|
);
|
|
}
|
|
});
|
|
}
|