Files
Garage-SDKs/garage_ui/test/properties_section_copy_test.dart
ImBenjiandClaude Opus 5.5 b269201919 The Garage SDKs, in the open
garage_auth, garage_entitlements, garage_iap and garage_ui, moved out of
Garage-Services and Metro-Map-Maker into one public repo. MIT, one readme,
docs under docs/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013F4NWNvYcdeSgqbWMT1VQ7
2026-09-23 18:49:21 +01:00

68 lines
2.2 KiB
Dart

import "package:flutter/widgets.dart";
import "package:flutter_test/flutter_test.dart";
import "package:garage_ui/garage_ui.dart";
import "support/test_scheme.dart";
// The section's own subtitle. Sits in the header under the title, and stays
// there while the section is collapsed - it names the section rather than
// being part of its body. Sections deliberately have no `description`; a box
// of copy above the rows competed with them, and a row's own description
// covers the case anyway.
Widget _host(Widget child) => Directionality(
textDirection: TextDirection.ltr,
child: GarageTheme(
data: ThemeData(colorScheme: testScheme, density: const Density()),
child: Center(child: SizedBox(width: 420, child: child)),
),
);
Widget _section({String? subtitle, bool collapsed = false}) =>
PropertiesSection(
title: "Profile",
subtitle: subtitle,
scheme: testScheme,
collapsed: collapsed,
onToggle: () {},
rows: [
PropertyRow(
label: "Username",
scheme: testScheme,
child: const TextField(),
),
],
);
void main() {
testWidgets("subtitle sits under the title, above the rows", (tester) async {
await tester.pumpWidget(_host(_section(subtitle: "a subtitle")));
final title = tester.getRect(find.text("Profile"));
final sub = tester.getRect(find.text("a subtitle"));
final row = tester.getRect(find.text("Username"));
expect(sub.top, greaterThanOrEqualTo(title.bottom));
expect(sub.left, title.left); // same column, clear of the chevron
expect(row.top, greaterThan(sub.bottom));
});
testWidgets("subtitle renders at textXxs", (tester) async {
await tester.pumpWidget(_host(_section(subtitle: "a subtitle")));
expect(
tester.widget<Text>(find.text("a subtitle")).style!.fontSize,
const Density().textXxs,
);
});
testWidgets("subtitle survives collapse", (tester) async {
await tester.pumpWidget(
_host(_section(subtitle: "a subtitle", collapsed: true)),
);
// it names the section, so it stays when the body goes
expect(find.text("a subtitle"), findsOneWidget);
expect(find.text("Username"), findsNothing);
});
}