Frontend Test Cases: Training Enrollment
Revision 1.0 (2026-01-23) - Consolidated from Service Report #008 (MoM 2026-01-16)
Source: Service Report #008
Test Accounts
| Role | Email | Password |
|---|
| Safety Officer | safety-supervisor@outlook.com | Test1234* |
| Contractor | safety-contractor1-0@outlook.com | Test1234* |
Precondition: Contractor opens Training Enrollment task
| Step | Action | Expected |
|---|
| 1 | Open Training Enrollment task with no session selected | Submit button disabled |
| 2 | Verify validation banner shows | "รอบอบรม" error visible |
| Step | Action | Expected |
|---|
| 1 | Select a session but no workers | Submit button still disabled |
| 2 | Verify validation banner | "ผู้อบรม (อย่างน้อย 1 คน)" error visible |
| Step | Action | Expected |
|---|
| 1 | Select session AND at least 1 worker | Submit button enabled |
| 2 | Validation banner disappears | No error messages |
TC-TE-004: Validation error messages display correctly
| Step | Action | Expected |
|---|
| 1 | Open form with no data | Orange validation banner visible |
| 2 | Check error list | Clear Thai/English messages for each missing field |
TC-TE-005: SO approval requires at least 1 worker
Precondition: SO reviewing enrollment task
| Step | Action | Expected |
|---|
| 1 | Deselect all workers | Approve button disabled |
| 2 | Verify validation message | "ต้องเลือกผู้อบรมอย่างน้อย 1 คนเพื่ออนุมัติ" |
TC-TE-006: ValidationRequired on Submit command
| Step | Action | Expected |
|---|
| 1 | Leave form empty | "ส่งรายชื่อผู้อบรม" button is disabled |
| 2 | Fill valid data | Button becomes enabled |
| 3 | "ยกเลิก" button | Always enabled (no validation required) |
2. Auto-Navigation
Precondition: Contractor opens Training Enrollment task in FillInTrainingList state
| Step | Action | Expected |
|---|
| 1 | Open the task | Form opens automatically (not document list) |
| 2 | Verify form is editable | Session dropdown and worker list are interactive |
Precondition: SO opens Training Enrollment task in ReviewBySafetyOfficer state
| Step | Action | Expected |
|---|
| 1 | Open the task | Form opens automatically |
| 2 | Verify form is in review mode | Worker checkboxes visible for partial approval |
TC-TE-009: Document list is bypassed
| Step | Action | Expected |
|---|
| 1 | Open task as Contractor or SO | Document list is NOT shown first |
| 2 | Form is displayed directly | No extra click required |
3. Document View Gating
TC-TE-010: Commands hidden on document list
Precondition: SO opens task (if auto-nav is disabled or navigates back)
| Step | Action | Expected |
|---|
| 1 | View document list | Command buttons (อนุมัติ, ปฏิเสธ, etc.) are HIDDEN |
| Step | Action | Expected |
|---|
| 1 | Open document form | Command buttons APPEAR in toolbar |
TC-TE-012: Commands hide on back navigation
| Step | Action | Expected |
|---|
| 1 | From form, click Back to document list | Command buttons HIDE again |
TC-TE-013: Cross-workflow gating works
| Step | Action | Expected |
|---|
| 1 | Check other workflow tasks (PR, JSA, Tool List) | Same gating behavior applies |
4. Block Duplicate Enrollment
TC-TE-014: Create enrollment with no pending task
Precondition: Contractor has no pending enrollment tasks
| Step | Action | Expected |
|---|
| 1 | Create Training Enrollment task | Task created successfully |
TC-TE-015: Block second enrollment while pending
Precondition: Contractor has a pending enrollment task (awaiting SO review)
| Step | Action | Expected |
|---|
| 1 | Try to create another Training Enrollment | Error message shown |
| 2 | Verify error text | "คุณมีรายการส่งรายชื่อผู้อบรมที่รอการอนุมัติอยู่แล้ว..." |
TC-TE-016: Create enrollment after approval/rejection
Precondition: Previous enrollment has been approved, rejected, or cancelled
| Step | Action | Expected |
|---|
| 1 | Create new Training Enrollment | Task created successfully |
5. Partial Approval
TC-TE-017: SO sees checkboxes in review state
Precondition: SO opens enrollment in ReviewBySafetyOfficer state
| Step | Action | Expected |
|---|
| 1 | Open form | Worker checkboxes visible |
| 2 | Workers with issues | Red background, checkbox disabled |
TC-TE-018: Blocked workers cannot be selected
| Step | Action | Expected |
|---|
| 1 | Find blacklisted worker | Red background, checkbox disabled |
| 2 | Find already-enrolled worker | Red background, checkbox disabled |
| 3 | Try clicking disabled checkbox | Nothing happens |
TC-TE-019: SO deselects workers and approves
| Step | Action | Expected |
|---|
| 1 | Deselect some workers (uncheck) | Workers removed from selection |
| 2 | Click "อนุมัติรายชื่อ" | Only selected workers are enrolled |
| 3 | Verify attendance records | Only for selected workers |
| Step | Action | Expected |
|---|
| 1 | Deselect ALL workers | Approve button disabled |
| 2 | Re-select at least 1 | Approve button enabled |
TC-TE-021: Validation error when none selected
| Step | Action | Expected |
|---|
| 1 | Deselect all workers | Validation message appears |
| 2 | Verify message | "ต้องเลือกผู้อบรมอย่างน้อย 1 คนเพื่ออนุมัติ" |
6. Training Attendance Verification
TC-TE-022: Passed worker shows green background
| Step | Action | Expected |
|---|
| 1 | Find worker with TrainingStatus = Passed | Row has green background (bg-green-50) |
| 2 | Worker is selectable | Checkbox enabled |
TC-TE-023: Passed worker with enrollment shows red
| Step | Action | Expected |
|---|
| 1 | Find passed worker already enrolled in THIS session | Row has red background |
| 2 | Checkbox disabled | Cannot select |
TC-TE-024: Passed but blacklisted shows red
| Step | Action | Expected |
|---|
| 1 | Find passed worker who is blacklisted | Row has red background |
| 2 | Checkbox disabled | Cannot select |
TC-TE-025: Expired worker with missing docs shows red
| Step | Action | Expected |
|---|
| 1 | Find worker with Expired status + missing documents | Red background, blocked |
TC-TE-026: None status with valid docs is selectable
| Step | Action | Expected |
|---|
| 1 | Find worker with None status + all documents | No colored background |
| 2 | Checkbox enabled | Can select |
| Step | Action | Expected |
|---|
| 1 | Hover over passed worker's validation icon | Tooltip: "ผ่านการอบรมแล้ว - สามารถลงทะเบียนอบรมทบทวนได้" |
7. Worker Selection Dialog
TC-TE-028: Dialog opens with default filter
| Step | Action | Expected |
|---|
| 1 | Click "จัดการรายชื่อ" | Dialog opens |
| 2 | Verify default chip selected | "ยังไม่ได้อบรม" chip active |
TC-TE-029: Search by name or ID
| Step | Action | Expected |
|---|
| 1 | Type worker name in search | List filters by name |
| 2 | Type ID card number | List filters by ID |
TC-TE-030: Filter by training status chips
| Step | Action | Expected |
|---|
| 1 | Click "ผ่าน" chip | Only passed workers shown, all disabled |
| 2 | Click "รอการอบรม" chip | Only pending workers, all disabled |
| 3 | Click "ยังไม่ได้อบรม" chip | Not-trained workers, selectable |
TC-TE-031: Deselect chip shows all
| Step | Action | Expected |
|---|
| 1 | Click active chip again | Chip deselected, all workers shown |
TC-TE-032: Select All only selects eligible
| Step | Action | Expected |
|---|
| 1 | Show all workers (deselect filter) | Mix of enabled/disabled |
| 2 | Click "เลือกทั้งหมด" | Only eligible workers selected |
| 3 | Disabled workers remain unchecked | Passed/Pending/Blacklisted not selected |
TC-TE-033: Blacklisted worker shows red badge
| Step | Action | Expected |
|---|
| 1 | Find blacklisted worker | Red badge visible |
| 2 | Row is grayed out | Cannot select |
TC-TE-034: Clicking disabled worker does nothing
| Step | Action | Expected |
|---|
| 1 | Click on a disabled worker row | No selection change |
| Step | Action | Expected |
|---|
| 1 | Select multiple workers | Checkboxes checked |
| 2 | Click "ยืนยันรายชื่อ (N)" | Dialog closes |
| 3 | Verify form | Workers added to worker list table |
| Step | Action | Expected |
|---|
| 1 | Select 3 workers | Button shows "ยืนยันรายชื่อ (3)" |
| 2 | Select 5 workers | Button shows "ยืนยันรายชื่อ (5)" |
8. Training Info Quick Enroll
Precondition: Login as Contractor
| Step | Action | Expected |
|---|
| 1 | Open Training Info (เครื่องมือ > ข้อมูลการอบรม) | Page loads |
| 2 | Find Open session | "ลงทะเบียน" button visible |
TC-TE-038: Progress bar during creation
| Step | Action | Expected |
|---|
| 1 | Click "ลงทะเบียน" | Progress bar appears below navbar |
TC-TE-039: Success toast and redirect
| Step | Action | Expected |
|---|
| 1 | Wait for task creation | Green toast: "สร้างงานส่งรายชื่อผู้อบรมสำเร็จ" |
| 2 | Verify navigation | Redirected to Task Review page for new task |
TC-TE-040: Register column hidden for SO
Precondition: Login as Safety Officer
| Step | Action | Expected |
|---|
| 1 | Open Training Info page | "ลงทะเบียน" column NOT visible |
| Step | Action | Expected |
|---|
| 1 | Find expired session | "ลงทะเบียน" button NOT shown |
| Step | Action | Expected |
|---|
| 1 | Find closed or full session | "ลงทะเบียน" button NOT shown |
9. Inbox Notifications
TC-TE-043: SO receives notification on submit
Precondition: Contractor submits enrollment
| Step | Action | Expected |
|---|
| 1 | Contractor submits training list | Task moves to ReviewBySafetyOfficer |
| 2 | Login as SO | Bell icon shows unread count |
| 3 | Click bell | Notification about new enrollment visible |
TC-TE-044: Contractor receives notification on approve
| Step | Action | Expected |
|---|
| 1 | SO approves enrollment | Task completed |
| 2 | Login as Contractor | Bell icon shows unread count |
| 3 | Check notification | Approval notification visible |
TC-TE-045: Contractor receives notification on reject
| Step | Action | Expected |
|---|
| 1 | SO rejects enrollment | Task rejected |
| 2 | Login as Contractor | Rejection notification visible |
TC-TE-046: Click notification navigates to task
| Step | Action | Expected |
|---|
| 1 | Click on a notification | Navigate to related task review page |
TC-TE-047: Mark notifications as read
| Step | Action | Expected |
|---|
| 1 | Open inbox page | Notifications listed |
| 2 | Select notifications → Mark as read | Badge count decreases |
TC-TE-048: Archive notifications
| Step | Action | Expected |
|---|
| 1 | Select notifications → Archive | Notifications removed from list |
TC-TE-049: Bell icon shows correct count
| Step | Action | Expected |
|---|
| 1 | Check bell icon | Shows unread notification count |
| 2 | Mark all as read | Badge disappears or shows 0 |
TC-TE-050: Notification on request change
| Step | Action | Expected |
|---|
| 1 | SO sends back for changes | Task returns to FillInTrainingList |
| 2 | Login as Contractor | Notification about changes needed |
Summary
| Category | Test Cases | Count |
|---|
| 1. Form Validation | TC-TE-001 to 006 | 6 |
| 2. Auto-Navigation | TC-TE-007 to 009 | 3 |
| 3. Document View Gating | TC-TE-010 to 013 | 4 |
| 4. Block Duplicate Enrollment | TC-TE-014 to 016 | 3 |
| 5. Partial Approval | TC-TE-017 to 021 | 5 |
| 6. Training Attendance Verification | TC-TE-022 to 027 | 6 |
| 7. Worker Selection Dialog | TC-TE-028 to 036 | 9 |
| 8. Training Info Quick Enroll | TC-TE-037 to 042 | 6 |
| 9. Inbox Notifications | TC-TE-043 to 050 | 8 |
| Total | | 50 |