62 lines
2.2 KiB
Dart
62 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/settings/quick_switch_preview.dart';
|
|
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
|
import 'package:pipelines_app/ui/motion/quick_switch_animation.dart';
|
|
|
|
Widget _host(QuickSwitchAnimation style, {bool reduced = false}) => MaterialApp(
|
|
home: Scaffold(
|
|
body: MediaQuery(
|
|
data: MediaQueryData(disableAnimations: reduced),
|
|
child: SingleChildScrollView(child: QuickSwitchPreview(animation: style)),
|
|
),
|
|
),
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('preview replays the real local workspace with chosen style', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(_host(QuickSwitchAnimation.cardStack));
|
|
await tester.pumpAndSettle();
|
|
final workspace = tester.widget<ChatWorkspace>(find.byType(ChatWorkspace));
|
|
expect(workspace.animationStyle, QuickSwitchAnimation.cardStack);
|
|
expect(workspace.controller.paneCount, 2);
|
|
final active = workspace.controller.activePaneId;
|
|
await tester.tap(find.text('Replay animation'));
|
|
await tester.pumpAndSettle();
|
|
expect(workspace.controller.activePaneId, isNot(active));
|
|
expect(tester.binding.transientCallbackCount, 0);
|
|
await tester.pumpWidget(_host(QuickSwitchAnimation.arcSwap));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller,
|
|
same(workspace.controller),
|
|
);
|
|
expect(
|
|
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).animationStyle,
|
|
QuickSwitchAnimation.arcSwap,
|
|
);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('reduced-motion preview remains still and disables replay', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
_host(QuickSwitchAnimation.cardStack, reduced: true),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.text('Reduced motion is enabled. Preview stays still.'),
|
|
findsOneWidget,
|
|
);
|
|
final button = tester.widget<TextButton>(
|
|
find.widgetWithText(TextButton, 'Replay animation'),
|
|
);
|
|
expect(button.onPressed, isNull);
|
|
expect(tester.binding.transientCallbackCount, 0);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|