feat(train): Profile opens on your body, the last 12 weeks and this year (ADR 0030, D60)

Above the days: a card with your body's weight and resting and maximal
heart rate, tapped opening Your body; the last 12 weeks' time trained as
bars, a week tapped showing its time, distance and workouts; and this
calendar year by activity. Home's week card reads its time as the days do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-31 18:46:26 +01:00
commit 5cfab59bd2
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -109,4 +109,84 @@ void main() {
expect(week.longestDay, const Duration(hours: 1));
});
group('the weeks Profile shows (D60)', () {
test('twelve, oldest first, the last this one', () {
final weeks = weeksBack(
[
workout(DateTime(2026, 10, 27, 7), moving: const Duration(hours: 1)),
workout(DateTime(2026, 8, 12, 7), moving: const Duration(hours: 2)),
// Thirteen weeks back: out.
workout(DateTime(2026, 7, 29, 7)),
],
now: now,
firstDay: DateTime.monday,
);
expect(weeks, hasLength(12));
expect(weeks.last.start, DateTime(2026, 10, 26));
expect(weeks.first.start, DateTime(2026, 8, 10));
expect(weeks.last.time, const Duration(hours: 1));
expect(weeks.first.time, const Duration(hours: 2));
expect(weeks.map((week) => week.count).reduce((a, b) => a + b), 2);
});
test('by the calendar across a change of the clocks', () {
// Clocks went back on 25 October 2026 in Europe.
final weeks = weeksBack(
const [],
now: now,
firstDay: DateTime.monday,
);
for (final week in weeks) {
expect(week.start.weekday, DateTime.monday);
expect(week.start.hour, 0);
}
});
});
group('the year Profile shows (D60)', () {
test('per activity, the most trained first, this calendar year alone', () {
final year = yearSummary([
workout(
DateTime(2026, 3, 1, 7),
moving: const Duration(hours: 1),
metres: 10000,
),
workout(
DateTime(2026, 10, 30, 7),
moving: const Duration(hours: 1),
metres: 12000,
),
WorkoutContent(
activity: Activity.cycling,
startedAt: DateTime(2026, 6, 1, 9).toUtc(),
endedAt: DateTime(2026, 6, 1, 12).toUtc(),
distanceMetres: 80000,
),
// Last year's.
workout(DateTime(2025, 12, 31, 20), metres: 5000),
], now: now);
expect(year.year, 2026);
expect(year.activities, [
(
activity: Activity.cycling,
count: 1,
time: const Duration(hours: 3),
metres: 80000,
),
(
activity: Activity.running,
count: 2,
time: const Duration(hours: 2),
metres: 22000,
),
]);
});
test('a year without workouts lists none', () {
expect(yearSummary(const [], now: now).activities, isEmpty);
});
});
}