Skip to content

Offline gym log for Android. No account, no ads, no internet.

Add exercise preview, archive, video step marks and new filters, and fix three exercises

InlitX47de0b9a21cb
diff --git a/test/audit_test.dart b/test/audit_test.dart
index 935cbf8..bead4fc 100644
--- a/test/audit_test.dart
+++ b/test/audit_test.dart
@@ -54,7 +54,7 @@ void main() {
]));
final pr = fit.personalRecords.single;
- expect(pr.topWeight, 80, reason: 'el récord sale de las series efectivas');
+ expect(pr.best, 80, reason: 'el récord sale de las series efectivas');
expect(pr.oneRm, closeTo(93.3, 0.1));
});
@@ -136,7 +136,7 @@ void main() {
});
test('the weekly goal never reads over 100%', () {
- fit.profile.weeklyGoal = 2;
+ fit.profile.weeklyGoal = 1;
for (int i = 0; i < 6; i++) {
fit.sessions.add(LoggedSession(DateTime.now(), 600, const []));
}
diff --git a/test/editing_test.dart b/test/editing_test.dart
index c57a7f9..ab6aadf 100644
--- a/test/editing_test.dart
+++ b/test/editing_test.dart
@@ -29,10 +29,10 @@ void main() {
test('a mis-logged exercise can be removed, and the records follow', () {
log('Bench', 60);
final fat = log('Bench Typo', 1000);
- expect(fit.personalRecords.first.topWeight, 1000);
+ expect(fit.personalRecords.first.best, 1000);
fit.deleteLoggedExercise(fat, fat.exercises.first);
- expect(fit.personalRecords.first.topWeight, 60, reason: 'el récord falso desaparece');
+ expect(fit.personalRecords.first.best, 60, reason: 'el récord falso desaparece');
});
test('removing the last exercise takes the whole session with it', () {
diff --git a/test/i18n_test.dart b/test/i18n_test.dart
index f4297d3..6c4f267 100644
--- a/test/i18n_test.dart
+++ b/test/i18n_test.dart
@@ -7,6 +7,7 @@ import 'package:gymmane/catalog/exercise_catalog.dart';
import 'package:gymmane/l10n/catalog_es.dart';
import 'package:gymmane/l10n/l10n.dart';
import 'package:gymmane/models/exercise.dart';
+import 'package:gymmane/models/workout.dart';
import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/state/fit_state.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -50,7 +51,7 @@ void main() {
expect(t.catalogName(e.id, e.name), kExerciseNameEs[e.id],
reason: 'catalogName es lo que tienen que llamar las pantallas, no e.name');
}
- expect(fit.personalRecords, isA<List<({String id, String name, double topWeight, double oneRm})>>());
+ expect(fit.personalRecords, isA<List<PersonalRecord>>());
});
test('an unknown language falls back to English instead of crashing', () {
diff --git a/test/reddit_requests_test.dart b/test/reddit_requests_test.dart
index fd4add9..ec30656 100644
--- a/test/reddit_requests_test.dart
+++ b/test/reddit_requests_test.dart
@@ -335,7 +335,7 @@ void main() {
fit.bumpRoutineSets(r.id, bench(), 1);
fit.startRoutine(r);
- final id = fit.saveSessionAsRoutine();
+ final id = fit.saveSessionAsRoutine('Copy');
final made = fit.routines.firstWhere((x) => x.id == id);
expect(made.exerciseIds, [bench()]);
expect(fit.routineSets(made, bench()), 4);
diff --git a/test/requests_18sep_test.dart b/test/requests_18sep_test.dart
index 7d7122e..b20088f 100644
--- a/test/requests_18sep_test.dart
+++ b/test/requests_18sep_test.dart
@@ -263,7 +263,7 @@ void main() {
fit.toggleChain(r.id, ids.first);
fit.startRoutine(r);
fit.setSessionWeight(0, 0, 62.5);
- final saved = fit.saveSessionAsRoutine();
+ final saved = fit.saveSessionAsRoutine('Copy');
final made = fit.routines.firstWhere((x) => x.id == saved);
expect(made.chained, contains(ids.first));
expect(fit.plannedSets(made, ids.first).first.weightKg, 62.5);
diff --git a/test/requests_27sep_test.dart b/test/requests_27sep_test.dart
new file mode 100644
index 0000000..6d0cecd
--- /dev/null
+++ b/test/requests_27sep_test.dart
@@ -0,0 +1,335 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/catalog/exercise_catalog.dart';
+import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/models/workout.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ fit.setUnits('kg');
+ });
+
+ tearDown(() {
+ if (fit.session != null) fit.saveAndExit();
+ });
+
+ String idOf(String name) => fit.matchExerciseByName(name)!.id;
+
+ Routine routineOf(List<String> names) {
+ final id = fit.createRoutine('Push');
+ for (final name in names) {
+ fit.toggleRoutineExercise(id, idOf(name));
+ }
+ return fit.routines.firstWhere((r) => r.id == id);
+ }
+
+ LoggedSession logged(DateTime at, List<LoggedSet> sets, {String id = 'push', String primary = 'chest'}) =>
+ LoggedSession(at, 600, [LoggedExercise(id, id, primary, sets)]);
+
+ group('#83 mapa de actividad', () {
+ test('un día de peso corporal se pinta', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(15, 0), LoggedSet(12, 0)]));
+ expect(fit.heatmapLevels.last, greaterThan(0));
+ });
+
+ test('un día marcado a mano también cuenta', () {
+ fit.toggleCheckin(fit.todayIndex);
+ expect(fit.heatmapLevels.last, greaterThan(0));
+ });
+ });
+
+ group('#104 récords sin peso', () {
+ test('peso corporal: el récord son las repeticiones', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(15, 0), LoggedSet(22, 0)]));
+ final pr = fit.personalRecords.single;
+ expect(pr.kind, PrKind.reps);
+ expect(pr.best, 22);
+ });
+
+ test('isométrico: el récord es el tiempo', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(0, 0, sec: 45), LoggedSet(0, 0, sec: 70)]));
+ final pr = fit.personalRecords.single;
+ expect(pr.kind, PrKind.time);
+ expect(fit.recordLabel(pr), isNot(contains('kg')));
+ });
+
+ test('con peso manda el peso y va primero en la lista', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(30, 0)], id: 'dips'));
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 100)], id: 'bench'));
+ expect(fit.personalRecords.map((r) => r.id), ['bench', 'dips']);
+ expect(fit.personalRecords.first.kind, PrKind.weight);
+ });
+ });
+
+ group('#92 inicio de semana', () {
+ test('empezar en domingo mueve toda la semana', () {
+ fit.setWeekStart(DateTime.sunday);
+ expect(fit.weekStartDate.weekday, DateTime.sunday);
+ expect(fit.weekdayAt(0), DateTime.sunday);
+ expect(fit.dateForWeekday(fit.todayIndex).day, DateTime.now().day);
+ });
+
+ test('se guarda con el resto de ajustes', () {
+ fit.setWeekStart(DateTime.saturday);
+ expect(fit.toJson()['weekStart'], DateTime.saturday);
+ fit.setWeekStart(4);
+ expect(fit.weekStartDay, DateTime.saturday, reason: 'solo lunes, sábado o domingo');
+ });
+ });
+
+ group('#117 objetivo semanal por días', () {
+ test('dos sesiones el mismo día son un día', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 60)]));
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 60)]));
+ expect(fit.daysDoneThisWeek, 1);
+ });
+
+ test('marcar y desmarcar un día lo deja como estaba', () {
+ final before = fit.daysDoneThisWeek;
+ fit.toggleCheckin(fit.todayIndex);
+ expect(fit.daysDoneThisWeek, before + 1);
+ fit.toggleCheckin(fit.todayIndex);
+ expect(fit.daysDoneThisWeek, before);
+ expect(fit.currentStreak, 0);
+ });
+ });
+
+ group('#122 salir del entreno', () {
+ test('salir pausa y deja volver donde estabas', () {
+ fit.startRoutine(routineOf(['Barbell Bench Press']));
+ fit.endCountdown();
+ fit.stepOutOfSession();
+ expect(fit.route, 'home');
+ expect(fit.sessionPaused, isTrue);
+ expect(fit.sessionParked, isTrue);
+
+ fit.stepBackIntoSession();
+ expect(fit.route, 'session');
+ expect(fit.sessionPaused, isFalse);
+ });
+
+ test('empezar otra cosa con uno aparcado vuelve al aparcado', () {
+ fit.startRoutine(routineOf(['Barbell Bench Press']));
+ fit.endCountdown();
+ final session = fit.session;
+ fit.stepOutOfSession();
+ fit.startRoutine(routineOf(['Barbell Squat']));
+ expect(fit.session, same(session));
+ expect(fit.route, 'session');
+ });
+ });
+
+ group('#102 guardar la rutina', () {
+ test('sin cambios no hay nada que guardar', () {
+ fit.startRoutine(routineOf(['Barbell Bench Press']));
+ expect(fit.sessionRoutine, isNotNull);
+ expect(fit.sessionEditedRoutine, isFalse);
+ });
+
+ test('añadir un ejercicio se puede llevar a la rutina', () {
+ final r = routineOf(['Barbell Bench Press']);
+ fit.startRoutine(r);
+ fit.addExerciseToSession(idOf('Barbell Squat'));
+ expect(fit.sessionEditedRoutine, isTrue);
+
+ fit.saveSessionIntoRoutine();
+ expect(r.exerciseIds, [idOf('Barbell Bench Press'), idOf('Barbell Squat')]);
+ expect(fit.sessionEditedRoutine, isFalse);
+ });
+
+ test('los cambios se enseñan antes de guardarlos', () {
+ final r = routineOf(['Barbell Bench Press', 'Barbell Squat', 'Barbell Deadlift']);
+ fit.startRoutine(r);
+ fit.removeSessionExercise(2);
+ fit.addExerciseToSession(idOf('Barbell Curl'));
+ fit.reorderSessionExercise(1, 0);
+ final changes = fit.sessionRoutineChanges;
+ expect(changes.added.map((e) => e.id), [idOf('Barbell Curl')]);
+ expect(changes.removed.map((e) => e.id), [idOf('Barbell Deadlift')]);
+ expect(changes.reordered, isTrue);
+ expect(r.exerciseIds, hasLength(3), reason: 'nada cambia hasta aceptar');
+ });
+
+ test('una sesión suelta se guarda con el nombre elegido', () {
+ fit.startRoutine(routineOf(['Barbell Bench Press']));
+ fit.session!.routineId = null;
+ final id = fit.saveSessionAsRoutine('Pecho');
+ expect(fit.routines.firstWhere((r) => r.id == id).name, 'Pecho');
+ expect(fit.sessionRoutine?.id, id, reason: 'el botón no vuelve a salir');
+ });
+ });
+
+ group('#115 sin material', () {
+ tearDown(fit.clearExFilters);
+
+ test('no enseña lo que necesita barra', () {
+ fit.toggleNoGearFilter();
+ final ids = fit.exercisesMatching('').map((e) => e.id).toSet();
+ expect(ids, isNot(contains(idOf('Pull-up'))));
+ expect(ids, isNot(contains('seal-jack')), reason: 'su dibujo es una estación de fondos');
+ expect(ids, isNot(contains('outdoor-run')), reason: 'el dibujo es una cinta');
+ expect(ids, contains(idOf('Push-up')));
+ });
+
+ test('elegir material lo apaga y al revés', () {
+ fit.toggleNoGearFilter();
+ fit.setEquipmentFilter('Barbell');
+ expect(fit.exNoGearOnly, isFalse);
+ fit.toggleNoGearFilter();
+ expect(fit.exEquipmentFilter, isNull);
+ });
+ });
+
+ test('#89 solo los creados por ti', () {
+ final id = fit.addCustomExercise(name: 'Mi press', primary: 'chest', equipment: 'Dumbbell');
+ fit.toggleMineFilter();
+ expect(fit.exercisesMatching('').map((e) => e.id), [id]);
+ fit.clearExFilters();
+ });
+
+ group('#120 calentamiento y #106 cardio', () {
+ test('los ejercicios sin peso también calientan', () {
+ fit.startRoutine(routineOf(['Push-up']));
+ fit.addWarmupSets(0);
+ expect(fit.hasWarmup(0), isTrue);
+ });
+
+ test('el calentamiento propone movilidad y el cardio solo cardio', () {
+ fit.startWorkout();
+ fit.startKindWorkout('warmup');
+ expect(fit.sessionPicks, isNotEmpty);
+ expect(fit.reviewExercises().where((e) => const ['Machine', 'Cable'].contains(e.equipment)), isEmpty);
+ fit.startKindWorkout('cardio');
+ final cardio = fit.reviewExercises().map((e) => e.id).toSet();
+ expect(cardio, containsAll(['skierg', 'battle-ropes', 'running']));
+ expect(cardio.every((id) => fit.isCardio(id) || kCardioExtras.contains(id)), isTrue);
+ fit.closeTrain();
+ });
+ });
+
+ group('#119 archivar', () {
+ test('un archivado desaparece de todo y vuelve al restaurarlo', () {
+ final id = idOf('Pull-up');
+ fit.toggleArchived(id);
+ expect(fit.exercisesMatching('').map((e) => e.id), isNot(contains(id)));
+ expect(fit.trainSearchResults('pull').map((e) => e.id), isNot(contains(id)));
+ expect(fit.getFilteredExercises(['back']).map((e) => e.id), isNot(contains(id)));
+ expect(fit.recommendedExercises(40).map((e) => e.id), isNot(contains(id)));
+
+ fit.toggleArchivedFilter();
+ expect(fit.exercisesMatching('').map((e) => e.id), [id]);
+
+ fit.toggleArchived(id);
+ expect(fit.exArchivedOnly, isFalse, reason: 'sin archivados el filtro se apaga');
+ expect(fit.exercisesMatching('').map((e) => e.id), contains(id));
+ });
+
+ test('se guarda en la copia', () {
+ fit.toggleArchived(idOf('Pull-up'));
+ expect(fit.toJson()['archived'], [idOf('Pull-up')]);
+ });
+ });
+
+ test('#95 los recomendados se pueden quitar y se guarda', () {
+ expect(fit.showRecommended, isTrue);
+ fit.toggleRecommended();
+ expect(fit.toJson()['showRecs'], isFalse);
+ });
+
+ test('#111 las marcas del vídeo se guardan y se van con el vídeo', () {
+ final id = idOf('Barbell Bench Press');
+ fit.setVideoMark(id, 1, 40000);
+ expect(fit.videoMark(id, 1), 40000);
+ expect(fit.toJson()['marks'], {id: {'1': 40000}});
+ fit.setVideoMark(id, 1, null);
+ expect(fit.videoMarks, isEmpty);
+ fit.setVideoMark(id, 0, 1000);
+ fit.clearExerciseMedia(id);
+ expect(fit.videoMark(id, 0), isNull);
+ });
+
+ group('#86 varias rutinas al día', () {
+ test('apagado, un día solo tiene una rutina', () {
+ final a = routineOf(['Barbell Bench Press']);
+ final b = routineOf(['Barbell Squat']);
+ final today = DateTime.now().weekday;
+ fit.togglePlanDay(today, a.id);
+ fit.togglePlanDay(today, b.id);
+ expect(fit.planIdsOn(today), [b.id]);
+ });
+
+ test('encendido, van en orden y el día acaba cuando se hacen todas', () {
+ fit.toggleMultiPlan();
+ final a = routineOf(['Barbell Bench Press']);
+ final b = routineOf(['Barbell Squat']);
+ final today = DateTime.now().weekday;
+ fit.togglePlanDay(today, a.id);
+ fit.togglePlanDay(today, b.id);
+ expect(fit.todayRoutine, same(a));
+ expect(fit.todayPlanDone, isFalse);
+
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 60)]));
+ expect(fit.todayRoutine, same(b));
+ expect(fit.todayPlanDone, isFalse);
+
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 100)]));
+ expect(fit.todayPlanDone, isTrue);
+ });
+
+ test('borrar la primera deja la segunda y se guarda', () {
+ fit.toggleMultiPlan();
+ final a = routineOf(['Barbell Bench Press']);
+ final b = routineOf(['Barbell Squat']);
+ final c = routineOf(['Barbell Deadlift']);
+ fit.togglePlanDay(1, a.id);
+ fit.togglePlanDay(1, b.id);
+ fit.togglePlanDay(1, c.id);
+ fit.deleteRoutine(a.id);
+ expect(fit.planIdsOn(1), [b.id, c.id]);
+ expect(fit.toJson()['planExtras'], {'1': [c.id]});
+ fit.toggleMultiPlan();
+ expect(fit.planIdsOn(1), [b.id], reason: 'apagado se ignoran las extra');
+ });
+ });
+
+ group('texto para la IA', () {
+ test('un usuario nuevo pide empezar suave y que le pregunten', () {
+ final text = fit.planRequestText();
+ expect(text, contains(t.planNoHistory));
+ expect(text, contains(t.planAskFirst));
+ expect(text, contains(t.planDays(fit.weeklyTarget)));
+ });
+
+ test('con historial lleva los entrenos y las mejores series', () {
+ fit.sessions.add(logged(DateTime.now(), [LoggedSet(5, 100)], id: idOf('Barbell Bench Press')));
+ final text = fit.planRequestText();
+ expect(text, isNot(contains(t.planNoHistory)));
+ expect(text, contains(t.planHistory(1)));
+ expect(text, contains(t.planBestLifts));
+ });
+ });
+
+ group('#85 racha con calendario', () {
+ test('un día sin rutina no rompe la racha', () {
+ final today = DateTime.now();
+ final yesterday = DateTime(today.year, today.month, today.day - 1);
+ final before = DateTime(today.year, today.month, today.day - 2);
+ fit.sessions.add(logged(today, [LoggedSet(5, 60)]));
+ fit.sessions.add(logged(before, [LoggedSet(5, 60)]));
+ expect(fit.currentStreak, 1);
+
+ final r = routineOf(['Barbell Bench Press']);
+ for (var d = 1; d <= 7; d++) {
+ if (d != yesterday.weekday) fit.assignRoutineToDay(d, r.id);
+ }
+ expect(fit.currentStreak, 2);
+ });
+ });
+}
diff --git a/test/scroll_keep_test.dart b/test/scroll_keep_test.dart
new file mode 100644
index 0000000..e0b41a0
--- /dev/null
+++ b/test/scroll_keep_test.dart
@@ -0,0 +1,46 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/app/gymmane_app.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ testWidgets('volver de un ejercicio deja la lista donde estaba', (tester) async {
+ SharedPreferences.setMockInitialValues({});
+ await tester.runAsync(() => Store.instance.init());
+ fit.resetAllData();
+ fit.onboarded = true;
+ fit.pendingAwards.clear();
+ fit.goExercises();
+ await tester.pumpWidget(const GymManeApp());
+ for (var i = 0; i < 10; i++) {
+ await tester.pump(const Duration(milliseconds: 80));
+ }
+
+ final list = find.byKey(const PageStorageKey('exercises'));
+ double offset() => tester
+ .state<ScrollableState>(find.descendant(of: find.byKey(const PageStorageKey('exercises')), matching: find.byType(Scrollable)))
+ .position
+ .pixels;
+ await tester.drag(list, const Offset(0, -2500));
+ for (var i = 0; i < 10; i++) {
+ await tester.pump(const Duration(milliseconds: 80));
+ }
+ final before = offset();
+ expect(before, greaterThan(1000));
+
+ fit.openExercise(fit.exercisesFiltered.first.id);
+ for (var i = 0; i < 12; i++) {
+ await tester.pump(const Duration(milliseconds: 80));
+ }
+ fit.closeExerciseDetail();
+ for (var i = 0; i < 12; i++) {
+ await tester.pump(const Duration(milliseconds: 80));
+ }
+ final after = offset();
+ expect(after, closeTo(before, 1));
+ });
+}
diff --git a/test/set_kinds_test.dart b/test/set_kinds_test.dart
index 3c90b90..6177392 100644
--- a/test/set_kinds_test.dart
+++ b/test/set_kinds_test.dart
@@ -125,13 +125,18 @@ void main() {
expect(fit.session!.exercises.first.sets, hasLength(after));
});
- test('with no weight on the bar there is nothing to ramp up to', () {
+ test('with no weight on the bar the warm-up is one set at half the reps', () {
startChestSession();
- for (var i = 0; i < fit.session!.exercises.first.sets.length; i++) {
+ final sets = fit.session!.exercises.first.sets;
+ for (var i = 0; i < sets.length; i++) {
fit.setSessionWeight(0, i, 0);
}
+ final reps = sets.map((s) => s.reps).reduce((a, b) => a > b ? a : b);
fit.addWarmupSets(0);
- expect(fit.hasWarmup(0), false);
+ expect(sets.first.kind, SetKind.warmup);
+ expect(sets.first.weight, 0);
+ expect(sets.first.reps, (reps / 2).ceil());
+ expect(sets.where((s) => s.kind == SetKind.warmup), hasLength(1));
});
test('the ramp rounds to the plates you actually have', () {
diff --git a/test/stats_realdata_test.dart b/test/stats_realdata_test.dart
index 5d9e713..26d727b 100644
--- a/test/stats_realdata_test.dart
+++ b/test/stats_realdata_test.dart
@@ -95,11 +95,11 @@ void main() {
test('personal records are the best set ever, not the last one', () {
final prs = {for (final p in fit.personalRecords) p.name: p};
- expect(prs['Barbell Deadlift']!.topWeight, 120);
+ expect(prs['Barbell Deadlift']!.best, 120);
expect(prs['Barbell Deadlift']!.oneRm, closeTo(152, 1));
- expect(prs['Barbell Full Squat']!.topWeight, 110);
- expect(prs['Barbell Bench Press']!.topWeight, 77.5);
- expect(prs['Barbell Curl']!.topWeight, 32.5);
+ expect(prs['Barbell Full Squat']!.best, 110);
+ expect(prs['Barbell Bench Press']!.best, 77.5);
+ expect(prs['Barbell Curl']!.best, 32.5);
expect(fit.personalRecords.first.name, 'Barbell Deadlift');
});
diff --git a/test/wear_test.dart b/test/wear_test.dart
index 6a26294..4c37647 100644
--- a/test/wear_test.dart
+++ b/test/wear_test.dart
@@ -104,8 +104,8 @@ void main() {
await tester.pump();
expect(fit.isSessionComplete, isTrue);
- await _reveal(tester, _label(t.saveAndExit));
- await tester.tap(_label(t.saveAndExit));
+ await _reveal(tester, _label(t.done));
+ await tester.tap(_label(t.done));
await tester.pump();
expect(fit.session, isNull);
expect(fit.sessions.length, 1);