fix(execution): corrige la reprise de seance affichant a tort Seance Terminee (#192)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
@ -88,6 +89,60 @@ void main() {
|
||||
expect(repository.session?.status, ActiveWorkoutStatus.abandoned);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'une séance sauvegardée est reprise sans afficher un faux état terminé',
|
||||
(tester) async {
|
||||
final clock = _FakeClock(DateTime.utc(2026, 7, 17, 12, 0, 15));
|
||||
final resumeGate = Completer<void>();
|
||||
final repository = _FakeActiveSessionRepository()
|
||||
..findByIdBlocker = resumeGate.future;
|
||||
final session = ActiveWorkoutSession(
|
||||
metadata: _metadata('session-1'),
|
||||
sourceWorkoutTemplateId: 'template-1',
|
||||
status: ActiveWorkoutStatus.savedExit,
|
||||
startedAt: DateTime.utc(2026, 7, 17, 11, 59),
|
||||
lastPersistedAt: DateTime.utc(2026, 7, 17, 12),
|
||||
elapsedActiveMs: 30000,
|
||||
currentProgramIndex: 0,
|
||||
currentExerciseIndex: 0,
|
||||
currentSetIndex: 0,
|
||||
resolvedTemplateSnapshotJson: _sessionSnapshot(),
|
||||
);
|
||||
repository.session = session;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: WorkoutExecutionScreen(
|
||||
initialSession: session,
|
||||
activeUseCases: _activeUseCases(repository, clock),
|
||||
closeUseCase: _closeUseCase(repository, clock),
|
||||
historyUseCases: _historyUseCases(clock),
|
||||
workoutTemplateUseCases: _workoutTemplateUseCases(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Reprise de la séance...'), findsOneWidget);
|
||||
expect(find.text('Pause'), findsNothing);
|
||||
expect(find.text('Séance terminée'), findsNothing);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
|
||||
expect(find.text('Reprise de la séance...'), findsOneWidget);
|
||||
expect(find.text('Séance terminée'), findsNothing);
|
||||
expect(repository.session?.status, ActiveWorkoutStatus.savedExit);
|
||||
|
||||
resumeGate.complete();
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(repository.session?.status, ActiveWorkoutStatus.running);
|
||||
expect(find.text('Squat'), findsOneWidget);
|
||||
expect(find.text('Séance terminée'), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('les répétitions sont initialisées avec la cible', (
|
||||
tester,
|
||||
) async {
|
||||
@ -2678,6 +2733,7 @@ final class _FakeExercisePerformanceReferenceRepository
|
||||
|
||||
final class _FakeActiveSessionRepository implements ActiveSessionRepository {
|
||||
ActiveWorkoutSession? session;
|
||||
Future<void>? findByIdBlocker;
|
||||
final results = <ActiveSetResult>[];
|
||||
final restStates = <ActiveRestState>[];
|
||||
final scoreStopwatchStates = <ActiveScoreStopwatchState>[];
|
||||
@ -2688,6 +2744,7 @@ final class _FakeActiveSessionRepository implements ActiveSessionRepository {
|
||||
|
||||
@override
|
||||
Future<ActiveWorkoutSession?> findById(String id) async {
|
||||
await findByIdBlocker;
|
||||
return session?.metadata.id == id ? session : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user