[Developer] #204 Phase 1 MVP — Flutter app skeleton complete
- Drift 21 tables (8 catalog + 11 user + habit_dose_variants + meta_kv) with R1~R10 CHECK constraints and 19 indexes - 8 hand-crafted seed JSON catalogs in app/assets/seed/ (refs 84, protocols 34, methodologies 21, frame_patterns 30, reward_menu_items 30, break_protocols 8, common_frames 5, diet_patterns 5) - 6 domain functions: recommend_variant, compute_streak, validate_frame_level, active_habit_quota, weekly_minimum_ratio, seed_importer (transactional, idempotent) - 4 vertical-slice Riverpod screens: HabitList, HabitCreate, CheckIn, Streak - 31 unit tests passing; flutter analyze clean - OQ-5 streak semantics: missing entry ≠ explicit blank (missing = end of history; only TrackerValue.blank triggers Never-miss-twice) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
38
app/test/domain/rules/active_habit_quota_test.dart
Normal file
38
app/test/domain/rules/active_habit_quota_test.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:life_helper/domain/models/habit.dart';
|
||||
import 'package:life_helper/domain/rules/active_habit_quota.dart';
|
||||
|
||||
void main() {
|
||||
test('build allows up to 3', () {
|
||||
expect(
|
||||
judgeActiveHabitQuota(type: HabitType.build, currentActiveCount: 2).allowed,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
judgeActiveHabitQuota(type: HabitType.build, currentActiveCount: 3).allowed,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('break allows only 1', () {
|
||||
expect(
|
||||
judgeActiveHabitQuota(type: HabitType.breakHabit, currentActiveCount: 0)
|
||||
.allowed,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
judgeActiveHabitQuota(type: HabitType.breakHabit, currentActiveCount: 1)
|
||||
.allowed,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('reason describes the limit when blocked', () {
|
||||
final r = judgeActiveHabitQuota(
|
||||
type: HabitType.build, currentActiveCount: 3);
|
||||
expect(r.reason, contains('3'));
|
||||
final br = judgeActiveHabitQuota(
|
||||
type: HabitType.breakHabit, currentActiveCount: 1);
|
||||
expect(br.reason, contains('1'));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user