edb558560f
Group each Settings section under one compact title, tighten the page to the web's 8/16 spacing and 20/16/32 page insets, and make field labels secondary so only the section title carries emphasis. Drop the duplicate Notifications heading now that the permission tile draws its own title. Adds a rendered-geometry regression for the centred 720px column, the title and section gaps, the secondary label role on both platforms, and the single Notifications heading.
100 lines
3.5 KiB
Dart
100 lines
3.5 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/core/transport/pipelines_client.dart'
|
|
as transport;
|
|
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
|
|
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
|
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 'fake_channel.dart';
|
|
|
|
void main() {
|
|
testWidgets('sections use one centred column and the web rhythm', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester);
|
|
|
|
final connection = tester.getRect(find.text('Connection'));
|
|
final serverUrlLabel = tester.getRect(find.text('Server URL'));
|
|
final warning = tester.getRect(find.byType(SettingsTrustWarning));
|
|
final workspace = tester.getRect(find.text('Workspace'));
|
|
|
|
// One column: the 720px reading width is centred in an 800px window.
|
|
expect(connection.left, closeTo(40, 0.01));
|
|
expect(connection.right, closeTo(760, 0.01));
|
|
|
|
// The compact title sits 8px above its grouped body, and sections are 16px
|
|
// apart, as on the web Settings page.
|
|
expect(
|
|
serverUrlLabel.top - connection.bottom,
|
|
closeTo(settingsTitleGap, 0.01),
|
|
);
|
|
expect(workspace.top - warning.bottom, closeTo(settingsSectionGap, 0.01));
|
|
|
|
// The field label is a compact secondary line, not a second title.
|
|
final label = tester.widget<Text>(find.text('Server URL'));
|
|
final theme = Theme.of(tester.element(find.text('Server URL')));
|
|
expect(label.style?.color, theme.colorScheme.onSurfaceVariant);
|
|
expect(label.style?.fontSize, theme.textTheme.labelMedium?.fontSize);
|
|
expect(
|
|
label.style?.fontSize,
|
|
lessThan(theme.textTheme.titleMedium!.fontSize!),
|
|
);
|
|
});
|
|
|
|
testWidgets('the notification tile is the section\'s only title', (
|
|
tester,
|
|
) async {
|
|
final notifications = NotificationController(
|
|
store: MemoryNotificationStore(),
|
|
);
|
|
addTearDown(notifications.dispose);
|
|
await _pump(tester, notifications: notifications);
|
|
|
|
expect(find.text('Notifications'), findsOneWidget);
|
|
expect(find.text('Connection'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Cupertino keeps the compact secondary field label', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester, platform: TargetPlatform.iOS);
|
|
|
|
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),
|
|
);
|
|
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
|
});
|
|
}
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester, {
|
|
TargetPlatform platform = TargetPlatform.android,
|
|
NotificationController? notifications,
|
|
}) async {
|
|
await tester.binding.setSurfaceSize(const Size(800, 1600));
|
|
addTearDown(() => tester.binding.setSurfaceSize(null));
|
|
final factory = FakeChannelFactory();
|
|
final client = transport.PipelinesClient(channelFactory: factory.call);
|
|
addTearDown(client.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: ThemeData(platform: platform),
|
|
home: SettingsScreen(
|
|
client: client,
|
|
store: MemorySettingsStore(),
|
|
notifications: notifications,
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
}
|