merge(app): land settings layout rhythm
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user