9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
192 lines
6.8 KiB
Dart
192 lines
6.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/chat/screen.dart';
|
|
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/motion/container_transform_flight.dart';
|
|
import 'package:pipelines_app/ui/motion/container_transform_route.dart';
|
|
import 'package:pipelines_app/ui/motion/container_transform_source.dart';
|
|
import 'package:pipelines_app/ui/motion/motion.dart';
|
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
|
|
|
import '../../native_back.dart';
|
|
import 'conversation/chat_thread_fixtures.dart';
|
|
|
|
class _Gateway extends FakeChatGateway {
|
|
@override
|
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
|
if (type == 'chat_sessions') {
|
|
return Future.value({
|
|
'chat_sessions': [
|
|
{'id': 'a', 'title': 'First chat', 'color': 'blue'},
|
|
{'id': 'b', 'title': 'Second chat'},
|
|
],
|
|
});
|
|
}
|
|
if (type == 'chat_shells') return Future.value({'chat_shells': []});
|
|
return super.call(type, fields);
|
|
}
|
|
}
|
|
|
|
Future<void> _pumpShell(WidgetTester tester, Size size) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final gateway = _Gateway()..history = (_) async => chatPage(const []);
|
|
addTearDown(gateway.close);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: appLightTheme(),
|
|
home: AdaptiveShell(
|
|
destination: AppDestination.chat,
|
|
destinationBodies: {
|
|
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Finder get _surface => find.byKey(containerTransformSurfaceKey);
|
|
|
|
void main() {
|
|
testWidgets('a phone grows the tapped row into the chat and back', (
|
|
tester,
|
|
) async {
|
|
// Chat tests run with reduced motion (flutter_test_config); this one
|
|
// covers the motion itself.
|
|
final reduced = tester.platformDispatcher.accessibilityFeatures;
|
|
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
|
const FakeAccessibilityFeatures();
|
|
addTearDown(
|
|
() => tester.platformDispatcher.accessibilityFeaturesTestValue = reduced,
|
|
);
|
|
await _pumpShell(tester, const Size(390, 844));
|
|
final row = tester.getRect(find.byKey(const Key('chat-row-a')));
|
|
expect(
|
|
find.byType(Hero),
|
|
findsNothing,
|
|
reason: 'the row is the shared element',
|
|
);
|
|
|
|
await tester.tap(find.text('First chat'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 120));
|
|
final navigator = tester.state<NavigatorState>(
|
|
find.byType(Navigator).first,
|
|
);
|
|
expect(navigator.canPop(), isTrue);
|
|
final mid = tester.getRect(_surface);
|
|
expect(mid.top, lessThan(row.top));
|
|
expect(mid.height, greaterThan(row.height));
|
|
expect(mid.height, lessThan(844));
|
|
|
|
await tester.pumpAndSettle();
|
|
expect(tester.getRect(_surface), const Rect.fromLTWH(0, 0, 390, 844));
|
|
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
|
expect(find.byType(Hero), findsNothing);
|
|
|
|
await tester.tap(findNativeBack());
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
final closing = tester.getRect(_surface);
|
|
expect(closing.height, lessThan(844));
|
|
expect(closing.height, greaterThan(row.height));
|
|
|
|
await tester.pumpAndSettle();
|
|
expect(navigator.canPop(), isFalse);
|
|
expect(_surface, findsNothing);
|
|
expect(tester.getRect(find.byKey(const Key('chat-row-a'))), row);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
});
|
|
|
|
testWidgets('a phone under reduced motion fades the chat in place', (
|
|
tester,
|
|
) async {
|
|
await _pumpShell(tester, const Size(390, 844));
|
|
await tester.tap(find.text('First chat'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 1));
|
|
expect(tester.getRect(_surface), const Rect.fromLTWH(0, 0, 390, 844));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
|
await tester.tap(findNativeBack());
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 1));
|
|
expect(tester.getRect(_surface), const Rect.fromLTWH(0, 0, 390, 844));
|
|
await tester.pumpAndSettle();
|
|
expect(_surface, findsNothing);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
});
|
|
|
|
testWidgets('a wide window opens the chat beside the list, untransformed', (
|
|
tester,
|
|
) async {
|
|
await _pumpShell(tester, const Size(1280, 800));
|
|
await tester.tap(find.text('First chat'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 120));
|
|
expect(_surface, findsNothing);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
|
expect(_surface, findsNothing);
|
|
final navigator = tester.state<NavigatorState>(
|
|
find.byType(Navigator).first,
|
|
);
|
|
expect(navigator.canPop(), isFalse);
|
|
expect(
|
|
find.byWidgetPredicate((w) => w is ContainerTransformSource),
|
|
findsWidgets,
|
|
reason: 'rows still register, but nothing grows from them',
|
|
);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
});
|
|
|
|
testWidgets('a row offers its tinted surface and edge marker', (
|
|
tester,
|
|
) async {
|
|
final sources = ContainerTransformSources();
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: appLightTheme(),
|
|
home: Scaffold(
|
|
body: ContainerTransformScope(
|
|
sources: sources,
|
|
child: ChatSessionRow(
|
|
session: const {'id': 'x', 'title': 'Tinted', 'color': 'blue'},
|
|
visible: true,
|
|
selected: true,
|
|
onOpen: (_) {},
|
|
onAction: (_) {},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final origin = sources.originOf('x')!;
|
|
expect(origin.rect, tester.getRect(find.byKey(const Key('chat-row-x'))));
|
|
final background = appLightTheme().scaffoldBackgroundColor;
|
|
expect(origin.color, isNot(background), reason: 'the chat colour tints it');
|
|
expect(origin.color.a, 1);
|
|
expect(origin.markerWidth, 10);
|
|
expect(origin.marker, isNotNull);
|
|
});
|
|
|
|
test('the route reads its timing from Motion', () {
|
|
final route = ContainerTransformPageRoute<void>(
|
|
link: ContainerTransformLink(() => null),
|
|
builder: (_) => const SizedBox(),
|
|
);
|
|
expect(route.transitionDuration, Motion.containerTransform);
|
|
expect(route.reverseTransitionDuration, Motion.containerTransformReverse);
|
|
expect(route.opaque, isTrue);
|
|
});
|
|
}
|