Worker Registration
Revision 1.1 (2025-12-31) - Updated blacklist location, added save-training endpoint
Feature Summary
Worker Registration (ทะเบียนผู้ปฏิบัติงาน) allows management of workers associated with contractors. The feature supports CRUD operations, training status management, and blacklist functionality.
Key Capabilities:
- View, create, edit, and delete workers
- Manage worker training status (pass/fail/expiry)
- Toggle blacklist status with reason tracking
- Role-based access control
Role Matrix
Revision 1.1 (2025-12-31) - Added "Edit training status" row
| Action | Admin | Purchasing | Work Owner | Safety Officer | Workspace Owner | Contractor |
|---|---|---|---|---|---|---|
| View all workers | ✅ | ❌ | ❌ | ✅ | ❌ | Own only |
| Create worker | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
| Edit worker (general info) | ❌ | ❌ | ❌ | ❌ | ❌ | Own only |
| Edit training status | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
| Delete worker | ❌ | ❌ | ❌ | ❌ | ❌ | Own only |
| Toggle blacklist | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
Legend:
- ✅ = Full access
- ❌ = No access
- Own only = Access restricted to workers belonging to contractor's company
Backend Test Report
Location:
backend/tests/http/workers/Tested: 2025-12-30
API Endpoints
| Method | Endpoint | Description | Tested |
|---|---|---|---|
| POST | /api/workers/search | Search workers | ✅ |
| POST | /api/workers/create | Create new worker | ✅ |
| GET | /api/workers/get/{id} | Get worker details | ✅ |
| POST | /api/workers/save | Save worker (Contractor only) | ✅ |
| POST | /api/workers/save-training | Save training data (Safety Officer only) | ✅ |
| POST | /api/workers/remove | Delete worker | ✅ |
| POST | /api/workers/toggleBlacklist | Toggle blacklist status | ✅ |
Test Results by Role
| Test Section | Admin | Safety Officer | Contractor |
|---|---|---|---|
| Search (TC-1.x) | ✅ | ✅ | ✅ (filtered) |
| Create (TC-2.x) | 403 | 403 | ✅ |
| Get (TC-3.x) | ✅ | ✅ | ✅ (own) |
| Save (TC-4.x) | 403 | 403 | ✅ (own) |
| Save Training (TC-5.x) | 403 | ✅ | 403 |
| Blacklist (TC-6.x) | 403 | ✅ | 403 |
| Remove (TC-7.x) | 403 | 403 | ✅ (own) |
Total: All critical test cases passed
Frontend Test Report
Location:
frontend/e2e/workers.spec.tsTested: 2025-12-30
E2E Test Results
| Test ID | Description | Result |
|---|---|---|
| TC-WRK-1 | Contractor can view worker list | ✅ Pass |
| TC-WRK-2 | Safety Officer can view all workers | ✅ Pass |
| TC-WRK-3 | Admin can view all workers | ✅ Pass |
| TC-WRK-4 | Contractor can create new worker | ✅ Pass |
| TC-WRK-5 | Safety Officer cannot create worker | ✅ Pass |
| TC-WRK-6 | Contractor can edit own worker | ✅ Pass |
| TC-WRK-7 | Safety Officer views worker readonly | ✅ Pass |
| TC-WRK-8 | Safety Officer can access training tab | ✅ Pass |
| TC-WRK-9 | Contractor views training tab readonly | ✅ Pass |
| TC-WRK-10 | Safety Officer can open blacklist dialog | ✅ Pass |
| TC-WRK-11 | Contractor blacklist attempt returns error | ✅ Pass |
| TC-WRK-12 | Contractor can delete worker | ✅ Pass |
Summary: 12 passed, 0 failed (50.5s)
Components Tested
worker-setting.component.ts- Main container componentworker-setting-list.component.ts- Worker list tableworker-setting-list-toolbar.component.ts- Toolbar with search/filtersworker-setting-form.component.ts- Edit form with tabsworker-setting-form-general.component.ts- General info tabworker-setting-form-training.component.ts- Training status tabdialog-blacklist.component.ts- Blacklist dialog
Manual Test Cases
Prerequisites
- Backend server running on
http://localhost:5000 - Frontend running on
http://localhost:4200 - Test accounts available (see Test Data section)
- Modern browser (Chrome recommended)
- At least one worker exists in the system
Test Data
Test Users
| Role | Password | Access Level | |
|---|---|---|---|
| Admin | tn@thaiscada.com | Test1234* | View all workers, no edit |
| Safety Officer | safety-supervisor@outlook.com | Test1234* | View all, training approval, blacklist |
| Contractor | safety-contractor1-0@outlook.com | Test1234* | CRUD own workers only |
Test Data for Creating Workers
| Field | Value |
|---|---|
| ชื่อ (First Name) | ทดสอบ |
| สกุล (Last Name) | ผู้ปฏิบัติงาน |
| เลขบัตรประชาชน (ID Card) | 1234567890123 |
| โทรศัพท์ (Phone) | 0812345678 |
test-worker@example.com |
Navigation Path
All Roles: เครื่องมือ (Tools) → ทะเบียนผู้ปฏิบัติงาน (Worker Registration)
URL: /tools/settings/worker
Test Summary
| Category | Total |
|---|---|
| 1. Navigation & Access | 4 |
| 2. View Worker List | 3 |
| 3. Create Worker | 4 |
| 4. Edit Worker | 4 |
| 5. Training Status | 3 |
| 6. Blacklist | 4 |
| 7. Delete Worker | 3 |
| Total | 25 |
1. Navigation & Access Tests
TC-WRK-M001: Contractor can access worker management
Precondition: User is logged in as Contractor
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "เครื่องมือ" (Tools) menu in header | Tools dropdown menu opens |
| 2 | Locate "ทะเบียนผู้ปฏิบัติงาน" menu item | Menu item visible |
| 3 | Click "ทะเบียนผู้ปฏิบัติงาน" | Page loads |
| 4 | Verify URL | URL is /tools/settings/worker |
| 5 | Verify page content | Worker list table displayed |
| 6 | Verify "เพิ่มผู้ปฏิบัติงาน" button visible | Add button present |
TC-WRK-M002: Safety Officer can access worker management
Precondition: User is logged in as Safety Officer
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as Safety Officer: safety-supervisor@outlook.com | Login successful |
| 2 | Navigate to เครื่องมือ → ทะเบียนผู้ปฏิบัติงาน | Worker management page loads |
| 3 | Verify URL | URL is /tools/settings/worker |
| 4 | Verify worker list displayed | Table with workers visible |
| 5 | Verify "เพิ่มผู้ปฏิบัติงาน" button NOT visible | Add button NOT present |
| 6 | Verify contractor filter dropdown visible | Filter dropdown present |
Safety Officer can view all workers but cannot create new ones.
TC-WRK-M003: Admin can access worker management
Precondition: User is logged in as Admin
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as Admin: tn@thaiscada.com | Login successful |
| 2 | Navigate to เครื่องมือ → ทะเบียนผู้ปฏิบัติงาน | Worker management page loads |
| 3 | Verify worker list displayed | Table with workers visible |
| 4 | Verify "เพิ่มผู้ปฏิบัติงาน" button NOT visible | Add button NOT present |
| 5 | Verify contractor filter dropdown visible | Filter dropdown present |
Admin can view all workers but cannot create/edit.
TC-WRK-M004: Purchasing user cannot access worker management
Precondition: User is logged in as Purchasing role
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as Purchasing: safety-purchasing@outlook.com | Login successful |
| 2 | Check if "ทะเบียนผู้ปฏิบัติงาน" menu item exists | Menu item NOT visible or access denied |
| 3 | Try direct URL navigation to /tools/settings/worker | Redirected or access denied |
Purchasing role does NOT have access to worker management.
2. View Worker List Tests
TC-WRK-M005: View worker list with table columns
Precondition: Logged in as Contractor, on Worker Management page
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to Worker Management page | Page loads with worker list |
| 2 | Verify table headers | Columns: ชื่อ-สกุล, เลขบัตรประชาชน, ประเภท, สถานะอบรม, Actions |
| 3 | Verify worker rows | Each row shows worker name, ID card, type, training status |
| 4 | Verify row actions | Each row has "แก้ไข" button and options menu (⌄) with "ลบ" option |
Contractor view does NOT show "บริษัท" column (filtered to own company). Options menu (⌄) is only visible for Contractors (Admin/SO do not see it).
TC-WRK-M006: Safety Officer sees company column
Precondition: Logged in as Safety Officer
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to Worker Management page | Page loads |
| 2 | Verify table has "บริษัท" (Company) column | Column visible between ประเภท and สถานะอบรม |
| 3 | Verify company names displayed | Each row shows contractor company name |
| 4 | Verify no options menu (⌄) | Only "แก้ไข" button visible, no dropdown menu |
Admin also sees company column. Neither Admin nor Safety Officer sees the options menu (⌄).
TC-WRK-M007: Search workers by keyword
Precondition: On Worker Management page with workers listed
| Step | Action | Expected Result |
|---|---|---|
| 1 | Locate search bar | Search input visible in toolbar |
| 2 | Enter worker name in search | Text entered |
| 3 | Press Enter or wait for search | List filtered |
| 4 | Verify filtered results | Only matching workers displayed |
| 5 | Clear search | All workers displayed again |
Search works on name, ID card, phone, email.
3. Create Worker Tests
TC-WRK-M008: Click add button opens form
Precondition: Logged in as Contractor, on Worker Management page
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "เพิ่มผู้ปฏิบัติงาน" button | Form opens |
| 2 | Verify form tabs displayed | 3 tabs: ข้อมูลส่วนบุคคล, เอกสารแนบ, สถานะการอบรม |
| 3 | Verify general tab is active | First tab selected by default |
| 4 | Verify "บันทึก" and "ยกเลิก" buttons | Both buttons visible |
TC-WRK-M009: Verify all form fields present
Precondition: Worker create form is open
| Step | Action | Expected Result |
|---|---|---|
| 1 | Verify worker type radio buttons | ประเภท: พนักงาน, 3rd Party (Specialist) |
| 2 | Verify contractor dropdown | บริษัทผู้รับเหมา* field present |
| 3 | Verify ID card field | เลขบัตรประชาชน* field present |
| 4 | Verify name fields | ชื่อ* and สกุล* fields present |
| 5 | Verify phone field | โทรศัพท์* field present |
| 6 | Verify email field | Email field present (optional) |
Fields marked with * are required.
TC-WRK-M010: Create worker with valid data
Precondition: Worker create form is open
| Step | Action | Expected Result |
|---|---|---|
| 1 | Select worker type: พนักงาน | Radio selected |
| 2 | Enter ID card: 1234567890123 | Field populated |
| 3 | Enter first name: ทดสอบ | Field populated |
| 4 | Enter last name: ผู้ปฏิบัติงาน | Field populated |
| 5 | Enter phone: 0812345678 | Field populated |
| 6 | Click "บันทึก" button | Save triggered |
| 7 | Verify success snackbar | "บันทึกสำเร็จ" message appears |
| 8 | Verify returned to list | Worker list displayed |
| 9 | Verify new worker in list | New worker visible in table |
TC-WRK-M011: Cancel create discards changes
Precondition: Worker create form is open with data entered
| Step | Action | Expected Result |
|---|---|---|
| 1 | Enter some data in form | Fields populated |
| 2 | Click "ยกเลิก" button | Cancel triggered |
| 3 | Verify returned to list | Worker list displayed |
| 4 | Verify worker NOT created | New worker not in list |
4. Edit Worker Tests
TC-WRK-M012: Click edit button opens form with data
Precondition: Logged in as Contractor, workers exist in list
| Step | Action | Expected Result |
|---|---|---|
| 1 | Locate a worker row | Row visible |
| 2 | Click "แก้ไข" button | Edit form opens |
| 3 | Verify form populated | All fields show current worker data |
| 4 | Verify "บันทึก" button visible | Save button present |
TC-WRK-M013: Edit worker name
Precondition: Worker edit form is open
| Step | Action | Expected Result |
|---|---|---|
| 1 | Note current first name | Record existing value |
| 2 | Clear first name field | Field is empty |
| 3 | Enter new name: แก้ไขแล้ว | Thai characters accepted |
| 4 | Click "บันทึก" button | Save triggered |
| 5 | Verify success snackbar | "บันทึกสำเร็จ" message appears |
| 6 | Verify updated name in list | New name shown in table |
Remember to restore original value after test.
TC-WRK-M014: Safety Officer views worker in readonly mode
Precondition: Logged in as Safety Officer
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to Worker Management | Worker list displayed |
| 2 | Click "แก้ไข" on any worker | Form opens |
| 3 | Verify "บันทึก" button NOT visible | Save button hidden |
| 4 | Verify "กลับ" button visible | Back button present instead of Cancel |
| 5 | Verify form fields are readonly | Cannot edit general info |
Safety Officer can only edit training status, not general info.
TC-WRK-M015: Cancel edit discards changes
Precondition: Worker edit form is open with changes made
| Step | Action | Expected Result |
|---|---|---|
| 1 | Make changes to worker form | Values modified |
| 2 | Click "ยกเลิก" button | Cancel triggered |
| 3 | Click "แก้ไข" on same worker | Edit form opens |
| 4 | Verify original values | Changes were NOT saved |
5. Training Status Tests
TC-WRK-M016: Navigate to training tab
Precondition: Worker edit form is open
| Step | Action | Expected Result |
|---|---|---|
| 1 | Locate "สถานะการอบรม" tab | Tab visible |
| 2 | Click "สถานะการอบรม" tab | Tab content displayed |
| 3 | Verify training status field | Status dropdown or display visible |
TC-WRK-M017: Safety Officer can update training status
Precondition: Logged in as Safety Officer, on training tab
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to training tab | Training content displayed |
| 2 | Verify training controls editable | Can modify training status |
| 3 | Update training status | Status changed |
| 4 | Click save (if applicable) | Changes saved |
Only Safety Officer can edit training status.
TC-WRK-M018: Contractor cannot edit training status
Precondition: Logged in as Contractor, on training tab
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to training tab | Training content displayed |
| 2 | Verify training controls are readonly | Cannot modify training status |
Contractor can view training status but cannot edit.
6. Blacklist Tests
Note: Blacklist controls are now located in the Training tab form (moved from context menu in v1.1)
TC-WRK-M019: Access blacklist controls in Training tab
Precondition: Logged in as Safety Officer, worker edit form open
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "สถานะการอบรม" tab | Training tab content displayed |
| 2 | Scroll to "สถานะ Blacklist" section | Blacklist section visible |
| 3 | Verify current status shown | "ไม่ได้ถูกติด Blacklist" with green checkmark |
| 4 | Verify "ติด Blacklist" button | Red button visible |
TC-WRK-M020: Add worker to blacklist
Precondition: On Training tab, worker not blacklisted
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "ติด Blacklist" button (red) | Blacklist dialog opens |
| 2 | Verify dialog fields | Reason field present |
| 3 | Enter reason: ทดสอบ Blacklist | Reason entered |
| 4 | Click confirm button | Dialog closes |
| 5 | Verify success snackbar | Success message appears |
| 6 | Verify Training tab updates | Shows "ถูกติด Blacklist" with reason |
| 7 | Return to list and verify | Worker row highlighted red with block icon |
TC-WRK-M021: Remove worker from blacklist
Precondition: Worker is blacklisted, on Training tab
| Step | Action | Expected Result |
|---|---|---|
| 1 | Verify blacklist status shown | "ถูกติด Blacklist" with reason displayed |
| 2 | Click "ปลด Blacklist" button | Confirmation dialog appears |
| 3 | Confirm removal | Dialog closes |
| 4 | Verify success snackbar | Success message appears |
| 5 | Verify Training tab updates | Shows "ไม่ได้ถูกติด Blacklist" |
| 6 | Return to list and verify | Row no longer red, no block icon |
TC-WRK-M022: Contractor cannot access blacklist controls
Precondition: Logged in as Contractor, on worker edit form
| Step | Action | Expected Result |
|---|---|---|
| 1 | Navigate to Training tab | Training content displayed |
| 2 | Scroll to Blacklist section | Section visible |
| 3 | Verify no blacklist button | "ติด Blacklist" button NOT visible |
| 4 | Verify status is read-only | Cannot modify blacklist status |
Contractors can only view blacklist status, not toggle it.
7. Delete Worker Tests
TC-WRK-M023: Open delete confirmation dialog
Precondition: Logged in as Contractor, own worker exists
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click options menu (⌄) on worker row | Dropdown opens |
| 2 | Verify delete option | "ลบ" (Delete) visible |
| 3 | Click "ลบ" | Confirmation dialog appears |
| 4 | Verify dialog text | Dialog shows worker name and confirms delete |
| 5 | Verify dialog buttons | "ตกลง" and "ยกเลิก" buttons visible |
TC-WRK-M024: Cancel delete keeps worker
Precondition: Delete confirmation dialog is showing
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "ยกเลิก" button | Dialog closes |
| 2 | Verify worker still in list | Worker NOT deleted |
TC-WRK-M025: Confirm delete removes worker
Precondition: Delete confirmation dialog is showing
| Step | Action | Expected Result |
|---|---|---|
| 1 | Click "ตกลง" button | Delete triggered |
| 2 | Verify success snackbar | "ลบสำเร็จ" message appears |
| 3 | Verify worker removed from list | Worker no longer in table |
Create a test worker before this test to avoid deleting real data.
Labels verified against:
worker-setting-list.component.ts(table headers, menu actions)worker-setting-form-general.component.ts(form field labels)worker-setting-list-toolbar.component.ts(toolbar buttons)dialog-blacklist.component.ts(dialog text)