Auto Task Assignment
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tasq/providers/tasks_provider.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'chooseAutoAssignCandidate picks latest check-in (late-comer priority)',
|
||||
() {
|
||||
final now = DateTime(2026, 2, 18, 12, 0, 0);
|
||||
final earlier = AutoAssignCandidate(
|
||||
userId: 'user-1',
|
||||
checkInAt: now.subtract(const Duration(hours: 2)),
|
||||
completedToday: 0,
|
||||
);
|
||||
final later = AutoAssignCandidate(
|
||||
userId: 'user-2',
|
||||
checkInAt: now.subtract(const Duration(hours: 1)),
|
||||
completedToday: 0,
|
||||
);
|
||||
|
||||
final chosen = chooseAutoAssignCandidate([earlier, later]);
|
||||
expect(chosen, equals('user-2'));
|
||||
},
|
||||
);
|
||||
|
||||
test('chooseAutoAssignCandidate uses completed count as tie-breaker', () {
|
||||
final now = DateTime(2026, 2, 18, 9, 0, 0);
|
||||
final a = AutoAssignCandidate(
|
||||
userId: 'a',
|
||||
checkInAt: now,
|
||||
completedToday: 5,
|
||||
);
|
||||
final b = AutoAssignCandidate(
|
||||
userId: 'b',
|
||||
checkInAt: now,
|
||||
completedToday: 2,
|
||||
);
|
||||
|
||||
final chosen = chooseAutoAssignCandidate([a, b]);
|
||||
expect(chosen, equals('b'));
|
||||
});
|
||||
|
||||
test('chooseAutoAssignCandidate returns null for empty list', () {
|
||||
expect(chooseAutoAssignCandidate([]), isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user