Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong section title for homeworks in next month. #1134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class TodoDateSubcategorizer extends Subcategorizer {
List<HomeworkSectionView> subcategorize(HomeworkList homeworks) {
final latestHomeworkList = homeworks;
final now = currentDate;
final tomorrow = now.addDaysWithNoChecking(1);
final in2Days = tomorrow.addDaysWithNoChecking(1);
final tomorrow = now.addDays(1);
final in2Days = tomorrow.addDays(1);

final List<HomeworkReadModel> overdueHomework = latestHomeworkList
.where((h) => Date.fromDateTime(h.todoDate) < now)
Expand Down
25 changes: 22 additions & 3 deletions lib/hausaufgabenheft_logik/test/homework_page_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ void main() {
late HomeworkPageBloc bloc;
late InMemoryHomeworkRepository repository;
late HomeworkSortingCache homeworkSortingCache;
late KeyValueStore kvs;

setUp(() {
repository = createRepositoy();
final kvs = InMemoryKeyValueStore();
kvs = InMemoryKeyValueStore();
bloc = createBloc(repository, keyValueStore: kvs);
homeworkSortingCache = HomeworkSortingCache(kvs);
});
Expand All @@ -53,6 +54,24 @@ void main() {
}
}

test(
// https://github.com/SharezoneApp/sharezone-app/issues/53
// https://github.com/SharezoneApp/sharezone-app/pull/1134
'Regressions test: Shows "Morgen" as section title if today is end of month (e.g. 31.10) and tomorrow is first of next month (e.g. 01.11)',
() async {
bloc = createBloc(repository,
keyValueStore: kvs, getCurrentDateTime: () => DateTime(2023, 10, 31));
await addToRepository([
createHomework(
id: 'hw', todoDate: const Date(year: 2023, month: 11, day: 1))
]);

bloc.add(LoadHomeworks());

Success success = await bloc.stream.whereType<Success>().first;
expect(success.open.sections.first.title, 'Morgen');
});

test(
'Regressions Test für #954 "Wenn man Hausaufgaben nach Fach sortiert und dann eine Aufgabe abhakt wechselt die App automatisch wieder in die Ansicht nach Datum."',
() async {
Expand Down Expand Up @@ -277,8 +296,8 @@ void main() {
});

test('date subcategory titles are only shown when necessary', () async {
final tomorrow = createHomework(
title: 'abc', todoDate: Date.now().addDaysWithNoChecking(1));
final tomorrow =
createHomework(title: 'abc', todoDate: Date.now().addDays(1));
await addToRepository([tomorrow]);
bloc.add(LoadHomeworks());

Expand Down
Loading