mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-05 23:44:02 +01:00
Build the routine fixtures from builders instead of mutating them
This commit is contained in:
@@ -73,7 +73,7 @@ class Slot {
|
||||
config = null;
|
||||
exercisesObj = exercises ?? [];
|
||||
exercisesIds = exercisesObj.map((e) => e.id).toList();
|
||||
entries = entries ?? [];
|
||||
this.entries = entries ?? [];
|
||||
if (day != null) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class _StubRoutinesRiverpod extends RoutinesRiverpod {
|
||||
|
||||
@override
|
||||
Stream<RoutinesState> build() =>
|
||||
Stream.value(RoutinesState(routines: [getTestRoutine()..sessions = _sessions]));
|
||||
Stream.value(RoutinesState(routines: [getTestRoutine().copyWith(sessions: _sessions)]));
|
||||
}
|
||||
|
||||
class _StubNutritionNotifier extends NutritionNotifier {
|
||||
|
||||
@@ -27,12 +27,10 @@ void main() {
|
||||
group('Routine model tests', () {
|
||||
test('correctly filters out null days', () {
|
||||
// Arrange: a rest day of the "fixed weekly schedule" carries no day
|
||||
final routine = getTestRoutine();
|
||||
final withDay = getTestRoutine().dayData[0];
|
||||
final withoutDay = getTestRoutine().dayData[0]..day = null;
|
||||
routine.dayData = [withDay, withoutDay];
|
||||
withDay.date = DateTime(2026, 1, 1);
|
||||
withoutDay.date = DateTime(2026, 1, 2);
|
||||
final day = getTestRoutine().days.first;
|
||||
final withDay = DayData(iteration: 1, date: DateTime(2026, 1, 1), day: day);
|
||||
final withoutDay = DayData(iteration: 1, date: DateTime(2026, 1, 2), day: null);
|
||||
final routine = getTestRoutine().copyWith(dayData: [withDay, withoutDay]);
|
||||
|
||||
// Assert
|
||||
expect(routine.dayDataCurrentIteration.length, equals(2));
|
||||
@@ -42,15 +40,13 @@ void main() {
|
||||
test('keeps the last entry of a day repeated by the weekly schedule', () {
|
||||
// Arrange: three entries for the same day, as the fixed weekly
|
||||
// schedule produces them
|
||||
final routine = getTestRoutine();
|
||||
routine.dayData = [
|
||||
getTestRoutine().dayData[0],
|
||||
getTestRoutine().dayData[0],
|
||||
getTestRoutine().dayData[0],
|
||||
];
|
||||
routine.dayData[0].date = DateTime(2026, 1, 1);
|
||||
routine.dayData[1].date = DateTime(2026, 1, 2);
|
||||
routine.dayData[2].date = DateTime(2026, 1, 3);
|
||||
final day = getTestRoutine().days.first;
|
||||
final routine = getTestRoutine().copyWith(
|
||||
dayData: [
|
||||
for (final date in [1, 2, 3])
|
||||
DayData(iteration: 1, date: DateTime(2026, 1, date), day: day),
|
||||
],
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(routine.dayDataCurrentIteration.length, equals(3));
|
||||
@@ -63,9 +59,10 @@ void main() {
|
||||
DayData entry(int iteration, int day) =>
|
||||
DayData(iteration: iteration, date: DateTime(2026, 1, day), day: null);
|
||||
|
||||
final routine = getTestRoutine()
|
||||
..dayData = [entry(1, 5), entry(1, 6), entry(2, 12), entry(2, 13)]
|
||||
..dayDataGym = [entry(1, 5), entry(2, 12)];
|
||||
final routine = getTestRoutine().copyWith(
|
||||
dayData: [entry(1, 5), entry(1, 6), entry(2, 12), entry(2, 13)],
|
||||
dayDataGym: [entry(1, 5), entry(2, 12)],
|
||||
);
|
||||
|
||||
test('follows the day the clock is on', () {
|
||||
withClock(Clock.fixed(DateTime(2026, 1, 12, 9)), () {
|
||||
|
||||
@@ -23,8 +23,10 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
import 'package:wger/core/consts.dart';
|
||||
import 'package:wger/features/exercises/models/image.dart';
|
||||
import 'package:wger/features/routines/models/day_data.dart';
|
||||
import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/models/page_progress.dart';
|
||||
import 'package:wger/features/routines/models/routine.dart';
|
||||
import 'package:wger/features/routines/notifications/workout_notification_content.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state_notifier.dart';
|
||||
@@ -32,6 +34,32 @@ import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
|
||||
import '../../../../test_data/routines.dart';
|
||||
|
||||
/// The test routine with a third slot on the first gym day, repeating its
|
||||
/// first slot under a slot entry of its own
|
||||
Routine withThirdSlot(Routine routine) {
|
||||
final firstDay = routine.dayDataGym.first;
|
||||
final firstSlot = firstDay.slots.first;
|
||||
return routine.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: firstDay.iteration,
|
||||
date: firstDay.date,
|
||||
day: firstDay.day,
|
||||
slots: [
|
||||
...firstDay.slots,
|
||||
makeSlotData(
|
||||
comment: firstSlot.comment,
|
||||
setConfigs: [
|
||||
for (final config in firstSlot.setConfigs) config.copyWith(slotEntryId: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
...routine.dayDataGym.skip(1),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
final now = DateTime.utc(2025, 3, 29, 14, 33);
|
||||
final i18n = lookupAppLocalizations(const Locale('en'));
|
||||
@@ -90,8 +118,7 @@ void main() {
|
||||
group('Rest', () {
|
||||
for (final overviews in [false, true]) {
|
||||
test('next notification skips completed slots (overviews=$overviews)', () {
|
||||
final routine = getTestRoutine();
|
||||
routine.dayDataGym.first.slots.add(routine.dayDataGym.first.slots.first);
|
||||
final routine = withThirdSlot(getTestRoutine());
|
||||
notifier.state = notifier.state.copyWith(routine: routine, showExercisePages: overviews);
|
||||
notifier.calculatePages();
|
||||
final slots = notifier.state.pages.where((p) => p.type == PageType.set).toList();
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:wger/features/routines/models/weight_unit.dart';
|
||||
import 'package:wger/features/routines/providers/gym_log_notifier.dart';
|
||||
|
||||
import '../../../../test_data/exercises.dart';
|
||||
import '../../../../test_data/routines.dart';
|
||||
|
||||
void main() {
|
||||
late ProviderContainer container;
|
||||
@@ -33,24 +34,6 @@ void main() {
|
||||
container = ProviderContainer.test();
|
||||
});
|
||||
|
||||
Log makeLog({
|
||||
String? id,
|
||||
int exerciseId = 1,
|
||||
int routineId = 100,
|
||||
num weight = 50,
|
||||
num repetitions = 10,
|
||||
DateTime? date,
|
||||
}) {
|
||||
return Log(
|
||||
id: id ?? 'log-1',
|
||||
exerciseId: exerciseId,
|
||||
routineId: routineId,
|
||||
weight: weight,
|
||||
repetitions: repetitions,
|
||||
date: date ?? DateTime.utc(2020, 1, 1),
|
||||
);
|
||||
}
|
||||
|
||||
test('initial state is null', () {
|
||||
expect(container.read(gymLogProvider), isNull);
|
||||
});
|
||||
@@ -66,8 +49,11 @@ void main() {
|
||||
test('setLog stores a copy with cleared id/sessionId and the current clock as date', () {
|
||||
final fixed = DateTime.utc(2026, 5, 1, 12);
|
||||
withClock(Clock.fixed(fixed), () {
|
||||
final source = makeLog(id: 'original-id', date: DateTime.utc(2020, 1, 1))
|
||||
..sessionId = 'session-from-2020';
|
||||
final source = makeLog(
|
||||
id: 'original-id',
|
||||
sessionId: 'session-from-2020',
|
||||
date: DateTime.utc(2020, 1, 1),
|
||||
);
|
||||
|
||||
container.read(gymLogProvider.notifier).setLog(source);
|
||||
|
||||
|
||||
@@ -873,7 +873,7 @@ void main() {
|
||||
bool superset = false,
|
||||
}) {
|
||||
final exercises = getTestExercises();
|
||||
final routine = getTestRoutine();
|
||||
final base = getTestRoutine();
|
||||
SetConfigData config(int index) => SetConfigData(
|
||||
exerciseId: exercises[index].id,
|
||||
exercise: exercises[index],
|
||||
@@ -883,25 +883,27 @@ void main() {
|
||||
restTime: 60,
|
||||
textRepr: '8x40kg',
|
||||
);
|
||||
routine.dayDataGym = [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2026, 11, 27),
|
||||
day: routine.days.first,
|
||||
slots: [
|
||||
for (var index = 0; index < slotCount; index++)
|
||||
SlotData(
|
||||
isSuperset: superset && index == 1,
|
||||
exerciseIds: superset && index == 1
|
||||
? [exercises[1].id, exercises[2].id]
|
||||
: [exercises[index].id],
|
||||
setConfigs: superset && index == 1
|
||||
? [config(1), config(2), config(1), config(2)]
|
||||
: [config(index)],
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
final routine = base.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2026, 11, 27),
|
||||
day: base.days.first,
|
||||
slots: [
|
||||
for (var index = 0; index < slotCount; index++)
|
||||
SlotData(
|
||||
isSuperset: superset && index == 1,
|
||||
exerciseIds: superset && index == 1
|
||||
? [exercises[1].id, exercises[2].id]
|
||||
: [exercises[index].id],
|
||||
setConfigs: superset && index == 1
|
||||
? [config(1), config(2), config(1), config(2)]
|
||||
: [config(index)],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
notifier.state = notifier.state.copyWith(
|
||||
routine: routine,
|
||||
showTimerPages: timers,
|
||||
|
||||
@@ -25,6 +25,8 @@ import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/providers/workout_logs_notifier.dart';
|
||||
import 'package:wger/features/routines/providers/workout_logs_repository.dart';
|
||||
|
||||
import '../../../../test_data/routines.dart';
|
||||
|
||||
import 'workout_logs_notifier_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WorkoutLogRepository])
|
||||
@@ -39,24 +41,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
Log makeLog({
|
||||
num repetitions = 10,
|
||||
int repetitionsUnitId = 1,
|
||||
num weight = 50,
|
||||
int weightUnitId = 1,
|
||||
DateTime? date,
|
||||
}) {
|
||||
return Log(
|
||||
exerciseId: 1,
|
||||
routineId: 100,
|
||||
repetitions: repetitions,
|
||||
repetitionsUnitId: repetitionsUnitId,
|
||||
weight: weight,
|
||||
weightUnitId: weightUnitId,
|
||||
date: date ?? DateTime.utc(2026, 4, 15),
|
||||
);
|
||||
}
|
||||
|
||||
void stubLogs(List<Log> logs) {
|
||||
when(
|
||||
mockRepo.watchLogsByExerciseDrift(
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/models/session.dart';
|
||||
import 'package:wger/features/routines/providers/workout_logs_repository.dart';
|
||||
|
||||
import '../../../../test_data/routines.dart';
|
||||
import '../../../helpers/in_memory_drift.dart';
|
||||
|
||||
void main() {
|
||||
@@ -37,24 +38,6 @@ void main() {
|
||||
await db.close();
|
||||
});
|
||||
|
||||
Log makeLog({
|
||||
int exerciseId = 1,
|
||||
int? routineId = 100,
|
||||
String? sessionId,
|
||||
DateTime? date,
|
||||
num weight = 50,
|
||||
num repetitions = 10,
|
||||
}) {
|
||||
return Log(
|
||||
exerciseId: exerciseId,
|
||||
routineId: routineId,
|
||||
sessionId: sessionId,
|
||||
weight: weight,
|
||||
repetitions: repetitions,
|
||||
date: date ?? DateTime.utc(2026, 4, 15, 10, 30),
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<dynamic>> readLogs() => db.select(db.workoutLogTable).get();
|
||||
Future<List<dynamic>> readSessions() => db.select(db.workoutSessionTable).get();
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:wger/database/powersync/database.dart';
|
||||
import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/models/session.dart';
|
||||
import 'package:wger/features/routines/providers/workout_session_repository.dart';
|
||||
|
||||
import '../../../../test_data/routines.dart';
|
||||
import '../../../helpers/in_memory_drift.dart';
|
||||
|
||||
void main() {
|
||||
@@ -58,25 +58,6 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
Log makeLog({
|
||||
String? id,
|
||||
required String sessionId,
|
||||
int exerciseId = 1,
|
||||
int routineId = 100,
|
||||
DateTime? date,
|
||||
num weight = 50,
|
||||
}) {
|
||||
return Log(
|
||||
id: id,
|
||||
exerciseId: exerciseId,
|
||||
routineId: routineId,
|
||||
sessionId: sessionId,
|
||||
weight: weight,
|
||||
repetitions: 10,
|
||||
date: date ?? DateTime.utc(2026, 4, 15, 10, 30),
|
||||
);
|
||||
}
|
||||
|
||||
group('CRUD', () {
|
||||
test('addLocalDrift inserts a row', () async {
|
||||
final inserted = await repo.addLocalDrift(makeSession());
|
||||
@@ -138,8 +119,8 @@ void main() {
|
||||
test('attaches logs to their parent session', () async {
|
||||
await seedUnits();
|
||||
final session = await repo.addLocalDrift(makeSession());
|
||||
final log1 = makeLog(sessionId: session.id!, exerciseId: 1);
|
||||
final log2 = makeLog(sessionId: session.id!, exerciseId: 2);
|
||||
final log1 = makeLog(sessionId: session.id, exerciseId: 1);
|
||||
final log2 = makeLog(sessionId: session.id, exerciseId: 2);
|
||||
await db.into(db.workoutLogTable).insert(log1.toCompanion());
|
||||
await db.into(db.workoutLogTable).insert(log2.toCompanion());
|
||||
|
||||
@@ -151,7 +132,7 @@ void main() {
|
||||
test('hydrates each log with its repetition and weight unit', () async {
|
||||
await seedUnits();
|
||||
final session = await repo.addLocalDrift(makeSession());
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: session.id!).toCompanion());
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: session.id).toCompanion());
|
||||
|
||||
final emitted = await repo.watchAllDrift().first;
|
||||
|
||||
@@ -172,8 +153,8 @@ void main() {
|
||||
await seedUnits();
|
||||
final s1 = await repo.addLocalDrift(makeSession(routineId: 1));
|
||||
final s2 = await repo.addLocalDrift(makeSession(routineId: 2));
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: s1.id!).toCompanion());
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: s2.id!).toCompanion());
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: s1.id).toCompanion());
|
||||
await db.into(db.workoutLogTable).insert(makeLog(sessionId: s2.id).toCompanion());
|
||||
|
||||
final emitted = await repo.watchAllDrift().first;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import 'package:wger/features/account/providers/user_profile_repository.dart';
|
||||
import 'package:wger/features/exercises/models/exercise.dart';
|
||||
import 'package:wger/features/exercises/providers/exercise_repository.dart';
|
||||
import 'package:wger/features/exercises/providers/exercises_notifier.dart';
|
||||
import 'package:wger/features/routines/models/day_data.dart';
|
||||
import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/models/repetition_unit.dart';
|
||||
import 'package:wger/features/routines/models/routine.dart';
|
||||
@@ -73,6 +74,32 @@ import 'gym_mode_test.mocks.dart';
|
||||
UserProfileRepository,
|
||||
WorkoutNotificationService,
|
||||
])
|
||||
/// The test routine with a third slot on the first gym day, repeating its
|
||||
/// first slot under a slot entry of its own
|
||||
Routine withThirdSlot(Routine routine) {
|
||||
final firstDay = routine.dayDataGym.first;
|
||||
final firstSlot = firstDay.slots.first;
|
||||
return routine.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: firstDay.iteration,
|
||||
date: firstDay.date,
|
||||
day: firstDay.day,
|
||||
slots: [
|
||||
...firstDay.slots,
|
||||
makeSlotData(
|
||||
comment: firstSlot.comment,
|
||||
setConfigs: [
|
||||
for (final config in firstSlot.setConfigs) config.copyWith(slotEntryId: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
...routine.dayDataGym.skip(1),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
installFakeConnectivity();
|
||||
|
||||
@@ -540,8 +567,7 @@ void main() {
|
||||
setTestViewSize(tester, const Size(800, 1000));
|
||||
await PreferenceHelper.asyncPref.setBool(PREFS_SHOW_TIMER, timers);
|
||||
await PreferenceHelper.asyncPref.setBool(PREFS_SHOW_EXERCISES, overviews);
|
||||
final routine = getTestRoutine();
|
||||
routine.dayDataGym.first.slots.add(routine.dayDataGym.first.slots.first);
|
||||
final routine = withThirdSlot(getTestRoutine());
|
||||
when(mockRoutinesRepo.watchAllDrift()).thenAnswer((_) => Stream.value([routine]));
|
||||
when(mockRoutinesRepo.fetchAndSetRoutineFullServer(any)).thenAnswer((_) async => routine);
|
||||
await tester.pumpWidget(renderGymMode());
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'package:material_ui/material_ui.dart';
|
||||
import 'package:wger/features/routines/models/log.dart';
|
||||
import 'package:wger/features/routines/widgets/charts.dart';
|
||||
|
||||
import '../../../../test_data/routines.dart';
|
||||
import '../../../helpers/pump_app.dart';
|
||||
|
||||
void main() {
|
||||
@@ -40,21 +41,14 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
Log makeLog(num repetitions, num weight, DateTime date) => Log(
|
||||
exerciseId: 1,
|
||||
repetitions: repetitions,
|
||||
weight: weight,
|
||||
date: date,
|
||||
);
|
||||
|
||||
testWidgets('renders a chart with logs', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
createChartScreen({
|
||||
10: [
|
||||
makeLog(10, 100, DateTime(2026, 7, 1)),
|
||||
makeLog(10, 110, DateTime(2026, 7, 8)),
|
||||
makeLog(repetitions: 10, weight: 100, date: DateTime(2026, 7, 1)),
|
||||
makeLog(repetitions: 10, weight: 110, date: DateTime(2026, 7, 8)),
|
||||
],
|
||||
8: [makeLog(8, 120, DateTime(2026, 7, 15))],
|
||||
8: [makeLog(repetitions: 8, weight: 120, date: DateTime(2026, 7, 15))],
|
||||
}),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
@@ -100,10 +94,13 @@ void main() {
|
||||
createChartScreen({
|
||||
// Insertion order decides what `keys.first` and `keys.last` are, and
|
||||
// both of these sit on the same July day
|
||||
10: [makeLog(10, 100, DateTime(2026, 7, 1))],
|
||||
10: [makeLog(repetitions: 10, weight: 100, date: DateTime(2026, 7, 1))],
|
||||
// while the series that spans the axis is neither of them
|
||||
5: [makeLog(5, 140, start), makeLog(5, 150, end)],
|
||||
8: [makeLog(8, 120, DateTime(2026, 7, 1))],
|
||||
5: [
|
||||
makeLog(repetitions: 5, weight: 140, date: start),
|
||||
makeLog(repetitions: 5, weight: 150, date: end),
|
||||
],
|
||||
8: [makeLog(repetitions: 8, weight: 120, date: DateTime(2026, 7, 1))],
|
||||
}),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -147,7 +147,7 @@ void main() {
|
||||
mockRoutinesRepository.editSlotEntryServer(
|
||||
argThat(
|
||||
isA<SlotEntry>()
|
||||
.having((d) => d.id, 'id', null)
|
||||
.having((d) => d.id, 'id', 1)
|
||||
.having((d) => d.slotId, 'slotId', 1)
|
||||
.having((d) => d.order, 'order', 1)
|
||||
.having((d) => d.type, 'type', SlotEntryType.myo)
|
||||
|
||||
@@ -42,33 +42,15 @@ void main() {
|
||||
final benchPress = routine.days[0].slots[0].entries[0].exerciseObj;
|
||||
final sideRaises = routine.days[0].slots[1].entries[0].exerciseObj;
|
||||
|
||||
SlotEntry makeEntry(int slotId, int exerciseId, {required exerciseObj}) {
|
||||
return SlotEntry(
|
||||
slotId: slotId,
|
||||
type: SlotEntryType.normal,
|
||||
order: 1,
|
||||
exerciseId: exerciseId,
|
||||
repetitionUnitId: 1,
|
||||
repetitionRounding: 1,
|
||||
weightUnitId: 1,
|
||||
weightRounding: 1,
|
||||
exercise: exerciseObj,
|
||||
);
|
||||
}
|
||||
|
||||
Slot makeSlot(int id, int order, SlotEntry entry) {
|
||||
final s = Slot.withData(id: id, day: 1, order: order);
|
||||
s.entries.add(entry);
|
||||
return s;
|
||||
}
|
||||
|
||||
test('empty list returns empty map', () {
|
||||
final groups = computeSlotGroups([], 'en');
|
||||
expect(groups, isEmpty);
|
||||
});
|
||||
|
||||
test('single slot is not grouped', () {
|
||||
final slots = [makeSlot(1, 1, makeEntry(1, benchPress.id, exerciseObj: benchPress))];
|
||||
final slots = [
|
||||
makeSlot(id: 1, order: 1, entries: [makeSlotEntry(slotId: 1, exercise: benchPress)]),
|
||||
];
|
||||
final groups = computeSlotGroups(slots, 'en');
|
||||
|
||||
expect(groups[0]!.groupSize, 1);
|
||||
@@ -78,8 +60,8 @@ void main() {
|
||||
|
||||
test('two consecutive same-exercise slots form a group', () {
|
||||
final slots = [
|
||||
makeSlot(1, 1, makeEntry(1, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(2, 2, makeEntry(2, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(id: 1, order: 1, entries: [makeSlotEntry(slotId: 1, exercise: benchPress)]),
|
||||
makeSlot(id: 2, order: 2, entries: [makeSlotEntry(slotId: 2, exercise: benchPress)]),
|
||||
];
|
||||
final groups = computeSlotGroups(slots, 'en');
|
||||
|
||||
@@ -93,8 +75,8 @@ void main() {
|
||||
|
||||
test('different exercises are not grouped', () {
|
||||
final slots = [
|
||||
makeSlot(1, 1, makeEntry(1, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(2, 2, makeEntry(2, sideRaises.id, exerciseObj: sideRaises)),
|
||||
makeSlot(id: 1, order: 1, entries: [makeSlotEntry(slotId: 1, exercise: benchPress)]),
|
||||
makeSlot(id: 2, order: 2, entries: [makeSlotEntry(slotId: 2, exercise: sideRaises)]),
|
||||
];
|
||||
final groups = computeSlotGroups(slots, 'en');
|
||||
|
||||
@@ -105,10 +87,10 @@ void main() {
|
||||
test('only consecutive same-exercise slots are grouped', () {
|
||||
// Bench, Bench, Side raises, Bench → group[2], single, single
|
||||
final slots = [
|
||||
makeSlot(1, 1, makeEntry(1, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(2, 2, makeEntry(2, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(3, 3, makeEntry(3, sideRaises.id, exerciseObj: sideRaises)),
|
||||
makeSlot(4, 4, makeEntry(4, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(id: 1, order: 1, entries: [makeSlotEntry(slotId: 1, exercise: benchPress)]),
|
||||
makeSlot(id: 2, order: 2, entries: [makeSlotEntry(slotId: 2, exercise: benchPress)]),
|
||||
makeSlot(id: 3, order: 3, entries: [makeSlotEntry(slotId: 3, exercise: sideRaises)]),
|
||||
makeSlot(id: 4, order: 4, entries: [makeSlotEntry(slotId: 4, exercise: benchPress)]),
|
||||
];
|
||||
final groups = computeSlotGroups(slots, 'en');
|
||||
|
||||
@@ -119,13 +101,17 @@ void main() {
|
||||
});
|
||||
|
||||
test('superset slots (multiple entries) are never grouped', () {
|
||||
final supersetSlot = Slot.withData(id: 1, day: 1, order: 1);
|
||||
supersetSlot.entries.add(makeEntry(1, benchPress.id, exerciseObj: benchPress));
|
||||
supersetSlot.entries.add(makeEntry(1, sideRaises.id, exerciseObj: sideRaises));
|
||||
final supersetSlot = makeSlot(
|
||||
id: 1,
|
||||
entries: [
|
||||
makeSlotEntry(slotId: 1, exercise: benchPress),
|
||||
makeSlotEntry(slotId: 1, exercise: sideRaises),
|
||||
],
|
||||
);
|
||||
|
||||
final slots = [
|
||||
supersetSlot,
|
||||
makeSlot(2, 2, makeEntry(2, benchPress.id, exerciseObj: benchPress)),
|
||||
makeSlot(id: 2, order: 2, entries: [makeSlotEntry(slotId: 2, exercise: benchPress)]),
|
||||
];
|
||||
final groups = computeSlotGroups(slots, 'en');
|
||||
|
||||
|
||||
@@ -156,37 +156,39 @@ void main() {
|
||||
|
||||
testWidgets('handles null reps/weight without crashing', (tester) async {
|
||||
final notifier = container.read(gymStateProvider.notifier);
|
||||
final routine = testdata.getTestRoutine();
|
||||
routine.dayDataGym = [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 01),
|
||||
label: '',
|
||||
day: routine.dayDataGym.first.day,
|
||||
slots: [
|
||||
SlotData(
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[0].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[0].id,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: null,
|
||||
repetitionsUnit: null,
|
||||
weight: null,
|
||||
weightUnit: null,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
final base = testdata.getTestRoutine();
|
||||
final routine = base.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 01),
|
||||
label: '',
|
||||
day: base.dayDataGym.first.day,
|
||||
slots: [
|
||||
SlotData(
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[0].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[0].id,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: null,
|
||||
repetitionsUnit: null,
|
||||
weight: null,
|
||||
weightUnit: null,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
notifier.initData(routine, routine.days.first.id!, 1);
|
||||
notifier.setCurrentPage(2);
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
import 'package:wger/features/routines/models/day_data.dart';
|
||||
import 'package:wger/features/routines/models/routine.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state_notifier.dart';
|
||||
import 'package:wger/features/routines/widgets/gym_mode/elapsed_time.dart';
|
||||
@@ -29,6 +31,32 @@ import 'package:wger/features/routines/widgets/gym_mode/navigation.dart';
|
||||
import '../../../../../test_data/routines.dart';
|
||||
import '../../../../helpers/pump_app.dart';
|
||||
|
||||
/// The test routine with a third slot on the first gym day, repeating its
|
||||
/// first slot under a slot entry of its own
|
||||
Routine withThirdSlot(Routine routine) {
|
||||
final firstDay = routine.dayDataGym.first;
|
||||
final firstSlot = firstDay.slots.first;
|
||||
return routine.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: firstDay.iteration,
|
||||
date: firstDay.date,
|
||||
day: firstDay.day,
|
||||
slots: [
|
||||
...firstDay.slots,
|
||||
makeSlotData(
|
||||
comment: firstSlot.comment,
|
||||
setConfigs: [
|
||||
for (final config in firstSlot.setConfigs) config.copyWith(slotEntryId: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
...routine.dayDataGym.skip(1),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -77,8 +105,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('continuing from rest skips a completed slot', (tester) async {
|
||||
final routine = getTestRoutine();
|
||||
routine.dayDataGym.first.slots.add(routine.dayDataGym.first.slots.first);
|
||||
final routine = withThirdSlot(getTestRoutine());
|
||||
final notifier = container.read(gymStateProvider.notifier);
|
||||
notifier.initData(routine, routine.days.first.id!, 1);
|
||||
final slots = notifier.state.pages.where((p) => p.type == PageType.set).toList();
|
||||
|
||||
@@ -23,7 +23,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
import 'package:wger/features/routines/models/day_data.dart';
|
||||
import 'package:wger/features/routines/models/page_progress.dart';
|
||||
import 'package:wger/features/routines/models/routine.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state.dart';
|
||||
import 'package:wger/features/routines/providers/gym_state_notifier.dart';
|
||||
import 'package:wger/features/routines/widgets/gym_mode/timer.dart';
|
||||
@@ -31,6 +33,32 @@ import 'package:wger/features/routines/widgets/gym_mode/timer.dart';
|
||||
import '../../../../../test_data/routines.dart' as testdata;
|
||||
import '../../../../helpers/pump_app.dart';
|
||||
|
||||
/// The test routine with a third slot on the first gym day, repeating its
|
||||
/// first slot under a slot entry of its own
|
||||
Routine withThirdSlot(Routine routine) {
|
||||
final firstDay = routine.dayDataGym.first;
|
||||
final firstSlot = firstDay.slots.first;
|
||||
return routine.copyWith(
|
||||
dayDataGym: [
|
||||
DayData(
|
||||
iteration: firstDay.iteration,
|
||||
date: firstDay.date,
|
||||
day: firstDay.day,
|
||||
slots: [
|
||||
...firstDay.slots,
|
||||
testdata.makeSlotData(
|
||||
comment: firstSlot.comment,
|
||||
setConfigs: [
|
||||
for (final config in firstSlot.setConfigs) config.copyWith(slotEntryId: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
...routine.dayDataGym.skip(1),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -107,9 +135,7 @@ void main() {
|
||||
|
||||
for (final countsUp in [false, true]) {
|
||||
testWidgets('up next skips a completed slot (countsUp=$countsUp)', (tester) async {
|
||||
final routine = testdata.getTestRoutine();
|
||||
// Repeat the first exercise as a third, distinct slot without changing shared fixtures.
|
||||
routine.dayDataGym.first.slots.add(routine.dayDataGym.first.slots.first);
|
||||
final routine = withThirdSlot(testdata.getTestRoutine());
|
||||
final notifier = container.read(gymStateProvider.notifier);
|
||||
notifier.initData(routine, routine.days.first.id!, 1);
|
||||
notifier.calculatePages();
|
||||
|
||||
@@ -40,53 +40,189 @@ const RepetitionUnit testRepetitionUnit1 = RepetitionUnit(id: 1, name: 'Repetiti
|
||||
const RepetitionUnit testRepetitionUnit2 = RepetitionUnit(id: 2, name: 'Hours');
|
||||
const testRepetitionUnits = [testRepetitionUnit1, testRepetitionUnit2];
|
||||
|
||||
// Builders for the routine models. Every parameter has a default, so a test
|
||||
// names only the values it is about. Structural variants (a superset, a rest
|
||||
// day, an extra slot) are built with these in the test itself instead of
|
||||
// mutating what getTestRoutine() returns.
|
||||
|
||||
SetConfigData makeSetConfig({
|
||||
required Exercise exercise,
|
||||
int slotEntryId = 1,
|
||||
SlotEntryType type = SlotEntryType.normal,
|
||||
num? nrOfSets = 1,
|
||||
num? repetitions = 10,
|
||||
num? weight = 50,
|
||||
num? rir,
|
||||
num? rpe,
|
||||
num? restTime,
|
||||
String textRepr = '',
|
||||
WeightUnit weightUnit = testWeightUnit1,
|
||||
RepetitionUnit repetitionsUnit = testRepetitionUnit1,
|
||||
}) {
|
||||
return SetConfigData(
|
||||
exerciseId: exercise.id,
|
||||
exercise: exercise,
|
||||
slotEntryId: slotEntryId,
|
||||
type: type,
|
||||
nrOfSets: nrOfSets,
|
||||
repetitions: repetitions,
|
||||
repetitionsUnit: repetitionsUnit,
|
||||
weight: weight,
|
||||
weightUnit: weightUnit,
|
||||
restTime: restTime,
|
||||
rir: rir,
|
||||
rpe: rpe,
|
||||
textRepr: textRepr,
|
||||
);
|
||||
}
|
||||
|
||||
/// A slot of a [DayData]; the exercise ids follow from [setConfigs].
|
||||
SlotData makeSlotData({
|
||||
required List<SetConfigData> setConfigs,
|
||||
String comment = '',
|
||||
bool isSuperset = false,
|
||||
}) {
|
||||
return SlotData(
|
||||
comment: comment,
|
||||
isSuperset: isSuperset,
|
||||
exerciseIds: setConfigs.map((config) => config.exerciseId).toSet().toList(),
|
||||
setConfigs: setConfigs,
|
||||
);
|
||||
}
|
||||
|
||||
/// A slot entry whose sets, repetitions and weight are set for the first
|
||||
/// iteration; pass [weightConfigs] for a progression.
|
||||
SlotEntry makeSlotEntry({
|
||||
required Exercise exercise,
|
||||
int? id,
|
||||
int slotId = 1,
|
||||
int order = 1,
|
||||
SlotEntryType type = SlotEntryType.normal,
|
||||
num nrOfSets = 3,
|
||||
num repetitions = 10,
|
||||
num weight = 50,
|
||||
List<BaseConfig>? weightConfigs,
|
||||
num repetitionRounding = 1,
|
||||
num weightRounding = 1.25,
|
||||
String comment = '',
|
||||
}) {
|
||||
final configId = id ?? 1;
|
||||
return SlotEntry(
|
||||
id: id,
|
||||
slotId: slotId,
|
||||
type: type,
|
||||
order: order,
|
||||
exerciseId: exercise.id,
|
||||
repetitionUnitId: testRepetitionUnit1.id,
|
||||
repetitionRounding: repetitionRounding,
|
||||
weightUnitId: testWeightUnit1.id,
|
||||
weightRounding: weightRounding,
|
||||
comment: comment,
|
||||
repetitionUnit: testRepetitionUnit1,
|
||||
weightUnit: testWeightUnit1,
|
||||
exercise: exercise,
|
||||
nrOfSetsConfigs: [BaseConfig.firstIteration(nrOfSets, configId)],
|
||||
repetitionsConfigs: [BaseConfig.firstIteration(repetitions, configId)],
|
||||
weightConfigs: weightConfigs ?? [BaseConfig.firstIteration(weight, configId)],
|
||||
);
|
||||
}
|
||||
|
||||
/// A slot holding [entries], with their exercises attached.
|
||||
Slot makeSlot({
|
||||
required List<SlotEntry> entries,
|
||||
int? id,
|
||||
int day = 1,
|
||||
int order = 1,
|
||||
String comment = '',
|
||||
}) {
|
||||
return Slot.withData(
|
||||
id: id,
|
||||
day: day,
|
||||
order: order,
|
||||
comment: comment,
|
||||
exercises: entries.map((entry) => entry.exerciseObj).toList(),
|
||||
entries: entries,
|
||||
);
|
||||
}
|
||||
|
||||
Log makeLog({
|
||||
String? id,
|
||||
Exercise? exercise,
|
||||
int exerciseId = 1,
|
||||
int? routineId = 100,
|
||||
String? sessionId,
|
||||
int? slotEntryId,
|
||||
int? iteration,
|
||||
num? repetitions = 10,
|
||||
int repetitionsUnitId = 1,
|
||||
num? weight = 50,
|
||||
int weightUnitId = 1,
|
||||
num? rir,
|
||||
DateTime? date,
|
||||
}) {
|
||||
final log = Log(
|
||||
id: id,
|
||||
exerciseId: exercise?.id ?? exerciseId,
|
||||
routineId: routineId,
|
||||
sessionId: sessionId,
|
||||
slotEntryId: slotEntryId,
|
||||
iteration: iteration,
|
||||
repetitions: repetitions,
|
||||
repetitionsUnitId: repetitionsUnitId,
|
||||
weight: weight,
|
||||
weightUnitId: weightUnitId,
|
||||
rir: rir,
|
||||
date: date ?? DateTime.utc(2026, 4, 15, 10, 30),
|
||||
);
|
||||
if (exercise != null) {
|
||||
log.exercise = exercise;
|
||||
log.weightUnit = testWeightUnit1;
|
||||
log.repetitionUnit = testRepetitionUnit1;
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
final testExercises = exercises ?? getTestExercises();
|
||||
final benchPress = testExercises[0];
|
||||
final crunches = testExercises[1];
|
||||
final squats = testExercises[4];
|
||||
final sideRaises = testExercises[5];
|
||||
|
||||
final log1 = Log(
|
||||
final log1 = makeLog(
|
||||
id: '1',
|
||||
exerciseId: 1,
|
||||
exercise: benchPress,
|
||||
routineId: 1,
|
||||
sessionId: '1',
|
||||
iteration: 2,
|
||||
slotEntryId: 3,
|
||||
slotEntryId: 1,
|
||||
weight: 10,
|
||||
rir: 1.5,
|
||||
date: DateTime(2021, 5, 1),
|
||||
repetitions: 10,
|
||||
routineId: 1,
|
||||
);
|
||||
log1.exercise = testExercises[0];
|
||||
log1.weightUnit = testWeightUnit1;
|
||||
log1.repetitionUnit = testRepetitionUnit1;
|
||||
|
||||
final log2 = Log(
|
||||
final log2 = makeLog(
|
||||
id: '2',
|
||||
exerciseId: 1,
|
||||
exercise: benchPress,
|
||||
routineId: 1,
|
||||
sessionId: '1',
|
||||
iteration: 4,
|
||||
slotEntryId: 1,
|
||||
weight: 10,
|
||||
rir: 2,
|
||||
date: DateTime(2021, 5, 1),
|
||||
repetitions: 12,
|
||||
routineId: 1,
|
||||
);
|
||||
log2.exercise = testExercises[0];
|
||||
log2.weightUnit = testWeightUnit1;
|
||||
log2.repetitionUnit = testRepetitionUnit1;
|
||||
|
||||
final log3 = Log(
|
||||
final log3 = makeLog(
|
||||
id: '3',
|
||||
exerciseId: 2,
|
||||
exercise: crunches,
|
||||
routineId: 1,
|
||||
sessionId: '2',
|
||||
iteration: 5,
|
||||
slotEntryId: 1,
|
||||
weight: 50,
|
||||
rir: null,
|
||||
date: DateTime(2021, 5, 2),
|
||||
repetitions: 8,
|
||||
routineId: 1,
|
||||
);
|
||||
log3.exercise = testExercises[1];
|
||||
log3.weightUnit = testWeightUnit1;
|
||||
log3.repetitionUnit = testRepetitionUnit1;
|
||||
|
||||
final session1 = WorkoutSession(
|
||||
id: '1',
|
||||
@@ -108,84 +244,68 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
logs: [log3],
|
||||
);
|
||||
|
||||
final slotEntryBenchPress = SlotEntry(
|
||||
slotId: 1,
|
||||
type: SlotEntryType.normal,
|
||||
order: 1,
|
||||
exerciseId: 1,
|
||||
repetitionUnitId: 1,
|
||||
repetitionRounding: 1,
|
||||
weightUnitId: 1,
|
||||
weightRounding: 1.25,
|
||||
comment: 'ddd',
|
||||
repetitionUnit: testRepetitionUnit1,
|
||||
weightUnit: testWeightUnit1,
|
||||
exercise: testExercises[0],
|
||||
nrOfSetsConfigs: [BaseConfig.firstIteration(4, 1)],
|
||||
repetitionsConfigs: [BaseConfig.firstIteration(3, 1)],
|
||||
weightConfigs: [
|
||||
BaseConfig.firstIteration(100, 1),
|
||||
BaseConfig(
|
||||
final slotBenchPress = makeSlot(
|
||||
id: 1,
|
||||
comment: 'Make sure to warm up',
|
||||
entries: [
|
||||
makeSlotEntry(
|
||||
id: 1,
|
||||
slotEntryId: 1,
|
||||
iteration: 2,
|
||||
value: 5,
|
||||
operation: '+',
|
||||
step: 'abs',
|
||||
requirements: null,
|
||||
repeat: true,
|
||||
exercise: benchPress,
|
||||
slotId: 1,
|
||||
nrOfSets: 4,
|
||||
repetitions: 3,
|
||||
weightConfigs: [
|
||||
BaseConfig.firstIteration(100, 1),
|
||||
BaseConfig(
|
||||
id: 1,
|
||||
slotEntryId: 1,
|
||||
iteration: 2,
|
||||
value: 5,
|
||||
operation: '+',
|
||||
step: 'abs',
|
||||
requirements: null,
|
||||
repeat: true,
|
||||
),
|
||||
],
|
||||
comment: 'ddd',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final slotBenchPress = Slot.withData(id: 1, day: 1, order: 1, comment: 'Make sure to warm up');
|
||||
slotBenchPress.addExerciseBase(testExercises[0]);
|
||||
slotBenchPress.entries.add(slotEntryBenchPress);
|
||||
|
||||
final slotEntrySquat = SlotEntry(
|
||||
slotId: 2,
|
||||
type: SlotEntryType.normal,
|
||||
order: 1,
|
||||
exerciseId: testExercises[4].id,
|
||||
repetitionUnitId: 1,
|
||||
repetitionRounding: 0.25,
|
||||
weightUnitId: 1,
|
||||
weightRounding: 0.25,
|
||||
comment: 'ddd',
|
||||
repetitionUnit: testRepetitionUnit1,
|
||||
weightUnit: testWeightUnit1,
|
||||
exercise: testExercises[4],
|
||||
weightConfigs: [BaseConfig.firstIteration(80, 1)],
|
||||
repetitionsConfigs: [BaseConfig.firstIteration(5, 1)],
|
||||
nrOfSetsConfigs: [BaseConfig.firstIteration(3, 1)],
|
||||
final slotSquat = makeSlot(
|
||||
id: 2,
|
||||
entries: [
|
||||
makeSlotEntry(
|
||||
id: 2,
|
||||
exercise: squats,
|
||||
slotId: 2,
|
||||
nrOfSets: 3,
|
||||
repetitions: 5,
|
||||
weight: 80,
|
||||
repetitionRounding: 0.25,
|
||||
weightRounding: 0.25,
|
||||
comment: 'ddd',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final slotSquat = Slot.withData(id: 2, day: 1, order: 1);
|
||||
slotSquat.addExerciseBase(testExercises[4]);
|
||||
slotSquat.entries.add(slotEntrySquat);
|
||||
|
||||
final slotEntrySideRaises = SlotEntry(
|
||||
slotId: 2,
|
||||
type: SlotEntryType.normal,
|
||||
order: 1,
|
||||
exerciseId: testExercises[5].id,
|
||||
repetitionUnitId: 1,
|
||||
repetitionRounding: 0.25,
|
||||
weightUnitId: 1,
|
||||
weightRounding: 0.25,
|
||||
comment: 'ddd',
|
||||
repetitionUnit: testRepetitionUnit1,
|
||||
weightUnit: testWeightUnit1,
|
||||
exercise: testExercises[5],
|
||||
nrOfSetsConfigs: [BaseConfig.firstIteration(4, 1)],
|
||||
repetitionsConfigs: [BaseConfig.firstIteration(12, 1)],
|
||||
weightConfigs: [BaseConfig.firstIteration(10, 1)],
|
||||
final slotSideRaises = makeSlot(
|
||||
id: 3,
|
||||
order: 2,
|
||||
entries: [
|
||||
makeSlotEntry(
|
||||
id: 3,
|
||||
exercise: sideRaises,
|
||||
slotId: 3,
|
||||
nrOfSets: 4,
|
||||
repetitions: 12,
|
||||
weight: 10,
|
||||
repetitionRounding: 0.25,
|
||||
weightRounding: 0.25,
|
||||
comment: 'ddd',
|
||||
),
|
||||
],
|
||||
);
|
||||
// settingSideRaises.weight = 6;
|
||||
|
||||
final slotSideRaises = Slot.withData(id: 3, day: 1, order: 1);
|
||||
slotSideRaises.addExerciseBase(testExercises[5]);
|
||||
slotSideRaises.entries.add(slotEntrySideRaises);
|
||||
|
||||
final dayChestShoulders = Day(
|
||||
id: 1,
|
||||
@@ -203,167 +323,62 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
slots: [slotSquat],
|
||||
);
|
||||
|
||||
// Gym mode gets one config per set, the overview one per exercise
|
||||
List<SetConfigData> sets(SetConfigData Function() config) => List.generate(3, (_) => config());
|
||||
|
||||
final List<DayData> dayDataGym = [
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 01),
|
||||
label: '',
|
||||
day: dayChestShoulders,
|
||||
slots: [
|
||||
SlotData(
|
||||
makeSlotData(
|
||||
comment: 'Make sure to warm up',
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[0].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: 1,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
setConfigs: sets(
|
||||
() => makeSetConfig(
|
||||
exercise: benchPress,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[0].id,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[0].id,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SlotData(
|
||||
makeSlotData(
|
||||
comment: 'Side rises',
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[5].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[5].id,
|
||||
exercise: testExercises[5],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
setConfigs: sets(
|
||||
() => makeSetConfig(
|
||||
exercise: sideRaises,
|
||||
slotEntryId: 3,
|
||||
repetitions: 12,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 10,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: null,
|
||||
rir: null,
|
||||
rpe: null,
|
||||
textRepr: '12x10kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[5].id,
|
||||
exercise: testExercises[5],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 12,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 10,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: null,
|
||||
rir: null,
|
||||
rpe: null,
|
||||
textRepr: '12x10kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[5].id,
|
||||
exercise: testExercises[5],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 12,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 10,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: null,
|
||||
rir: null,
|
||||
rpe: null,
|
||||
textRepr: '12x10kg',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 02),
|
||||
label: '',
|
||||
day: dayLegs,
|
||||
slots: [
|
||||
SlotData(
|
||||
makeSlotData(
|
||||
comment: 'Squats',
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[4].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[4].id,
|
||||
exercise: testExercises[4],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
setConfigs: sets(
|
||||
() => makeSetConfig(
|
||||
exercise: squats,
|
||||
slotEntryId: 2,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[4].id,
|
||||
exercise: testExercises[4],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[4].id,
|
||||
exercise: testExercises[4],
|
||||
slotEntryId: 1,
|
||||
nrOfSets: 1,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
textRepr: '3x100kg',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -373,23 +388,15 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 01),
|
||||
label: '',
|
||||
day: dayChestShoulders,
|
||||
slots: [
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [1],
|
||||
makeSlotData(
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: 1,
|
||||
exercise: testExercises[0],
|
||||
slotEntryId: 1,
|
||||
makeSetConfig(
|
||||
exercise: benchPress,
|
||||
nrOfSets: 4,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
@@ -397,23 +404,15 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
),
|
||||
],
|
||||
),
|
||||
SlotData(
|
||||
comment: '',
|
||||
isSuperset: false,
|
||||
exerciseIds: [6],
|
||||
makeSlotData(
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: 6,
|
||||
exercise: testExercises[5],
|
||||
slotEntryId: 1,
|
||||
makeSetConfig(
|
||||
exercise: sideRaises,
|
||||
slotEntryId: 3,
|
||||
nrOfSets: 4,
|
||||
repetitions: 12,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 10,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 60,
|
||||
rir: null,
|
||||
rpe: null,
|
||||
textRepr: '4 sets 12x10kg',
|
||||
),
|
||||
],
|
||||
@@ -423,23 +422,17 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 02),
|
||||
label: '',
|
||||
day: dayLegs,
|
||||
slots: [
|
||||
SlotData(
|
||||
makeSlotData(
|
||||
comment: 'Make sure to go deep. Slow down, and push through your heels',
|
||||
isSuperset: false,
|
||||
exerciseIds: [testExercises[4].id],
|
||||
setConfigs: [
|
||||
SetConfigData(
|
||||
exerciseId: testExercises[4].id,
|
||||
exercise: testExercises[4],
|
||||
slotEntryId: 1,
|
||||
makeSetConfig(
|
||||
exercise: squats,
|
||||
slotEntryId: 2,
|
||||
nrOfSets: 4,
|
||||
repetitions: 3,
|
||||
repetitionsUnit: testRepetitionUnit1,
|
||||
weight: 100,
|
||||
weightUnit: testWeightUnit1,
|
||||
restTime: 120,
|
||||
rir: 1.5,
|
||||
rpe: 8,
|
||||
@@ -449,23 +442,17 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
),
|
||||
],
|
||||
),
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 02),
|
||||
label: 'null day (filled because of fitInWeek flag)',
|
||||
day: null,
|
||||
slots: [],
|
||||
),
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 02),
|
||||
label: 'null day (filled because of fitInWeek flag)',
|
||||
day: null,
|
||||
slots: [],
|
||||
),
|
||||
for (var i = 0; i < 2; i++)
|
||||
DayData(
|
||||
iteration: 1,
|
||||
date: DateTime(2024, 11, 02),
|
||||
label: 'null day (filled because of fitInWeek flag)',
|
||||
day: null,
|
||||
slots: [],
|
||||
),
|
||||
];
|
||||
|
||||
final routine = Routine(
|
||||
return Routine(
|
||||
id: 1,
|
||||
created: DateTime(2021, 01, 01),
|
||||
name: '3 day workout',
|
||||
@@ -480,6 +467,4 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
dayDataGym: dayDataGym,
|
||||
isHydrated: true,
|
||||
);
|
||||
|
||||
return routine;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user