Merge commit '2eeca633096f2fc59a2397b6208e3cb518828de5' into pipelines/run-20261112-1043-dim-inactive-chat-panes-a498

This commit is contained in:
2026-11-12 10:59:05 +00:00
22 changed files with 844 additions and 254 deletions
@@ -673,11 +673,18 @@ void main() {
});
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(find.byTooltip('2 tasks, 12 automations'), findsOneWidget);
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
final counter = find.byKey(const Key('chat-background-tasks-button'));
// One '2' is the count inside the ring, one is the compact caption.
expect(
tester
.widget<Text>(find.byKey(const Key('chat-background-tasks-count')))
.data,
'2',
);
expect(
find.descendant(of: counter, matching: find.text('2')),
findsOneWidget,
findsNWidgets(2),
);
expect(
find.descendant(of: counter, matching: find.text('12')),
@@ -6,19 +6,23 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_background_tasks.dart';
import 'package:pipelines_app/features/chat/conversation/chat_task_spinner.dart';
RotationTransition _rotation(WidgetTester tester) =>
tester.widget<RotationTransition>(
find.byKey(const Key('chat-background-tasks-spinner')),
final _spinnerFinder = find.byKey(const Key('chat-background-tasks-spinner'));
CircularProgressIndicator _ring(WidgetTester tester) =>
tester.widget<CircularProgressIndicator>(
find.descendant(
of: _spinnerFinder,
matching: find.byType(CircularProgressIndicator),
),
);
Widget _spinner(bool spinning) => MaterialApp(
home: Scaffold(
body: ChatTaskSpinner(
spinning: spinning,
child: const Icon(Icons.layers_outlined, size: 16),
),
),
);
Widget _spinner(int running, {Brightness brightness = Brightness.light}) =>
MaterialApp(
theme: ThemeData(colorSchemeSeed: Colors.indigo, brightness: brightness),
home: Scaffold(
body: Center(child: ChatTaskSpinner(running: running)),
),
);
void _reducedMotion(bool reduced) =>
TestWidgetsFlutterBinding.ensureInitialized()
@@ -51,58 +55,99 @@ class _TasksGateway implements ApiGateway {
void main() {
tearDown(() => _reducedMotion(false));
testWidgets('turns once every period while spinning', (tester) async {
testWidgets(
'a running task shows an indeterminate primary ring with the count',
(tester) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(2));
final ring = _ring(tester);
expect(ring.value, isNull);
expect(ring.strokeWidth, 2);
expect(
ring.color,
ThemeData(colorSchemeSeed: Colors.indigo).colorScheme.primary,
);
expect(
find.descendant(of: _spinnerFinder, matching: find.text('2')),
findsOneWidget,
);
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byIcon(Icons.layers_outlined),
),
findsNothing,
);
// The ring keeps turning: time advances the animation.
await tester.pump(const Duration(milliseconds: 300));
expect(tester.binding.transientCallbackCount, greaterThan(0));
await tester.pumpWidget(const SizedBox.shrink());
expect(tester.binding.transientCallbackCount, 0);
},
);
testWidgets('dark theme uses the dark primary for the ring', (tester) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(true));
expect(_rotation(tester).turns.value, 0);
await tester.pump(ChatTaskSpinner.period ~/ 4);
expect(_rotation(tester).turns.value, closeTo(0.25, 0.01));
// Past one full lap the turn starts again from the top.
await tester.pump(
ChatTaskSpinner.period ~/ 4 * 3 + const Duration(milliseconds: 100),
await tester.pumpWidget(_spinner(1, brightness: Brightness.dark));
expect(
_ring(tester).color,
ThemeData(
colorSchemeSeed: Colors.indigo,
brightness: Brightness.dark,
).colorScheme.primary,
);
expect(_rotation(tester).turns.value, closeTo(0.04, 0.01));
await tester.pumpWidget(const SizedBox.shrink());
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('stays still when not spinning, and stops when it stops', (
testWidgets('no running task shows the static icon with no ring', (
tester,
) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(false));
await tester.pump(const Duration(seconds: 2));
expect(_rotation(tester).turns.value, 0);
expect(tester.binding.transientCallbackCount, 0);
await tester.pumpWidget(_spinner(true));
await tester.pump(const Duration(milliseconds: 625));
expect(_rotation(tester).turns.value, greaterThan(0));
await tester.pumpWidget(_spinner(false));
await tester.pump();
expect(_rotation(tester).turns.value, 0);
await tester.pump(const Duration(seconds: 2));
expect(_rotation(tester).turns.value, 0);
await tester.pumpWidget(_spinner(0));
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byType(CircularProgressIndicator),
),
findsNothing,
);
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byIcon(Icons.layers_outlined),
),
findsOneWidget,
);
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('reduced motion keeps the icon static even while spinning', (
testWidgets('every state keeps the same square size', (tester) async {
_reducedMotion(false);
for (final running in [0, 1, 12]) {
await tester.pumpWidget(_spinner(running));
expect(tester.getSize(_spinnerFinder), const Size(16, 16));
}
});
testWidgets('reduced motion holds one static ring segment while running', (
tester,
) async {
_reducedMotion(true);
await tester.pumpWidget(_spinner(true));
await tester.pumpWidget(_spinner(3));
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
await tester.pump(const Duration(seconds: 1));
expect(_rotation(tester).turns.value, 0);
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('the tasks icon rotates only while a task runs', (tester) async {
testWidgets('the composer button shows the count ring and its tooltip', (
tester,
) async {
_reducedMotion(false);
final gateway = _TasksGateway();
addTearDown(gateway.close);
gateway.running = const [
{'id': 'sh1', 'status': 'running', 'command': 'go test ./...'},
{'id': 'sh2', 'status': 'running', 'command': 'make'},
];
await tester.pumpWidget(
MaterialApp(
@@ -111,12 +156,15 @@ void main() {
),
),
);
// The spinning icon repeats forever, so settle by pumping, never by waiting.
// The ring repeats forever, so settle by pumping, never by waiting.
await tester.pump();
await tester.pump();
expect(find.text('1 task'), findsOneWidget);
final before = _rotation(tester).turns.value;
await tester.pump(const Duration(milliseconds: 300));
expect(_rotation(tester).turns.value, greaterThan(before));
expect(find.text('2 tasks'), findsOneWidget);
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
expect(_ring(tester).value, isNull);
expect(
find.descendant(of: _spinnerFinder, matching: find.text('2')),
findsOneWidget,
);
});
}