diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index 8a91faad..c24d729f 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -23,7 +23,45 @@ on: - 'ios/**' jobs: - Build: + Workout: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - name: Check Version + run: flutter --version + - name: Flutter Doctor + run: flutter doctor -v + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 35 + arch: x86_64 + script: | + # Build the APK + flutter build apk --debug + adb -s emulator-5554 install build/app/outputs/flutter-apk/app-debug.apk + adb -s emulator-5554 root + adb -s emulator-5554 shell appops set com.codepup.workout_timer SCHEDULE_EXACT_ALARM allow + flutter drive -d emulator-5554 --driver=test_driver/integration_test.dart --target=integration_test/workout_test.dart + + Timer: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/integration_test/timer_test.dart b/integration_test/timer_test.dart index 57c18fce..7401829c 100644 --- a/integration_test/timer_test.dart +++ b/integration_test/timer_test.dart @@ -9,8 +9,6 @@ void main() { final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; - const String workoutName = 'Test Workout'; - const String workoutName2 = 'Test Workout Edited'; const String timerName = 'Test Timer'; group('end-to-end test', () { @@ -19,26 +17,6 @@ void main() { await binding.setSurfaceSize(const Size(1080, 2400)); expect(find.text('No saved timers'), findsOneWidget); }); - testWidgets('create a workout', (tester) async { - await loadApp(tester); - await navigateToAddWorkoutOrTimer(tester, true); - await createWorkout(tester, workoutName); - }); - testWidgets('run a workout and restart', (tester) async { - await loadApp(tester); - await verifyWorkoutOrTimerOpens(tester, workoutName); - await runWorkoutOne(tester, binding); - }); - testWidgets('edit workout', (tester) async { - await loadApp(tester); - await verifyWorkoutOrTimerOpens(tester, workoutName); - await editWorkout(tester, workoutName2); - }); - testWidgets('run an edited workout and restart', (tester) async { - await loadApp(tester); - await verifyWorkoutOrTimerOpens(tester, workoutName2); - await runWorkoutTwo(tester); - }); testWidgets('create a timer', (tester) async { await loadApp(tester); await navigateToAddWorkoutOrTimer(tester, false); diff --git a/integration_test/workout_test.dart b/integration_test/workout_test.dart new file mode 100644 index 00000000..03d7f733 --- /dev/null +++ b/integration_test/workout_test.dart @@ -0,0 +1,38 @@ +import 'dart:ui'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'functions.dart'; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; + + const String workoutName = 'Test Workout'; + const String workoutName2 = 'Test Workout Edited'; + + group('end-to-end test', () { + testWidgets('create a workout', (tester) async { + await loadApp(tester); + await binding.setSurfaceSize(const Size(1080, 2400)); + await navigateToAddWorkoutOrTimer(tester, true); + await createWorkout(tester, workoutName); + }); + testWidgets('run a workout and restart', (tester) async { + await loadApp(tester); + await verifyWorkoutOrTimerOpens(tester, workoutName); + await runWorkoutOne(tester, binding); + }); + testWidgets('edit workout', (tester) async { + await loadApp(tester); + await verifyWorkoutOrTimerOpens(tester, workoutName); + await editWorkout(tester, workoutName2); + }); + testWidgets('run an edited workout and restart', (tester) async { + await loadApp(tester); + await verifyWorkoutOrTimerOpens(tester, workoutName2); + await runWorkoutTwo(tester); + }); + }); +}