Task 18: Auto Employee Number Generation
Test Cases
| ID | Scenario | Expected Result | Status |
|---|---|---|---|
| T18-01 | Create a new employee under entity "Hayo" without entering an employee number | Employee is created with number HAYO-001 (or next in sequence) | |
| T18-02 | Create a second employee under entity "Hayo" | Employee number is HAYO-002 (increments from previous) | |
| T18-03 | Create an employee under a different entity (e.g., "Slick") | Employee number starts with SLICK-001 (independent sequence) | |
| T18-04 | Try to send employee_number manually in the create API payload | Request is rejected with 422 validation error (employee_number is prohibited) | |
| T18-05 | Try to update an existing employee's employee_number via API | Request is rejected with 422 validation error (employee_number is prohibited) | |
| T18-06 | Import CSV with blank employee_number column | Employees are created with auto-generated numbers | |
| T18-07 | Import CSV without the employee_number column at all | Import succeeds; employees get auto-generated numbers | |
| T18-08 | Import CSV with explicit employee_number values provided | Employees are created with the provided numbers (backward compatible) |
Demo Walkthrough
Creating an Employee (UI)
- Navigate to Employees → click New Employee.
- Select an Entity (e.g., "Hayo") and a department.
- Notice the Employee Number field shows "Auto-generated after creation" — no manual input needed.
- Fill in required fields (work email, first name, last name, role).
- Click "Create & Next".
- Verify the created employee now shows an employee number like
HAYO-001in the detail view. - Create another employee under the same entity → verify the number increments (e.g.,
HAYO-002). - Switch entity to "Slick" → create an employee → verify the number is
SLICK-001(separate sequence).
Editing an Employee (UI)
- Open an existing employee in edit mode.
- Verify the Employee Number field is displayed but disabled (greyed out, read-only).
- Confirm you cannot type into it or change the value.
CSV Import with Auto-Generation
- Navigate to Employees → click Import CSV/Excel.
- Prepare a CSV with required columns but leave
employee_numberblank or remove the column entirely. - Upload the file.
- Verify the import succeeds and imported employees have auto-generated numbers matching their entity prefix.
API Validation
- Send a POST to
/api/employeeswith anemployee_numberfield included → verify 422 error withemployee_numberin validation errors. - Send a PATCH to
/api/employees/{id}with anemployee_numberfield → verify 422 error.