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.
95 lines
2.8 KiB
Dart
95 lines
2.8 KiB
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 'package:pipelines_app/features/chat/ui/sessions/chat_session_local.dart';
|
|
|
|
import 'fake_chat_gateway.dart';
|
|
|
|
/// In-memory device-local store; widget tests never read real preferences.
|
|
class MemoryChatSessionLocalStore implements ChatSessionLocalStore {
|
|
MemoryChatSessionLocalStore([this.state]);
|
|
|
|
ChatSessionLocal? state;
|
|
|
|
@override
|
|
Future<ChatSessionLocal> load() async => state ?? const ChatSessionLocal();
|
|
|
|
@override
|
|
Future<void> save(ChatSessionLocal next) async => state = next;
|
|
}
|
|
|
|
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 ?? (_) {},
|
|
localStore: MemoryChatSessionLocalStore(),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
/// The screen's iOS/macOS path uses the same ordinary Material app root.
|
|
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 ?? (_) {},
|
|
localStore: MemoryChatSessionLocalStore(),
|
|
),
|
|
),
|
|
);
|
|
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);
|
|
}
|
|
|
|
/// The project's smallest supported acceptance size with 2x text.
|
|
void useSmallTextSurface(WidgetTester tester) {
|
|
tester.view.physicalSize = const Size(320, 640);
|
|
tester.view.devicePixelRatio = 1;
|
|
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
|
}
|