Preview quick switch styles with the real local workspace
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
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.swap));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller,
|
||||
same(workspace.controller),
|
||||
);
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).animationStyle,
|
||||
QuickSwitchAnimation.swap,
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user