Commit a00d8cd

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-02-03 11:41:54
test editing add intake dosis
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent dc3bfd9
Changed files (1)
test/ui/components/add_measurement_dialoge_test.dart
@@ -481,7 +481,6 @@ void main() {
       expect(find.descendant(of: fourthFocusedTextFormField, matching: find.text('Systolic')), findsWidgets);
     });
     testWidgets('should allow entering custom dosis', (widgetTester) async {
-      // TODO: add test for saving edited custom dosis
       dynamic result;
       await loadDialoge(widgetTester, (context) async =>
         result = await showAddEntryDialoge(context, Settings(
@@ -517,5 +516,46 @@ void main() {
           .having((p0) => p0.dosis, 'dosis', 654.321),
       );
     });
+    testWidgets('should allow modifying entered dosis', (widgetTester) async {
+      dynamic result;
+      await loadDialoge(widgetTester, (context) async =>
+        result = await showAddEntryDialoge(context, Settings(
+          medications: [mockMedicine(designation: 'testmed')],
+        ),),
+      );
+      final localizations = await AppLocalizations.delegate.load(const Locale('en'));
+
+      await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
+      await widgetTester.pumpAndSettle();
+
+      await widgetTester.tap(find.text('testmed'));
+      await widgetTester.pumpAndSettle();
+
+      await widgetTester.enterText(
+        find.ancestor(
+          of: find.text(localizations.dosis).first,
+          matching: find.byType(TextFormField),
+        ),
+        '654.321',
+      );
+      await widgetTester.pumpAndSettle();
+      await widgetTester.enterText(
+        find.ancestor(
+          of: find.text(localizations.dosis).first,
+          matching: find.byType(TextFormField),
+        ),
+        '654.322',
+      );
+      await widgetTester.pumpAndSettle();
+
+      await widgetTester.tap(find.text(localizations.btnSave));
+      await widgetTester.pumpAndSettle();
+
+      expect(result, isNotNull);
+      expect(result?.$1, isNull);
+      expect(result?.$2, isA<MedicineIntake>()
+          .having((p0) => p0.dosis, 'dosis', 654.322),
+      );
+    });
   });
 }