Remove Cupertino branches from Settings
Keep the Material-only settings implementation and its focused tests while preserving public cupertino parameters for later cleanup. This removes unreachable platform-specific widgets and test variants without changing the Material path.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||
@@ -15,7 +14,6 @@ import 'package:pipelines_app/features/settings/settings_layout.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
@@ -94,29 +92,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
|
||||
expect(find.byType(Card), findsNothing);
|
||||
expect(find.byType(CupertinoListSection), findsWidgets);
|
||||
for (final section in tester.widgetList<CupertinoListSection>(
|
||||
find.byType(CupertinoListSection),
|
||||
)) {
|
||||
expect(section.type, CupertinoListSectionType.insetGrouped);
|
||||
}
|
||||
final context = tester.element(find.byType(SettingsGroup).first);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is ColoredBox &&
|
||||
widget.color == AppColors.groupedBackground.resolveFrom(context),
|
||||
),
|
||||
findsWidgets,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('the notification tile is the section\'s only title', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -131,77 +106,54 @@ void main() {
|
||||
expect(find.text('Connection').last, findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino keeps the compact secondary field label', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
|
||||
final label = tester.widget<Text>(find.text('Server URL'));
|
||||
final context = tester.element(find.text('Server URL'));
|
||||
expect(
|
||||
label.style?.color,
|
||||
CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
testWidgets('server rows show which server is selected', (tester) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'Home',
|
||||
name: 'Home',
|
||||
endpoints: const ['wss://home.test/connect'],
|
||||
),
|
||||
SavedServer.validated(
|
||||
id: 'Work',
|
||||
name: 'Work',
|
||||
endpoints: const ['wss://work.test/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'Home',
|
||||
),
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
|
||||
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||
expect(find.text('Pipelines and runs server'), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Address: wss://work.test/connect'), findsOneWidget);
|
||||
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
|
||||
expect(find.text('Add server'), findsOneWidget);
|
||||
// Tapping another server's row uses it.
|
||||
await tester.tap(find.text('Work'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.id, 'Work');
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('server rows show which server is selected ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'Home',
|
||||
name: 'Home',
|
||||
endpoints: const ['wss://home.test/connect'],
|
||||
),
|
||||
SavedServer.validated(
|
||||
id: 'Work',
|
||||
name: 'Work',
|
||||
endpoints: const ['wss://work.test/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'Home',
|
||||
),
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
|
||||
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||
expect(find.text('Pipelines and runs server'), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Address: wss://work.test/connect'), findsOneWidget);
|
||||
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
|
||||
expect(find.text('Add server'), findsOneWidget);
|
||||
// Tapping another server's row uses it.
|
||||
await tester.tap(find.text('Work'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.id, 'Work');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pump(
|
||||
WidgetTester tester, {
|
||||
bool cupertino = false,
|
||||
NotificationController? notifications,
|
||||
Size size = const Size(800, 1600),
|
||||
double topPadding = 0,
|
||||
@@ -224,15 +176,10 @@ Future<void> _pump(
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: padded,
|
||||
home: CupertinoPageScaffold(child: screen),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: padded,
|
||||
home: Scaffold(body: screen),
|
||||
),
|
||||
MaterialApp(
|
||||
builder: padded,
|
||||
home: Scaffold(body: screen),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
Reference in New Issue
Block a user