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.
97 lines
3.4 KiB
Dart
97 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:pipelines_app/application/app_route.dart';
|
|
import 'package:pipelines_app/application/app_router.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/chat/screen.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
|
|
|
import '../features/chat/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': 's', 'title': 'Beside the list'},
|
|
],
|
|
});
|
|
}
|
|
if (type == 'chat_shells') return Future.value({'chat_shells': []});
|
|
return super.call(type, fields);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('an open chat beside the list leaves Back to the platform', (
|
|
tester,
|
|
) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
tester.view.physicalSize = const Size(1000, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final exits = <String>[];
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
SystemChannels.platform,
|
|
(call) async {
|
|
if (call.method == 'SystemNavigator.pop') exits.add(call.method);
|
|
return null;
|
|
},
|
|
);
|
|
addTearDown(
|
|
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
SystemChannels.platform,
|
|
null,
|
|
),
|
|
);
|
|
final gateway = _Gateway()..history = (_) async => chatPage(const []);
|
|
addTearDown(gateway.close);
|
|
late final AppRouterDelegate router;
|
|
router = AppRouterDelegate(
|
|
initial: AppRoute.chat,
|
|
builder: (_, route) => AdaptiveShell(
|
|
destination: AppDestination.chat,
|
|
destinationBodies: {
|
|
AppDestination.chat: (_) => ChatScreen(
|
|
gateway: gateway,
|
|
initialSessionId: route.chatSessionId,
|
|
onSessionSelected: (id) => router.goTo(AppRoute.chatSession(id)),
|
|
onBack: () => router.goTo(AppRoute.chat),
|
|
),
|
|
},
|
|
),
|
|
);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/chat')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp.router(
|
|
theme: appLightTheme(),
|
|
routerDelegate: router,
|
|
routeInformationParser: const AppRouteParser(),
|
|
routeInformationProvider: provider,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Beside the list'));
|
|
await tester.pumpAndSettle();
|
|
expect(router.route, AppRoute.chatSession('s'));
|
|
expect(find.byKey(const ValueKey('chat-thread-s')), findsOneWidget);
|
|
|
|
// No page covers the shell and the app adds no Back behavior: the
|
|
// platform's own Back applies at once, with no exit prompt.
|
|
await tester.binding.handlePopRoute();
|
|
await tester.pump();
|
|
expect(find.text('Press back again to close'), findsNothing);
|
|
expect(exits, ['SystemNavigator.pop']);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
router.dispose();
|
|
});
|
|
}
|