Commit 5683d75
Changed files (2)
app
lib
features
input
forms
test
features
input
app/lib/features/input/forms/add_entry_form.dart
@@ -68,7 +68,7 @@ class AddEntryFormState extends FormStateBase<AddEntryFormValue, AddEntryForm> {
if (widget.initialValue!.record == null
&& widget.initialValue!.intake == null
&& widget.initialValue!.weight != null) {
- _controller.animateTo(2);
+ _controller.animateTo(widget.meds.isEmpty ? 1 : 2);
} else if (widget.initialValue!.record == null
&& widget.initialValue!.intake != null) {
_controller.animateTo(1);
app/test/features/input/forms/add_entry_form_test.dart
@@ -417,6 +417,25 @@ void main() {
matching: find.text(localizations.sysLong)
), findsOneWidget);
});
+
+ testWidgets('opens correct tab on edit', (tester) async {
+ final key = GlobalKey<AddEntryFormState>();
+ await tester.pumpWidget(materialApp(AddEntryForm(key: key,
+ initialValue: (
+ timestamp: DateTime.now(),
+ weight: BodyweightRecord(time: DateTime.now(), weight: Weight.kg(123.0)),
+ record: null,
+ note: null,
+ intake: null,
+ ),
+ ),
+ settings: Settings(weightInput: true),
+ ));
+ await tester.pumpAndSettle();
+
+ expect(find.byType(BloodPressureForm), findsNothing);
+ expect(find.byType(WeightForm), findsOneWidget);
+ });
}
class _MockBluetoothCubit extends Fake implements BluetoothCubit {