Animate retained mobile chat reopening without remounting panes

This commit is contained in:
2026-11-08 00:22:51 +00:00
parent 1a674297c1
commit d189f61eee
6 changed files with 240 additions and 4 deletions
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_entrance.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets('retained entrance moves the same child ($cupertino)', (
tester,
) async {
tester.platformDispatcher.accessibilityFeaturesTestValue =
const FakeAccessibilityFeatures(disableAnimations: false);
addTearDown(
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
);
final childKey = GlobalKey();
final child = TextField(key: childKey);
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
child: SizedBox.expand(
child: ChatWorkspaceEntrance(
visible: visible,
cupertino: cupertino,
child: Material(child: child),
),
),
),
);
await tester.pumpWidget(host(false));
final element = childKey.currentContext;
final state = childKey.currentState;
expect(find.byKey(childKey), findsNothing);
await tester.pumpWidget(host(true));
final start = tester.getTopLeft(find.byKey(childKey));
await tester.pump();
await tester.pump(const Duration(milliseconds: 80));
final middle = tester.getTopLeft(find.byKey(childKey));
await tester.pumpAndSettle();
final end = tester.getTopLeft(find.byKey(childKey));
expect(cupertino ? middle.dx : middle.dy, greaterThan(0));
expect(
cupertino ? middle.dx : middle.dy,
lessThan(cupertino ? start.dx : start.dy),
);
expect(end, Offset.zero);
expect(childKey.currentContext, same(element));
expect(childKey.currentState, same(state));
await tester.enterText(find.byType(TextField), 'Retained draft');
await tester.pumpWidget(host(false));
await tester.pumpAndSettle();
await tester.pumpWidget(host(true, reduced: true));
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
expect(find.text('Retained draft'), findsOneWidget);
expect(childKey.currentState, same(state));
expect(tester.takeException(), isNull);
});
}
}