41d30a4280
Split the 406-line chat session browser into a controller, body, shared adaptive primitives and separate standard Material and Cupertino lists and dialogs. Preserve the existing server directory/backend catalogs, instructions field, closed/starred grouping, directory headings and empty/no-match states. - keep refresh generations so stale replies are discarded - open a created chat immediately and refresh the list in the background - disable rename Save while the trimmed name is blank - label row actions per session, with the id on duplicate titles - wrap Cupertino empty/no-match/error messages instead of clipping, and give them a Cupertino text style under a bare MaterialApp - allow the Material rename helper to wrap at large text scales - cover both native branches, lifecycle ordering, create/rename/close/star and the Cupertino theme path with widget tests
78 lines
2.2 KiB
Dart
78 lines
2.2 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
|
|
|
|
import 'fake_chat_gateway.dart';
|
|
|
|
List<JsonMap> sampleSessions() => [
|
|
{'id': 's1', 'title': 'Starred chat', 'directory': '/work', 'starred': true},
|
|
{'id': 's2', 'title': 'Open chat', 'directory': '/work'},
|
|
{'id': 's3', 'title': 'Elsewhere chat', 'directory': '/else'},
|
|
{
|
|
'id': 's4',
|
|
'title': 'Closed chat',
|
|
'directory': '/else',
|
|
'closed_at': '2026-01-01',
|
|
},
|
|
{
|
|
'id': 's5',
|
|
'title': 'Starred closed',
|
|
'directory': '/work',
|
|
'starred': true,
|
|
'closed_at': '2026-01-02',
|
|
},
|
|
];
|
|
|
|
Future<void> pumpMaterialChat(
|
|
WidgetTester tester,
|
|
FakeChatGateway gateway, {
|
|
ValueChanged<JsonMap>? onOpen,
|
|
}) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: ThemeData(platform: TargetPlatform.android),
|
|
home: ChatSessionsScreen(gateway: gateway, onOpen: onOpen ?? (_) {}),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<void> pumpCupertinoChat(
|
|
WidgetTester tester,
|
|
FakeChatGateway gateway, {
|
|
ValueChanged<JsonMap>? onOpen,
|
|
}) async {
|
|
await tester.pumpWidget(
|
|
CupertinoApp(
|
|
home: ChatSessionsScreen(gateway: gateway, onOpen: onOpen ?? (_) {}),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
/// The screen's iOS/macOS path: Cupertino controls under the app's ordinary
|
|
/// `MaterialApp` root, with no Material or CupertinoTheme ancestor.
|
|
Future<void> pumpIosMaterialChat(
|
|
WidgetTester tester,
|
|
FakeChatGateway gateway, {
|
|
ValueChanged<JsonMap>? onOpen,
|
|
}) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: ThemeData(platform: TargetPlatform.iOS),
|
|
home: ChatSessionsScreen(gateway: gateway, onOpen: onOpen ?? (_) {}),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
/// Narrows the test surface to a phone so long messages must wrap.
|
|
void usePhoneSurface(WidgetTester tester) {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
}
|