mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
## 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>
51 lines
1.6 KiB
Dart
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);
|
|
});
|
|
}
|