fix(core): fusionne la strategie Health Services au niveau seance et nullifie sourceExerciseId au pull si absent

Complement #183 : fusion de la strategie Health Services au niveau seance pour eviter que le premier exercice fige tout le choix de strategie sur la seance.
Fix #185 : nullification defensive de sourceExerciseId au pull quand l'exercice source est absent, pour ne plus casser le chargement des programmes apres suppression d'un exercice.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-30 17:12:03 +02:00
parent c43b93ef99
commit 326bd1893c
4 changed files with 249 additions and 32 deletions

View File

@ -54,28 +54,27 @@ void main() {
expect(projection.dominantTimer, isNull);
});
test(
'projects Health Services exercise type strategy from snapshot',
() async {
final repository = _FakeActiveSessionRepository()
..session = _session(
healthServicesExerciseTypeStrategy: const [
'RUNNING',
'HIGH_INTENSITY_INTERVAL_TRAINING',
'WORKOUT',
],
);
final projector = _projector(repository, _clock());
test('projects session-level Health Services exercise strategy', () async {
final repository = _FakeActiveSessionRepository()
..session = _session(
healthServicesExerciseTypeStrategy: const ['WORKOUT'],
secondExerciseName: 'Dribble',
secondExerciseHealthServicesExerciseTypeStrategy: const [
'RUNNING',
'HIGH_INTENSITY_INTERVAL_TRAINING',
'WORKOUT',
],
);
final projector = _projector(repository, _clock());
final projection = await projector.project(revision: 1);
final projection = await projector.project(revision: 1);
expect(projection.healthServicesExerciseTypeStrategy, [
'RUNNING',
'HIGH_INTENSITY_INTERVAL_TRAINING',
'WORKOUT',
]);
},
);
expect(projection.healthServicesExerciseTypeStrategy, [
'WORKOUT',
'RUNNING',
'HIGH_INTENSITY_INTERVAL_TRAINING',
]);
});
test('projects running with step timer before stopwatch score', () async {
final now = DateTime.utc(2026, 7, 25, 12);
@ -611,6 +610,7 @@ ActiveWorkoutSession _session({
List<ExerciseStep> steps = const [],
String? secondExerciseName,
List<String> healthServicesExerciseTypeStrategy = const [],
List<String> secondExerciseHealthServicesExerciseTypeStrategy = const [],
}) {
final exerciseSnapshot = {
'id': 'exercise-snapshot-1',
@ -642,6 +642,8 @@ ActiveWorkoutSession _session({
'scoreInputModeSnapshot': ScoreInputMode.manual.name,
'exerciseStepsSnapshot': const [],
'autoStartNextTimedStepSnapshot': true,
'healthServicesExerciseTypeStrategy':
secondExerciseHealthServicesExerciseTypeStrategy,
};
return ActiveWorkoutSession(
metadata: _metadata('session-1'),