sistemati bug
This commit is contained in:
1 parent
89e5d4014d
commit
2c02dfcf8b
13 files changed
+1645
-16
No files matched your search
@@ -0,0 +1,125 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flux/features/home/dashboard_daily_ricontatti/blocs/dashboard_daily_ricontatti_state.dart';
|
||||
import 'package:flux/features/home/dashboard_daily_ricontatti/models/staff_daily_ricontatti_summary.dart';
|
||||
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||
import 'package:flux/features/operations/models/operation_type.dart';
|
||||
|
||||
void main() {
|
||||
group('StaffDailyRicontattiSummary', () {
|
||||
test('correctly evaluates hasReachedGoal, hasStarted, isZero', () {
|
||||
const summaryZero = StaffDailyRicontattiSummary(
|
||||
staffId: '1',
|
||||
staffName: 'Mario Rossi',
|
||||
count: 0,
|
||||
);
|
||||
expect(summaryZero.isZero, isTrue);
|
||||
expect(summaryZero.hasStarted, isFalse);
|
||||
expect(summaryZero.hasReachedGoal, isFalse);
|
||||
|
||||
const summaryOne = StaffDailyRicontattiSummary(
|
||||
staffId: '2',
|
||||
staffName: 'Luigi Bianchi',
|
||||
count: 1,
|
||||
);
|
||||
expect(summaryOne.isZero, isFalse);
|
||||
expect(summaryOne.hasStarted, isTrue);
|
||||
expect(summaryOne.hasReachedGoal, isFalse);
|
||||
|
||||
const summaryTwo = StaffDailyRicontattiSummary(
|
||||
staffId: '3',
|
||||
staffName: 'Anna Verdi',
|
||||
count: 2,
|
||||
);
|
||||
expect(summaryTwo.isZero, isFalse);
|
||||
expect(summaryTwo.hasStarted, isFalse);
|
||||
expect(summaryTwo.hasReachedGoal, isTrue);
|
||||
|
||||
const summaryFive = StaffDailyRicontattiSummary(
|
||||
staffId: '4',
|
||||
staffName: 'Paolo Neri',
|
||||
count: 5,
|
||||
);
|
||||
expect(summaryFive.isZero, isFalse);
|
||||
expect(summaryFive.hasStarted, isFalse);
|
||||
expect(summaryFive.hasReachedGoal, isTrue);
|
||||
});
|
||||
|
||||
test('copyWith updates fields as expected', () {
|
||||
const original = StaffDailyRicontattiSummary(
|
||||
staffId: '1',
|
||||
staffName: 'Mario',
|
||||
count: 0,
|
||||
systemRole: SystemRole.user,
|
||||
);
|
||||
|
||||
final updated = original.copyWith(
|
||||
count: 3,
|
||||
monthCount: 15,
|
||||
systemRole: SystemRole.manager,
|
||||
);
|
||||
|
||||
expect(updated.count, equals(3));
|
||||
expect(updated.monthCount, equals(15));
|
||||
expect(updated.systemRole, equals(SystemRole.manager));
|
||||
expect(updated.staffName, equals('Mario'));
|
||||
expect(updated.staffId, equals('1'));
|
||||
});
|
||||
});
|
||||
|
||||
group('DashboardDailyRicontattiState', () {
|
||||
test('computes staffWithGoal, staffWithOne, staffAtZero correctly', () {
|
||||
final state = DashboardDailyRicontattiState(
|
||||
date: DateTime(2026, 10, 9),
|
||||
summaries: const [
|
||||
StaffDailyRicontattiSummary(
|
||||
staffId: '1',
|
||||
staffName: 'Mario',
|
||||
count: 3, // >= 2
|
||||
monthCount: 18,
|
||||
),
|
||||
StaffDailyRicontattiSummary(
|
||||
staffId: '2',
|
||||
staffName: 'Luigi',
|
||||
count: 2, // >= 2
|
||||
monthCount: 12,
|
||||
),
|
||||
StaffDailyRicontattiSummary(
|
||||
staffId: '3',
|
||||
staffName: 'Anna',
|
||||
count: 1, // == 1
|
||||
monthCount: 9,
|
||||
),
|
||||
StaffDailyRicontattiSummary(
|
||||
staffId: '4',
|
||||
staffName: 'Paolo',
|
||||
count: 0, // == 0
|
||||
monthCount: 5,
|
||||
),
|
||||
StaffDailyRicontattiSummary(
|
||||
staffId: '5',
|
||||
staffName: 'Giulia',
|
||||
count: 0, // == 0
|
||||
monthCount: 0,
|
||||
),
|
||||
],
|
||||
totalRicontattiToday: 6,
|
||||
totalRicontattiMonth: 44,
|
||||
);
|
||||
|
||||
expect(state.activeStaffCount, equals(5));
|
||||
expect(state.staffWithGoal, equals(2));
|
||||
expect(state.staffWithOne, equals(1));
|
||||
expect(state.staffAtZero, equals(2));
|
||||
expect(state.totalRicontattiToday, equals(6));
|
||||
expect(state.totalRicontattiMonth, equals(44));
|
||||
});
|
||||
});
|
||||
|
||||
group('OperationType.ricontatto', () {
|
||||
test('resolves from string accurately', () {
|
||||
expect(OperationType.fromValue('ricontatto'), equals(OperationType.ricontatto));
|
||||
expect(OperationType.fromValue('Ricontatto'), equals(OperationType.ricontatto));
|
||||
expect(OperationType.fromValue('RICONTATTO'), equals(OperationType.ricontatto));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user