mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-20 20:52:23 +01:00
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation infos failed flutter analyze --fatal-infos, and four Dart pins were behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2, github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages now sit on material_ui, so the app has to as well or their widgets lose MaterialLocalizations. Imports swap one-for-one and dart fix re-sorted the directives; no behaviour change. analyze is clean and all six test shards pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
74 lines
2.5 KiB
Dart
74 lines
2.5 KiB
Dart
// The Body screen's two date controls apply what their picker confirms:
|
|
// the dated-value card's day, and the profile's birth date (whose picker
|
|
// opens with the year wheel focused).
|
|
|
|
import 'package:diet_guard_app/models/local_time.dart';
|
|
import 'package:diet_guard_app/widgets/body/dated_value_card.dart';
|
|
import 'package:diet_guard_app/widgets/body/profile_card.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import '../label_finders.dart';
|
|
import '../screens/body_screen_support.dart';
|
|
|
|
Future<void> _host(WidgetTester tester, Widget child) async {
|
|
tester.view.physicalSize = const Size(800, 1600);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: child)));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<void> _pressAndSettle(
|
|
WidgetTester tester,
|
|
LogicalKeyboardKey key,
|
|
) async {
|
|
await tester.sendKeyEvent(key);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('the dated-value card shows the confirmed day', (tester) async {
|
|
await _host(
|
|
tester,
|
|
DatedValueCard(
|
|
semanticLabel: 'Weight',
|
|
fieldSemanticLabel: 'Weight (kg)',
|
|
icon: Icons.monitor_weight,
|
|
unit: 'kg',
|
|
min: 20,
|
|
max: 400,
|
|
latest: null,
|
|
series: const [],
|
|
onSave: (_, _) async {},
|
|
onDelete: (_) async {},
|
|
onChanged: () {},
|
|
),
|
|
);
|
|
final now = DateTime.now();
|
|
final yesterday = localDateKey(DateTime(now.year, now.month, now.day - 1));
|
|
await tester.tap(find.byIcon(Icons.event));
|
|
await tester.pumpAndSettle();
|
|
await _pressAndSettle(tester, LogicalKeyboardKey.arrowLeft);
|
|
await _pressAndSettle(tester, LogicalKeyboardKey.enter);
|
|
expect(find.byType(Dialog), findsNothing);
|
|
expect(find.text(' $yesterday'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('the birth date opens on the year wheel and applies', (
|
|
tester,
|
|
) async {
|
|
await setUpBodyServices(MemoryDocStore());
|
|
addTearDown(tearDownBodyServices);
|
|
await _host(tester, ProfileCard(onSaved: () {}));
|
|
final year = DateTime.now().year - 31;
|
|
await tester.tap(byIconLabel('Birth date'));
|
|
await tester.pumpAndSettle();
|
|
await _pressAndSettle(tester, LogicalKeyboardKey.arrowUp);
|
|
await _pressAndSettle(tester, LogicalKeyboardKey.enter);
|
|
expect(find.byType(Dialog), findsNothing);
|
|
expect(find.text(' $year-01-01'), findsOneWidget);
|
|
});
|
|
}
|