feat(02-01): German task templates for 14 room types with detectRoomType
- Create TaskTemplate class with name, intervalType, intervalDays, effortLevel - Add roomTemplates const map with 3-6 templates per room type (14 total) - Implement detectRoomType with case-insensitive matching and alias support - Room types: kueche, badezimmer, schlafzimmer, wohnzimmer, flur, buero, garage, balkon, waschkueche, keller, kinderzimmer, gaestezimmer, esszimmer, garten - All 11 template tests passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
111
test/features/templates/task_templates_test.dart
Normal file
111
test/features/templates/task_templates_test.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/effort_level.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/frequency.dart';
|
||||
import 'package:household_keeper/features/templates/data/task_templates.dart';
|
||||
|
||||
void main() {
|
||||
group('roomTemplates', () {
|
||||
test('contains exactly 14 room type keys', () {
|
||||
expect(roomTemplates.length, 14);
|
||||
});
|
||||
|
||||
test('all 14 room types from TMPL-02 are present', () {
|
||||
const expectedTypes = [
|
||||
'kueche',
|
||||
'badezimmer',
|
||||
'schlafzimmer',
|
||||
'wohnzimmer',
|
||||
'flur',
|
||||
'buero',
|
||||
'garage',
|
||||
'balkon',
|
||||
'waschkueche',
|
||||
'keller',
|
||||
'kinderzimmer',
|
||||
'gaestezimmer',
|
||||
'esszimmer',
|
||||
'garten',
|
||||
];
|
||||
for (final type in expectedTypes) {
|
||||
expect(
|
||||
roomTemplates.containsKey(type),
|
||||
isTrue,
|
||||
reason: 'Missing room type: $type',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('each room type maps to a non-empty list of TaskTemplate objects', () {
|
||||
for (final entry in roomTemplates.entries) {
|
||||
expect(
|
||||
entry.value,
|
||||
isNotEmpty,
|
||||
reason: 'Room type ${entry.key} has no templates',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('every TaskTemplate has a non-empty German name', () {
|
||||
for (final entry in roomTemplates.entries) {
|
||||
for (final template in entry.value) {
|
||||
expect(
|
||||
template.name.isNotEmpty,
|
||||
isTrue,
|
||||
reason:
|
||||
'Template in ${entry.key} has empty name',
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('every TaskTemplate has a valid IntervalType', () {
|
||||
for (final entry in roomTemplates.entries) {
|
||||
for (final template in entry.value) {
|
||||
expect(
|
||||
IntervalType.values.contains(template.intervalType),
|
||||
isTrue,
|
||||
reason:
|
||||
'Template "${template.name}" in ${entry.key} has invalid intervalType',
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('every TaskTemplate has a valid EffortLevel', () {
|
||||
for (final entry in roomTemplates.entries) {
|
||||
for (final template in entry.value) {
|
||||
expect(
|
||||
EffortLevel.values.contains(template.effortLevel),
|
||||
isTrue,
|
||||
reason:
|
||||
'Template "${template.name}" in ${entry.key} has invalid effortLevel',
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
group('detectRoomType', () {
|
||||
test('"Kueche" returns "kueche"', () {
|
||||
expect(detectRoomType('Kueche'), 'kueche');
|
||||
});
|
||||
|
||||
test('"Mein Badezimmer" returns "badezimmer"', () {
|
||||
expect(detectRoomType('Mein Badezimmer'), 'badezimmer');
|
||||
});
|
||||
|
||||
test('"Bad" returns "badezimmer" (alias)', () {
|
||||
expect(detectRoomType('Bad'), 'badezimmer');
|
||||
});
|
||||
|
||||
test('"Random Name" returns null', () {
|
||||
expect(detectRoomType('Random Name'), isNull);
|
||||
});
|
||||
|
||||
test('is case-insensitive', () {
|
||||
expect(detectRoomType('KUECHE'), 'kueche');
|
||||
expect(detectRoomType('kueche'), 'kueche');
|
||||
expect(detectRoomType('Kueche'), 'kueche');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user