c75023eb40
Keep the app's Material-only chat workspace path while retaining public cupertino parameters for callers. Narrow the affected widget tests to the supported Material host.
86 lines
3.0 KiB
Dart
86 lines
3.0 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/chat_sessions_screen.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/shell/shell_bar.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': 's1',
|
|
'title': 'Open conversation',
|
|
'updated_at': '2026-10-24T12:00:00Z',
|
|
},
|
|
{
|
|
'id': 's2',
|
|
'title': 'Other conversation',
|
|
'updated_at': '2026-10-24T12:00:00Z',
|
|
},
|
|
],
|
|
});
|
|
}
|
|
return super.call(type, fields);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'a pushed phone chat stays read and preserves underlying list chrome',
|
|
(tester) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
SharedPreferences.setMockInitialValues({});
|
|
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
|
addTearDown(gateway.close);
|
|
final bar = ShellBarRegistry();
|
|
addTearDown(bar.dispose);
|
|
final selected = ValueNotifier<String?>('s1');
|
|
addTearDown(selected.dispose);
|
|
final screen = ShellBarScope(
|
|
registry: bar,
|
|
destination: AppDestination.chat,
|
|
child: ValueListenableBuilder<String?>(
|
|
valueListenable: selected,
|
|
builder: (_, id, _) => ChatScreen(
|
|
gateway: gateway,
|
|
initialSessionId: id,
|
|
onBack: () => selected.value = null,
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
|
await tester.pumpAndSettle();
|
|
final list = tester.widget<ChatSessionsScreen>(
|
|
find.byType(ChatSessionsScreen, skipOffstage: false),
|
|
);
|
|
final controller = list.controller!;
|
|
expect(controller.activeSessionId, 's1');
|
|
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
|
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
|
await tester.pumpAndSettle();
|
|
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
|
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
controller.sessions.where(controller.isUnseen).map((row) => row['id']),
|
|
['s2'],
|
|
);
|
|
await tester.binding.handlePopRoute();
|
|
await tester.pumpAndSettle();
|
|
expect(controller.activeSessionId, isNull);
|
|
expect(find.text('Open conversation'), findsOneWidget);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
},
|
|
);
|
|
}
|