Refactor employee management by implementing automatic employee number generation, updating national ID handling, and enhancing localization for gender and nationality fields across various resources. Adjust form components and validation logic to improve user experience and data integrity.
This commit is contained in:
@@ -84,6 +84,32 @@ it('defines expected employee relationships', function (): void {
|
||||
->and($employee->documents)->toHaveCount(1);
|
||||
});
|
||||
|
||||
it('generates an employee number on save when number is blank', function (): void {
|
||||
$employee = Employee::factory()->create([
|
||||
'employee_number' => '',
|
||||
]);
|
||||
|
||||
expect($employee->employee_number)->toBe('EMP-00001');
|
||||
});
|
||||
|
||||
it('does not overwrite an existing employee number on update', function (): void {
|
||||
$employee = Employee::factory()->create([
|
||||
'employee_number' => 'EMP-CUSTOM',
|
||||
]);
|
||||
|
||||
$employee->update(['full_name' => 'Updated Name']);
|
||||
|
||||
expect($employee->fresh()->employee_number)->toBe('EMP-CUSTOM');
|
||||
});
|
||||
|
||||
it('increments employee numbers sequentially', function (): void {
|
||||
$first = Employee::factory()->create(['employee_number' => '']);
|
||||
$second = Employee::factory()->create(['employee_number' => '']);
|
||||
|
||||
expect($first->employee_number)->toBe('EMP-00001')
|
||||
->and($second->employee_number)->toBe('EMP-00002');
|
||||
});
|
||||
|
||||
it('enforces a unique employee number', function (): void {
|
||||
Employee::factory()->create(['employee_number' => 'EMP-UNIQUE']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user