Redesign Settings as grouped searchable page

Replace the tabbed Settings flow with a single grouped page that searches and lazily loads server-backed sections. Preserve existing settings behavior while adding inline loading and retry states and updating coverage for the new navigation model.
This commit is contained in:
2026-11-12 02:54:07 +00:00
parent 9bb87e5118
commit 3136e5bb7e
29 changed files with 1467 additions and 777 deletions
@@ -9,7 +9,7 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/features/settings/settings_store.dart';
import 'fake_channel.dart';
import 'settings_topic_test_helper.dart';
import 'settings_section_test_helper.dart';
void main() {
testWidgets('renders idle settings without opening a connection', (
@@ -34,7 +34,7 @@ void main() {
expect(find.text('Not connected'), findsOneWidget);
expect(find.text('Saved workspace: /srv/pipelines'), findsOneWidget);
expect(
tester.widget<TextField>(find.byType(TextField).first).controller?.text,
tester.widget<TextField>(serverUrlField).controller?.text,
'ws://saved.test/connect',
);
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
@@ -65,7 +65,7 @@ void main() {
),
);
final field = tester.widget<TextField>(find.byType(TextField).first);
final field = tester.widget<TextField>(serverUrlField);
expect(field.maxLines, 2);
expect(field.controller?.text, contains('/connect'));
expect(tester.takeException(), isNull);
@@ -82,15 +82,14 @@ void main() {
store: MemorySettingsStore(serverUrl: 'ws://127.0.0.1:8080/connect'),
);
final fields = find.byType(TextField);
final url = tester.widget<TextField>(fields.first);
final url = tester.widget<TextField>(serverUrlField);
expect(url.minLines, 1);
// The URL field grows only when its text wraps: one line is the same
// height as the single-line workspace field below it.
Size editable(Finder field) => tester.getSize(
find.descendant(of: field, matching: find.byType(EditableText)),
);
expect(editable(fields.first).height, editable(fields.last).height);
expect(editable(serverUrlField).height, editable(workspaceField).height);
});
testWidgets('an invalid URL shows the field error and opens no socket', (
@@ -101,7 +100,7 @@ void main() {
addTearDown(client.dispose);
await _pump(tester, client);
await tester.enterText(find.byType(TextField).first, 'http://example.test');
await tester.enterText(serverUrlField, 'http://example.test');
await tester.pump();
await tester.tap(find.byKey(SettingsKeys.connect));
await tester.pump();
@@ -119,10 +118,7 @@ void main() {
addTearDown(client.dispose);
await _pump(tester, client);
await tester.enterText(
find.byType(TextField).first,
'ws://example.test:8123',
);
await tester.enterText(serverUrlField, 'ws://example.test:8123');
await tester.pump();
await tester.tap(find.byKey(SettingsKeys.connect));
await tester.pump();
@@ -162,9 +158,13 @@ void main() {
findsOneWidget,
);
expect(find.text('Connect'), findsNothing);
// Notification settings are loaded only when their topic is opened.
expect(factory.last.decodedOutgoing, hasLength(1));
await selectSettingsTopic(tester, 'Notifications');
// Notification settings load once their lazy section is near the list:
// this tall window reaches it on open, after the single ping.
expect(factory.last.decodedOutgoing.map((message) => message['type']), [
'ping',
'notification_settings',
]);
await openSettingsSection(tester, 'Phone notifications');
_answerNtfySettings(factory.last);
await tester.pump();
await tester.pump();
@@ -179,10 +179,7 @@ void main() {
addTearDown(client.dispose);
await _pump(tester, client);
await tester.enterText(
find.byType(TextField).first,
'ws://example.test:8123',
);
await tester.enterText(serverUrlField, 'ws://example.test:8123');
await tester.pump();
await tester.tap(find.byKey(SettingsKeys.connect));
await tester.pump();
@@ -206,7 +203,7 @@ void main() {
expect(find.text(serverDetailsPending), findsNothing);
expect(find.text('Server build unavailable'), findsOneWidget);
expect(find.text('Server time unavailable'), findsOneWidget);
await selectSettingsTopic(tester, 'Notifications');
await openSettingsSection(tester, 'Phone notifications');
_answerNtfySettings(factory.last);
await tester.pump();
});
@@ -220,7 +217,7 @@ void main() {
final store = MemorySettingsStore();
await _pump(tester, client, store: store);
final workspace = find.byType(TextField).at(1);
final workspace = workspaceField;
await tester.enterText(workspace, 'relative/path');
await tester.pump();
@@ -270,7 +267,7 @@ void main() {
200,
scrollable: find
.descendant(
of: find.byKey(const ValueKey('settings-topic-connection')),
of: find.byKey(const ValueKey<String>('settings.scroll')),
matching: find.byType(Scrollable),
)
.first,
@@ -318,20 +315,88 @@ void main() {
await _pump(tester, client);
final labels = <String>[
tester
.getSemantics(find.byType(TextField).at(0))
.getSemanticsData()
.label,
tester
.getSemantics(find.byType(TextField).at(1))
.getSemanticsData()
.label,
tester.getSemantics(serverUrlField).getSemanticsData().label,
tester.getSemantics(workspaceField).getSemanticsData().label,
];
expect(labels[0], contains('Server URL'));
expect(labels[1], contains('Workspace path (on the server)'));
handle.dispose();
});
testWidgets('Help and about keeps the keyboard shortcuts row', (
tester,
) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await _pump(tester, client);
await openSettingsSection(tester, 'Help and about');
expect(find.text('Help and about'), findsOneWidget);
expect(find.byKey(SettingsKeys.keyboardShortcuts), findsOneWidget);
// Help is a plain section of the page, so the search reaches it too.
await tester.enterText(
find.byKey(const ValueKey<String>('settings.search')),
'shortcuts',
);
await tester.pump();
expect(find.byKey(SettingsKeys.keyboardShortcuts), findsOneWidget);
expect(find.text('Server URL'), findsNothing);
});
testWidgets('Help and about has a Show the walkthrough row', (tester) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
var shown = 0;
await _pump(tester, client, onShowWalkthrough: () => shown++);
await openSettingsSection(tester, 'Help and about');
final row = find.byKey(SettingsKeys.showWalkthrough);
expect(find.text('Show the walkthrough'), findsOneWidget);
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.enabled,
isTrue,
);
await tester.tap(row);
await tester.pump();
expect(shown, 1);
// The search reaches the row as well.
await tester.enterText(
find.byKey(const ValueKey<String>('settings.search')),
'walkthrough',
);
await tester.pump();
expect(find.byKey(SettingsKeys.showWalkthrough), findsOneWidget);
});
testWidgets('Show the walkthrough row is disabled without a handler', (
tester,
) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await _pump(tester, client);
await openSettingsSection(tester, 'Help and about');
final row = find.byKey(SettingsKeys.showWalkthrough);
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.enabled,
isFalse,
);
});
testWidgets('unmounting leaves the shared client usable', (tester) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
@@ -350,6 +415,17 @@ void main() {
});
}
/// The Server URL and Workspace fields, addressed by their keys: the search
/// field is the page's first text field.
Finder get serverUrlField => find.descendant(
of: find.byKey(SettingsKeys.serverUrl),
matching: find.byType(TextField),
);
Finder get workspaceField => find.descendant(
of: find.byKey(SettingsKeys.workspace),
matching: find.byType(TextField),
);
Future<void> _pump(
WidgetTester tester,
transport.PipelinesClient client, {
@@ -357,6 +433,7 @@ Future<void> _pump(
TargetPlatform platform = TargetPlatform.android,
double textScale = 1,
Size size = const Size(800, 1200),
VoidCallback? onShowWalkthrough,
}) async {
await tester.binding.setSurfaceSize(size);
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -372,12 +449,13 @@ Future<void> _pump(
home: SettingsScreen(
client: client,
store: store ?? MemorySettingsStore(),
onShowWalkthrough: onShowWalkthrough,
),
),
);
await tester.pump();
await tester.pump();
await selectSettingsTopic(tester, 'Connection');
await openSettingsSection(tester, 'Connection');
}
/// Answers the Settings screen's queued ntfy-settings load on [channel].