test(TaskListScreen): add integration tests for filtered and overdue task states
All checks were successful
Build and Release to F-Droid / build-and-deploy (push) Successful in 10m30s
All checks were successful
Build and Release to F-Droid / build-and-deploy (push) Successful in 10m30s
- Covers empty states, celebration state, and scheduled/overdue task rendering - Verifies proper checkbox behavior for future tasks - Tests AppBar for sort dropdown, edit/delete actions, and calendar strip - Adds necessary test helpers and overrides for room-specific tasks
This commit is contained in:
@@ -55,6 +55,33 @@ class CalendarDao extends DatabaseAccessor<AppDatabase>
|
||||
return result.read(countExp) ?? 0;
|
||||
}
|
||||
|
||||
/// Watch tasks due on [date] within a specific [roomId].
|
||||
///
|
||||
/// Same as [watchTasksForDate] but filtered to a single room.
|
||||
Stream<List<TaskWithRoom>> watchTasksForDateInRoom(
|
||||
DateTime date, int roomId) {
|
||||
final startOfDay = DateTime(date.year, date.month, date.day);
|
||||
final endOfDay = startOfDay.add(const Duration(days: 1));
|
||||
|
||||
final query = select(tasks).join([
|
||||
innerJoin(rooms, rooms.id.equalsExp(tasks.roomId)),
|
||||
]);
|
||||
query.where(
|
||||
tasks.nextDueDate.isBiggerOrEqualValue(startOfDay) &
|
||||
tasks.nextDueDate.isSmallerThanValue(endOfDay) &
|
||||
tasks.roomId.equals(roomId),
|
||||
);
|
||||
query.orderBy([OrderingTerm.asc(tasks.name)]);
|
||||
|
||||
return query.watch().map((rows) {
|
||||
return rows.map((row) {
|
||||
final task = row.readTable(tasks);
|
||||
final room = row.readTable(rooms);
|
||||
return TaskWithRoom(task: task, roomName: room.name, roomId: room.id);
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
/// Watch tasks whose [nextDueDate] is strictly before [referenceDate].
|
||||
///
|
||||
/// Returns tasks sorted by [nextDueDate] ascending (oldest first).
|
||||
@@ -84,4 +111,50 @@ class CalendarDao extends DatabaseAccessor<AppDatabase>
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
/// Watch overdue tasks (before [referenceDate]) within a specific [roomId].
|
||||
///
|
||||
/// Same as [watchOverdueTasks] but filtered to a single room.
|
||||
Stream<List<TaskWithRoom>> watchOverdueTasksInRoom(
|
||||
DateTime referenceDate, int roomId) {
|
||||
final startOfReferenceDay = DateTime(
|
||||
referenceDate.year,
|
||||
referenceDate.month,
|
||||
referenceDate.day,
|
||||
);
|
||||
|
||||
final query = select(tasks).join([
|
||||
innerJoin(rooms, rooms.id.equalsExp(tasks.roomId)),
|
||||
]);
|
||||
query.where(
|
||||
tasks.nextDueDate.isSmallerThanValue(startOfReferenceDay) &
|
||||
tasks.roomId.equals(roomId),
|
||||
);
|
||||
query.orderBy([OrderingTerm.asc(tasks.nextDueDate)]);
|
||||
|
||||
return query.watch().map((rows) {
|
||||
return rows.map((row) {
|
||||
final task = row.readTable(tasks);
|
||||
final room = row.readTable(rooms);
|
||||
return TaskWithRoom(
|
||||
task: task,
|
||||
roomName: room.name,
|
||||
roomId: room.id,
|
||||
);
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
/// Total task count within a specific room.
|
||||
///
|
||||
/// Used to distinguish first-run empty state from celebration state
|
||||
/// in the room calendar view.
|
||||
Future<int> getTaskCountInRoom(int roomId) async {
|
||||
final countExp = tasks.id.count();
|
||||
final query = selectOnly(tasks)
|
||||
..addColumns([countExp])
|
||||
..where(tasks.roomId.equals(roomId));
|
||||
final result = await query.getSingle();
|
||||
return result.read(countExp) ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user