Narrow chat tests to Material hosts
Remove Cupertino-only fixtures, test variants, and the obsolete readable-text test now that the app is Material-only. Preserve the Material coverage while avoiding unreachable platform branches.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
@@ -64,11 +63,6 @@ Widget _host(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
Widget _cupertinoHost(Widget child) => CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
);
|
||||
|
||||
const _session = <String, dynamic>{
|
||||
'id': 's',
|
||||
'backend': 'opencode',
|
||||
@@ -82,7 +76,6 @@ JsonMap _withSession(Map<String, dynamic> changes) => {..._session, ...changes};
|
||||
Future<void> _openThread(
|
||||
WidgetTester tester,
|
||||
_ModelGateway gateway, {
|
||||
bool cupertino = false,
|
||||
JsonMap session = _session,
|
||||
ValueChanged<ChatModelSelection>? onChanged,
|
||||
}) async {
|
||||
@@ -93,7 +86,7 @@ Future<void> _openThread(
|
||||
onBack: () {},
|
||||
onModelChanged: onChanged,
|
||||
);
|
||||
await tester.pumpWidget(cupertino ? _cupertinoHost(thread) : _host(thread));
|
||||
await tester.pumpWidget(_host(thread));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -169,32 +162,28 @@ void main() {
|
||||
expect(find.text('model-b'), findsNothing);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('an accepted switch shows the server-reported model '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
final gateway = _ModelGateway()
|
||||
..modelsReply = _catalog
|
||||
..switchReply = const {
|
||||
'chat_model': {
|
||||
'session_id': 's',
|
||||
'provider': 'p2',
|
||||
'model': 'server-reported-model',
|
||||
'selection': 'next_turn',
|
||||
},
|
||||
};
|
||||
await _openThread(tester, gateway, cupertino: cupertino);
|
||||
testWidgets('an accepted switch shows the server-reported model ', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _ModelGateway()
|
||||
..modelsReply = _catalog
|
||||
..switchReply = const {
|
||||
'chat_model': {
|
||||
'session_id': 's',
|
||||
'provider': 'p2',
|
||||
'model': 'server-reported-model',
|
||||
'selection': 'next_turn',
|
||||
},
|
||||
};
|
||||
await _openThread(tester, gateway);
|
||||
|
||||
await _openChooser(tester);
|
||||
await tester.tap(find.text('Model Beta'));
|
||||
await tester.pumpAndSettle();
|
||||
await _openChooser(tester);
|
||||
await tester.tap(find.text('Model Beta'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('server-reported-model · next turn'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
if (cupertino) {
|
||||
expect(find.byType(Material), findsNothing);
|
||||
}
|
||||
});
|
||||
}
|
||||
expect(find.text('server-reported-model · next turn'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('lists only the server catalog and reports an empty one', (
|
||||
tester,
|
||||
@@ -306,39 +295,36 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('searches the catalog by name, id and provider '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
final gateway = _ModelGateway()..modelsReply = _catalog;
|
||||
await _openThread(tester, gateway, cupertino: cupertino);
|
||||
await _openChooser(tester);
|
||||
testWidgets('searches the catalog by name, id and provider ', (tester) async {
|
||||
final gateway = _ModelGateway()..modelsReply = _catalog;
|
||||
await _openThread(tester, gateway);
|
||||
await _openChooser(tester);
|
||||
|
||||
final search = find.byKey(const Key('chat-model-search'));
|
||||
expect(search, findsOneWidget);
|
||||
final search = find.byKey(const Key('chat-model-search'));
|
||||
expect(search, findsOneWidget);
|
||||
|
||||
await tester.enterText(search, 'beta');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Beta'), findsOneWidget);
|
||||
expect(find.text('Model Alpha'), findsNothing);
|
||||
await tester.enterText(search, 'beta');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Beta'), findsOneWidget);
|
||||
expect(find.text('Model Alpha'), findsNothing);
|
||||
|
||||
await tester.enterText(search, 'P1');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Alpha'), findsOneWidget);
|
||||
expect(find.text('Model Beta'), findsNothing);
|
||||
await tester.enterText(search, 'P1');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Alpha'), findsOneWidget);
|
||||
expect(find.text('Model Beta'), findsNothing);
|
||||
|
||||
await tester.enterText(search, 'zzz');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No models match "zzz".'), findsOneWidget);
|
||||
expect(find.text('Model Alpha'), findsNothing);
|
||||
expect(find.text('Model Beta'), findsNothing);
|
||||
await tester.enterText(search, 'zzz');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No models match "zzz".'), findsOneWidget);
|
||||
expect(find.text('Model Alpha'), findsNothing);
|
||||
expect(find.text('Model Beta'), findsNothing);
|
||||
|
||||
await tester.enterText(search, '');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Alpha'), findsOneWidget);
|
||||
expect(find.text('Model Beta'), findsOneWidget);
|
||||
expect(find.text('No models match "zzz".'), findsNothing);
|
||||
});
|
||||
}
|
||||
await tester.enterText(search, '');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Model Alpha'), findsOneWidget);
|
||||
expect(find.text('Model Beta'), findsOneWidget);
|
||||
expect(find.text('No models match "zzz".'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('marks the current row by id and provider when ids repeat', (
|
||||
tester,
|
||||
@@ -405,39 +391,36 @@ void main() {
|
||||
expect(find.text('model-a'), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('the chooser fits the smallest surface at 2x text '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
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);
|
||||
testWidgets('the chooser fits the smallest surface at 2x text ', (
|
||||
tester,
|
||||
) async {
|
||||
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);
|
||||
|
||||
final gateway = _ModelGateway()
|
||||
..modelsReply = {
|
||||
'chat_models': [
|
||||
for (var index = 1; index <= 6; index++)
|
||||
{
|
||||
'id': 'model-$index',
|
||||
'provider': 'provider-$index',
|
||||
'name': 'Model number $index with a longer name',
|
||||
},
|
||||
],
|
||||
};
|
||||
await _openThread(tester, gateway, cupertino: cupertino);
|
||||
await _openChooser(tester);
|
||||
final gateway = _ModelGateway()
|
||||
..modelsReply = {
|
||||
'chat_models': [
|
||||
for (var index = 1; index <= 6; index++)
|
||||
{
|
||||
'id': 'model-$index',
|
||||
'provider': 'provider-$index',
|
||||
'name': 'Model number $index with a longer name',
|
||||
},
|
||||
],
|
||||
};
|
||||
await _openThread(tester, gateway);
|
||||
await _openChooser(tester);
|
||||
|
||||
expect(find.byKey(const Key('chat-model-chooser')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-model-search')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
if (!cupertino) {
|
||||
// Every row is built inside the dialog's own scroll view.
|
||||
expect(find.textContaining('Model number 6'), findsOneWidget);
|
||||
}
|
||||
});
|
||||
}
|
||||
expect(find.byKey(const Key('chat-model-chooser')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-model-search')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
// Every row is built inside the dialog's own scroll view.
|
||||
expect(find.textContaining('Model number 6'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('an accepted switch applies after the chooser was dismissed', (
|
||||
tester,
|
||||
|
||||
Reference in New Issue
Block a user