Files
buzz/mobile/test/shared/widgets/buzz_loading_indicator_test.dart
klopez4212andGitHub a77212875a Unify mobile loading spinners (#3314)
## What
- add the shared desktop-style arc spinner for mobile
- replace app loading indicators with the shared component
- preserve a static pose when reduced motion is enabled

## Stack
- follows #3313

## Validation
- `just mobile-check`
- focused spinner and pairing widget tests

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
2026-07-28 19:12:54 +01:00

51 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:buzz/shared/theme/theme.dart';
import 'package:buzz/shared/widgets/buzz_loading_indicator.dart';
Widget _testable({required bool disableAnimations}) {
return ProviderScope(
child: MaterialApp(
theme: AppTheme.light(),
home: MediaQuery(
data: const MediaQueryData().copyWith(
disableAnimations: disableAnimations,
),
child: const Scaffold(
body: BuzzLoadingIndicator(semanticLabel: 'Loading photos'),
),
),
),
);
}
void main() {
testWidgets('animates the shared arc spinner', (tester) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(_testable(disableAnimations: false));
await tester.pump(const Duration(milliseconds: 70));
final spinner = tester.widget<RotationTransition>(
find.byKey(const ValueKey('buzz-loading-indicator-spinner')),
);
expect(spinner.turns.value, greaterThan(0));
expect(find.bySemanticsLabel('Loading photos'), findsOneWidget);
semantics.dispose();
});
testWidgets('holds a static pose when reduced motion is enabled', (
tester,
) async {
await tester.pumpWidget(_testable(disableAnimations: true));
await tester.pump(const Duration(milliseconds: 70));
final spinner = tester.widget<RotationTransition>(
find.byKey(const ValueKey('buzz-loading-indicator-spinner')),
);
expect(spinner.turns.value, 0);
expect(tester.binding.hasScheduledFrame, isFalse);
});
}