replaced generic "Event" label with substitution or lesson text

This commit is contained in:
2026-09-24 22:22:43 +02:00
parent 498d195138
commit 4f31e68456
4 changed files with 81 additions and 4 deletions
@@ -0,0 +1,59 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:marianum_mobile/api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
import 'package:marianum_mobile/view/pages/timetable/data/lesson_type_label.dart';
McTimetableEntry _entry({
String lessonType = 'LESSON',
String? substitutionText,
String? lessonText,
}) => McTimetableEntry(
id: 1,
date: DateTime(2026, 5, 4),
startTime: DateTime(1970, 1, 1, 8),
endTime: DateTime(1970, 1, 1, 15),
subjects: const [],
teachers: const [],
rooms: const ['A101'],
classNames: const ['8a'],
lessonType: lessonType,
status: 'REGULAR',
substitutionText: substitutionText,
lessonText: lessonText,
infoText: null,
);
void main() {
group('LessonTypeLabel.forEntry', () {
test('prefers the substitution text', () {
expect(
LessonTypeLabel.forEntry(
_entry(substitutionText: 'Klassenfahrt 8a', lessonText: 'Anderes'),
),
'Klassenfahrt 8a',
);
});
test('falls back to the lesson text', () {
expect(
LessonTypeLabel.forEntry(_entry(lessonText: ' Wandertag\n8a ')),
'Wandertag 8a',
);
});
test('falls back to "Event" with room when no text is set', () {
expect(
LessonTypeLabel.forEntry(_entry(substitutionText: ' ')),
'A101 Event',
);
});
test('keeps known lesson types over free text', () {
expect(
LessonTypeLabel.forEntry(
_entry(lessonType: 'BREAK_SUPERVISION', lessonText: 'Hof'),
),
'A101 Aufsicht',
);
});
});
}