feat(app): the home dashboard's data: activity, streak, goal, layout

What the dashboard shows, worked out from this device's data: cards
rated (crammed included, fresh starts not) and cards written per local
day; the streak, up to today or yesterday, rest days counting; the cards
falling due per day, but those resting in archived studysets; the study
goal's progress in its day or week. The goal, the rest days and the
dashboard's arrangement live in the synced settings (payload schema 3).
Cards tell when they were made by their UUID v7 ids; reviews report
their changes.

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-01 21:59:52 +02:00
commit d846ee4582
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -1,5 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_learn_flutter/src/core/content/payload.dart';
import 'package:halkyon_learn_flutter/src/feature/home/model/home_layout.dart';
import 'package:halkyon_learn_flutter/src/feature/home/model/study_goal.dart';
import 'package:halkyon_learn_flutter/src/feature/settings/data/settings_payload.dart';
import 'package:halkyon_learn_flutter/src/feature/settings/model/person_settings.dart';
import 'package:halkyon_learn_flutter/src/feature/study/model/study_options.dart';
@ -95,4 +97,50 @@ void main() {
StudyOrder.newestFirst,
);
});
test('the goal, rest days and home layout survive a round trip', () {
final settings = PersonSettings(
goal: const StudyGoal(period: GoalPeriod.week, target: 150),
restDays: {DateTime(2026, 10, 5), DateTime(2026, 12, 24)},
home: const HomeLayout(
order: [HomeWidget.activity, HomeWidget.goal, HomeWidget.week],
hidden: {HomeWidget.week},
),
);
expect(decodeSettingsPayload(encodeSettingsPayload(settings)), settings);
});
test('a home layout from another version keeps the widgets this one '
'knows, and adds those it misses', () {
final settings = decodeSettingsPayload(
encodePayload(3, {
'studyTags': {},
'home': {
'order': ['activity', 'pomodoro'],
'hidden': ['pomodoro'],
},
}),
);
expect(settings.home.order, [
HomeWidget.activity,
HomeWidget.goal,
HomeWidget.week,
]);
expect(settings.home.hidden, isEmpty);
});
test('folding keeps both rest days, and the goal one of them has', () {
final mine = PersonSettings(restDays: {DateTime(2026, 10, 5)});
final theirs = PersonSettings(
goal: const StudyGoal(period: GoalPeriod.day, target: 20),
restDays: {DateTime(2026, 10, 6)},
);
final folded = mine.foldedWith(theirs);
expect(folded.restDays, {DateTime(2026, 10, 5), DateTime(2026, 10, 6)});
expect(folded.goal, theirs.goal);
});
}