Skip to content

Commit

Permalink
Add translated exercises for the screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Jan 10, 2024
1 parent c91263a commit cf1bedd
Show file tree
Hide file tree
Showing 9 changed files with 610 additions and 15 deletions.
3 changes: 2 additions & 1 deletion integration_test/1_dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import '../test/nutrition/nutritional_plan_form_test.mocks.dart';
import '../test/workout/weight_unit_form_widget_test.mocks.dart';
import '../test/workout/workout_form_test.mocks.dart';
import '../test_data/body_weight.dart';
import '../test_data/exercises.dart';
import '../test_data/measurements.dart';
import '../test_data/nutritional_plans.dart';
import '../test_data/workouts.dart';

Widget createDashboardScreen({locale = 'en'}) {
final mockWorkoutProvider = MockWorkoutPlansProvider();
when(mockWorkoutProvider.activePlan).thenReturn(getWorkout());
when(mockWorkoutProvider.activePlan).thenReturn(getWorkout(exercises: getScreenshotExercises()));

final Map<String, dynamic> logs = {
'results': [
Expand Down
5 changes: 3 additions & 2 deletions integration_test/2_workout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import 'package:wger/screens/workout_plan_screen.dart';
import 'package:wger/theme/theme.dart';

import '../test/workout/workout_form_test.mocks.dart';
import '../test_data/exercises.dart';
import '../test_data/workouts.dart';

Widget createWorkoutDetailScreen({locale = 'en'}) {
final key = GlobalKey<NavigatorState>();

final mockWorkoutProvider = MockWorkoutPlansProvider();
final workout = getWorkout();
final workout = getWorkout(exercises: getScreenshotExercises());
when(mockWorkoutProvider.activePlan).thenReturn(workout);
when(mockWorkoutProvider.fetchAndSetWorkoutPlanFull(1)).thenAnswer((_) => Future.value(workout));

Expand All @@ -33,7 +34,7 @@ Widget createWorkoutDetailScreen({locale = 'en'}) {
home: TextButton(
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: getWorkout()),
settings: RouteSettings(arguments: workout),
builder: (_) => WorkoutPlanScreen(),
),
),
Expand Down
2 changes: 1 addition & 1 deletion integration_test/3_gym_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import '../test_data/workouts.dart';
Widget createGymModeScreen({locale = 'en'}) {
final key = GlobalKey<NavigatorState>();
final bases = getTestExerciseBases();
final workout = getWorkout();
final workout = getWorkout(exercises: getScreenshotExercises());

final mockExerciseProvider = MockExercisesProvider();

Expand Down
12 changes: 7 additions & 5 deletions integration_test/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Start emulator and run
This will generate some screenshots and save them to the Play Store metadata folder.

`flutter drive --driver=test_driver/screenshot_driver.dart --target=integration_test/make_screenshots_test.dart`
1) Set the correct value for the device size by setting the `destination` variable
2) Start the correct emulator and
run `flutter drive --driver=test_driver/screenshot_driver.dart --target=integration_test/make_screenshots_test.dart`
3) If you get errors or the screenshots are not written to disk, edit the
`languages` list and comment some of the languages

This will generate some screenshots and save them to the Play Store metadata folder

See
See also

* <https://github.com/openfoodfacts/smooth-app/issues/217#issuecomment-1092678779>
* <https://dev.to/mjablecnik/take-screenshot-during-flutter-integration-tests-435k>
9 changes: 7 additions & 2 deletions integration_test/make_screenshots_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum DeviceType {
wearScreenshots
}

final destination = DeviceType.tenInchScreenshots.name;
final destination = DeviceType.phoneScreenshots.name;

Future<void> takeScreenshot(tester, binding, String language, String name) async {
if (Platform.isAndroid) {
Expand All @@ -37,19 +37,24 @@ const languages = [
// Note: it seems if too many languages are processed at once, some processes
// disappear and no images are written. Doing this in smaller steps works fine

/*
'ca',
'de-DE',
'el-GR',
'en-US',
'es-ES',
*/

/*
'fr-FR',
'hi-IN',
'hr',
'it-IT',
'pt-BR',
'nb-NO',
*/

'nb-NO',
'pl-PL',
'ru-RU',
'tr-TR',
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,10 @@ packages:
dependency: transitive
description:
name: image_picker_android
sha256: "1a27bf4cc0330389cebe465bab08fe6dec97e44015b4899637344bb7297759ec"
sha256: "39f2bfe497e495450c81abcd44b62f56c2a36a37a175da7d137b4454977b51b1"
url: "https://pub.dev"
source: hosted
version: "0.8.9+2"
version: "0.8.9+3"
image_picker_for_web:
dependency: transitive
description:
Expand Down
13 changes: 13 additions & 0 deletions test_data/exercises.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'package:wger/models/exercises/language.dart';
import 'package:wger/models/exercises/muscle.dart';
import 'package:wger/models/exercises/translation.dart';

import 'screenshots_exercises.dart';

const tLanguage1 = Language(id: 1, shortName: 'de', fullName: 'Deutsch');
const tLanguage2 = Language(id: 2, shortName: 'en', fullName: 'English');
const tLanguage3 = Language(id: 3, shortName: 'fr', fullName: 'Français');
Expand Down Expand Up @@ -208,3 +210,14 @@ List<ExerciseBase> getTestExerciseBases() {

return [benchPress, crunches, deadLift, curls, squats, sideRaises];
}

List<ExerciseBase> getScreenshotExercises() {
benchPress.translations = benchPressTranslations;
crunches.translations = crunchesTranslations;
deadLift.translations = deadLiftTranslations;
curls.translations = curlsTranslations;
squats.translations = squatsTranslations;
sideRaises.translations = raisesTranslations;

return [benchPress, crunches, deadLift, curls, squats, sideRaises];
}
Loading

0 comments on commit cf1bedd

Please sign in to comment.