From 593aadae85bbb4dafe69c9b3366cd91a1d837486 Mon Sep 17 00:00:00 2001 From: a-mabe Date: Fri, 28 Jul 2023 11:18:16 -0400 Subject: [PATCH] Test changing working time --- lib/create_workout/set_timings.dart | 4 ++++ test/workout_test.dart | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/create_workout/set_timings.dart b/lib/create_workout/set_timings.dart index 0342a7c..8e1381f 100644 --- a/lib/create_workout/set_timings.dart +++ b/lib/create_workout/set_timings.dart @@ -97,6 +97,7 @@ class _SetTimingsState extends State { children: [ const Icon(Icons.fitness_center), IconButton( + key: const Key('work-decrement'), icon: const Icon(Icons.remove), onPressed: () => setState(() { final newValue = exerciseTime - 1; @@ -106,6 +107,7 @@ class _SetTimingsState extends State { ), Text('Working time: $exerciseTime seconds'), IconButton( + key: const Key('work-increment'), icon: const Icon(Icons.add), onPressed: () => setState(() { final newValue = exerciseTime + 1; @@ -125,6 +127,7 @@ class _SetTimingsState extends State { children: [ const Icon(Icons.snooze), IconButton( + key: const Key('rest-decrement'), icon: const Icon(Icons.remove), onPressed: () => setState(() { final newValue = restTime - 1; @@ -134,6 +137,7 @@ class _SetTimingsState extends State { ), Text('Rest time: $restTime seconds'), IconButton( + key: const Key('rest-increment'), icon: const Icon(Icons.add), onPressed: () => setState(() { final newValue = restTime + 1; diff --git a/test/workout_test.dart b/test/workout_test.dart index 075a3a0..a9dfe25 100644 --- a/test/workout_test.dart +++ b/test/workout_test.dart @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:openhiit/main.dart'; void main() { - testWidgets('Load add workout smoke test', (WidgetTester tester) async { + testWidgets('Add workout smoke test', (WidgetTester tester) async { String workoutName = "Test workout 1"; // Build our app and trigger a frame. @@ -68,5 +68,29 @@ void main() { expect(find.text('testing $i'), findsOneWidget); } + + // Tap to go to the next page. + await tester.tap(find.byType(ElevatedButton)); + await tester.pumpAndSettle(); + + // Reduce working time. + for (var i = 0; i < 2; i++) { + // Reduce the working time by 2. + await tester.tap(find.byKey(const Key('work-decrement'))); + await tester.pumpAndSettle(); + } + + // Work time should be 18. + expect(find.text('18'), findsOneWidget); + + // Increase working time. + for (var i = 0; i < 2; i++) { + // Increase the working time by 3. + await tester.tap(find.byKey(const Key('work-increment'))); + await tester.pumpAndSettle(); + } + + // Work time should be 21. + expect(find.text('21'), findsOneWidget); }); }