feat(ui): affichage du chrono de score dans le plan et l'historique (ticket #28)

Affiche le chrono du score chronométré sur workout_execution_screen.dart
(plan de séance) et history_screen.dart (historique). flutter analyze
propre, 77/77 tests verts, build APK debug validé. Dernier ticket du
backlog — clôture aussi le ticket parent #18 (score chronométré).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-18 14:40:37 +02:00
parent a1b27fdcbc
commit 1a315d586f
4 changed files with 202 additions and 13 deletions

View File

@ -50,6 +50,31 @@ void main() {
);
});
testWidgets('le détail affiche le score chrono comme temps réalisé', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: HistoryDetailScreen(
history: _history(id: 'history-1', stopwatchScore: true),
historyUseCases: _historyUseCases(_FakeWorkoutHistoryRepository()),
workoutTemplateUseCases: _workoutTemplateUseCases(),
activeUseCases: _activeUseCases(),
closeUseCase: _closeUseCase(),
),
),
);
expect(
find.text(
'Temps 00:45 · 10 répétitions · '
'Temps réalisé : 00:38.7 / objectif 00:45',
),
findsOneWidget,
);
expect(find.textContaining('Score 38.7'), findsNothing);
});
testWidgets('la suppression demande une confirmation', (tester) async {
final repository = _FakeWorkoutHistoryRepository();
@ -85,7 +110,11 @@ void main() {
});
}
WorkoutHistory _history({required String id, DateTime? startedAt}) {
WorkoutHistory _history({
required String id,
DateTime? startedAt,
bool stopwatchScore = false,
}) {
final start = startedAt ?? DateTime.utc(2026, 7, 17, 10);
return WorkoutHistory(
metadata: _metadata(id),
@ -98,7 +127,9 @@ WorkoutHistory _history({required String id, DateTime? startedAt}) {
completed: true,
historySnapshotJson: jsonEncode({
'sessionId': 'session-1',
'resolvedTemplateSnapshotJson': _resolvedSnapshot(),
'resolvedTemplateSnapshotJson': _resolvedSnapshot(
stopwatchScore: stopwatchScore,
),
'results': [
{
'programSnapshotId': 'program-snapshot-1',
@ -108,16 +139,21 @@ WorkoutHistory _history({required String id, DateTime? startedAt}) {
'setIndex': 0,
'actualTimeMs': 45000,
'actualReps': 10,
'actualScore': 80,
if (stopwatchScore) 'actualScoreTimeMs': 38700,
if (!stopwatchScore) 'actualScore': 80,
'scoreLabelSnapshot': 'Charge',
'scoreUnitSnapshot': 'kg',
'scoreInputModeSnapshot': stopwatchScore
? ScoreInputMode.stopwatch.name
: ScoreInputMode.manual.name,
if (!stopwatchScore) 'scoreUnitSnapshot': 'kg',
if (stopwatchScore) 'targetScoreTimeMsSnapshot': 45000,
},
],
}),
);
}
String _resolvedSnapshot() {
String _resolvedSnapshot({bool stopwatchScore = false}) {
return jsonEncode({
'name': 'Séance jambes',
'programs': [
@ -135,9 +171,13 @@ String _resolvedSnapshot() {
'scoreEnabled': true,
'targetTimeSeconds': 45,
'targetReps': 10,
'targetScore': 80,
if (stopwatchScore) 'targetScoreTimeMs': 45000,
if (!stopwatchScore) 'targetScore': 80,
'scoreInputModeSnapshot': stopwatchScore
? ScoreInputMode.stopwatch.name
: ScoreInputMode.manual.name,
'scoreLabelSnapshot': 'Charge',
'scoreUnitSnapshot': 'kg',
if (!stopwatchScore) 'scoreUnitSnapshot': 'kg',
'restSecondsOverride': 0,
},
],