@@ -23,6 +23,7 @@ import 'package:mockito/mockito.dart';
2323import 'package:provider/provider.dart' ;
2424import 'package:wger/helpers/consts.dart' ;
2525import 'package:wger/l10n/generated/app_localizations.dart' ;
26+ import 'package:wger/models/workouts/base_config.dart' ;
2627import 'package:wger/models/workouts/slot_entry.dart' ;
2728import 'package:wger/providers/routines.dart' ;
2829import 'package:wger/widgets/routines/forms/repetitions.dart' ;
@@ -47,7 +48,7 @@ void main() {
4748 when (mockRoutinesProvider.findRepetitionUnitById (any)).thenReturn (testRepetitionUnit1);
4849 });
4950
50- Widget renderWidget ({simpleMode = true , locale = 'en' }) {
51+ Widget renderWidget ({simpleMode = true , locale = 'en' , SlotEntry ? entry }) {
5152 final key = GlobalKey <NavigatorState >();
5253
5354 return ChangeNotifierProvider <RoutinesProvider >(
@@ -57,7 +58,7 @@ void main() {
5758 localizationsDelegates: AppLocalizations .localizationsDelegates,
5859 supportedLocales: AppLocalizations .supportedLocales,
5960 navigatorKey: key,
60- home: Scaffold (body: SlotEntryForm (slotEntry, 1 , simpleMode: simpleMode)),
61+ home: Scaffold (body: SlotEntryForm (entry ?? slotEntry, 1 , simpleMode: simpleMode)),
6162 ),
6263 );
6364 }
@@ -156,4 +157,47 @@ void main() {
156157 expect (capturedArgs[(6 * 3 ) + 1 ], 100 );
157158 expect (capturedArgs[(6 * 3 ) + 2 ], ConfigType .maxRest);
158159 });
160+
161+ testWidgets ('Fractional weight survives a no-op save in a comma-decimal locale' , (
162+ WidgetTester tester,
163+ ) async {
164+ final entry = getTestRoutine ().days[0 ].slots[0 ].entries[0 ];
165+ entry.weightConfigs.first.value = 2.5 ;
166+
167+ await tester.pumpWidget (renderWidget (simpleMode: false , locale: 'de' , entry: entry));
168+ await tester.pumpAndSettle ();
169+
170+ // The field shows the locale-formatted value, not the invariant "2.5"
171+ expect (find.text ('2,5' ), findsOneWidget);
172+
173+ // Save without touching anything
174+ await tester.tap (find.byKey (const ValueKey (SUBMIT_BUTTON_KEY_NAME )));
175+ await tester.pumpAndSettle ();
176+
177+ final capturedArgs = verify (
178+ mockRoutinesProvider.handleConfig (captureAny, captureAny, captureAny),
179+ ).captured;
180+
181+ expect (capturedArgs[(1 * 3 ) + 2 ], ConfigType .weight);
182+ expect (capturedArgs[(1 * 3 ) + 1 ], 2.5 );
183+ });
184+
185+ testWidgets ('Fractional RiR survives a no-op save' , (WidgetTester tester) async {
186+ final entry = getTestRoutine ().days[0 ].slots[0 ].entries[0 ];
187+ entry.rirConfigs = [BaseConfig .firstIteration (2.5 , 1 )];
188+
189+ await tester.pumpWidget (renderWidget (simpleMode: false , entry: entry));
190+ await tester.pumpAndSettle ();
191+
192+ // Save without touching anything
193+ await tester.tap (find.byKey (const ValueKey (SUBMIT_BUTTON_KEY_NAME )));
194+ await tester.pumpAndSettle ();
195+
196+ final capturedArgs = verify (
197+ mockRoutinesProvider.handleConfig (captureAny, captureAny, captureAny),
198+ ).captured;
199+
200+ expect (capturedArgs[(7 * 3 ) + 2 ], ConfigType .rir);
201+ expect (capturedArgs[(7 * 3 ) + 1 ], 2.5 );
202+ });
159203}
0 commit comments