> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# HR Module E2E Test Scenarios

> Version: 1.0.0 Last Updated: 2026-02-09 Module: HR (Human Resources) - Hiring to Onboarding Integration Status: Active

**Version:** 1.0.0\
**Last Updated:** 2026-02-09\
**Module:** HR (Human Resources) - Hiring to Onboarding Integration\
**Status:** Active

***

## Overview

This document defines comprehensive end-to-end (E2E) test scenarios for the HR module, focusing on real-world workflows from job posting through employee onboarding. Each scenario includes step-by-step instructions, test data setup, validation assertions, and database verification queries.

### Scope

* **HR-09:** Applicant Tracking System (ATS) - Job postings, applications, offers
* **HR-03:** Onboarding - Checklists, credentials, benefits, tax forms, skills
* **HR-01:** Employee Directory - Employee records and profiles
* **Cross-Module:** Event-driven integration between ATS and Onboarding

### Test Environment

* **Organization:** NorthSight Recovery (Test Org ID: `75fc234d-79e9-461f-8cab-1cbe0384b1d2`)
* **Database:** Lovable Cloud (Supabase)
* **Test Users:** See [Test Data Setup](#test-data-setup)
* **Duration:** \~30-45 minutes per full scenario

***

## Test Data Setup

### Users

| Email                                   | Role                 | Department | Organization     |
| --------------------------------------- | -------------------- | ---------- | ---------------- |
| `jbloom@northsightrecovery.com`         | org\_admin           | Admin      | Encore Health OS |
| `hiring-manager@northsightrecovery.com` | department\_manager  | Clinical   | Encore Health OS |
| `hr-admin@northsightrecovery.com`       | hr\_admin            | HR         | Encore Health OS |
| `test-candidate@example.com`            | candidate (external) | N/A        | N/A              |

### Required Database Records

Before running E2E tests, ensure these records exist:

```sql theme={null}
-- Verify organization
SELECT id, name FROM pf_organizations 
WHERE id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';

-- Verify test users
SELECT id, email, organization_id FROM pf_profiles 
WHERE email IN ('jbloom@northsightrecovery.com', 'hiring-manager@northsightrecovery.com', 'hr-admin@northsightrecovery.com');

-- Verify default department
SELECT id, name FROM pf_departments 
WHERE organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2'
AND name = 'Clinical';

-- Verify onboarding template exists
SELECT id, name FROM hr_onboarding_templates 
WHERE organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2'
AND name = 'Standard Onboarding';

-- Verify auto-onboarding is enabled
SELECT auto_create_onboarding, default_onboarding_template_id 
FROM hr_module_settings 
WHERE organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';
```

***

## Journey 5: Hiring to Onboarding (Full Cycle)

**Objective:** Test the complete workflow from job posting through employee onboarding initiation when an offer is accepted.

**Scenario:** Hire a new Clinical Therapist through the ATS and verify automatic onboarding creation.

**Expected Duration:** 30-45 minutes

### Phase 1: Job Posting (Steps 1-8)

#### Step 1: Log in as Hiring Manager

* **Actor:** Hiring Manager (`hiring-manager@northsightrecovery.com`)
* **Action:** Log in to application
* **Expected Result:** Redirect to HR dashboard with hiring manager role

#### Step 2: Navigate to Job Postings

* **Actor:** Hiring Manager
* **Path:** HR → Recruitment → Job Postings
* **Expected Result:** Job postings list displays

#### Step 3: Create New Job Posting

* **Actor:** Hiring Manager
* **Action:** Click "Create Job Posting"
* **Form Data:**
  * **Position Title:** Clinical Therapist - Test
  * **Position Level:** 3 (Full Time)
  * **Department:** Clinical
  * **Status:** Active
  * **Description:** "Test position for E2E testing"
  * **Qualifications:** "LCSW license required"
  * **Salary Min:** 55000
  * **Salary Max:** 75000
* **Expected Result:** Job posting created, receives UUID

**Verification Query:**

```sql theme={null}
SELECT id, position_title, position_level, status, created_by 
FROM hr_job_postings 
WHERE position_title = 'Clinical Therapist - Test'
AND organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';
```

#### Step 4: Publish Job Posting

* **Actor:** Hiring Manager
* **Action:** Update job posting status to "Published"
* **Expected Result:** Status changes, posting becomes visible to candidates

#### Step 5: Navigate to Candidates

* **Actor:** Hiring Manager
* **Path:** HR → Recruitment → Candidates
* **Expected Result:** Candidates list displays (initially empty or with existing candidates)

#### Step 6: Create Candidate Manually (or use external application)

* **Actor:** Hiring Manager OR Candidate submits through portal
* **Option A - Manual Creation:**
  * Click "Add Candidate"
  * **Form Data:**
    * **First Name:** John
    * **Last Name:** Applicant
    * **Email:** `test-candidate-e2e-001@example.com`
    * **Phone:** 480-555-0001
    * **Source:** Direct Application
  * Click "Save"
* **Expected Result:** Candidate created with UUID

**Verification Query:**

```sql theme={null}
SELECT id, first_name, last_name, email, organization_id 
FROM hr_candidates 
WHERE email = 'test-candidate-e2e-001@example.com'
AND organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';
```

#### Step 7: Create Application

* **Actor:** Hiring Manager
* **Action:**
  * Go to candidate detail
  * Click "Create Application"
  * Select the job posting created in Step 3
  * Click "Submit"
* **Expected Result:** Application created in "applied" stage

**Verification Query:**

```sql theme={null}
SELECT id, job_posting_id, candidate_id, current_stage, status 
FROM hr_applications 
WHERE candidate_id = (SELECT id FROM hr_candidates WHERE email = 'test-candidate-e2e-001@example.com')
AND organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';
```

#### Step 8: Verify Application in Pipeline

* **Actor:** Hiring Manager
* **Path:** HR → Recruitment → Applications or Pipeline
* **Expected Result:** Application appears in "Applied" stage with candidate name and position

***

### Phase 2: Application Screening & Interview (Steps 9-16)

#### Step 9: Screen Application

* **Actor:** Hiring Manager
* **Action:**
  * Open application detail
  * Scroll to "Screening" section
  * Click "Screen Candidate"
* **Form Data:**
  * **Screening Result:** Approved
  * **Notes:** "Strong background, excellent references"
* **Expected Result:** Application moves to "screened" stage

**Verification Query:**

```sql theme={null}
SELECT id, current_stage, status FROM hr_applications 
WHERE id = [application_id_from_step_7];
```

#### Step 10: Schedule Interview

* **Actor:** Hiring Manager
* **Action:**
  * In application detail, scroll to "Interview" section
  * Click "Schedule Interview"
* **Form Data:**
  * **Interview Type:** Phone Screening
  * **Scheduled Date:** \[Today + 3 days at 10:00 AM]
  * **Interviewer:** Hiring Manager
  * **Notes:** "Initial phone screening with candidate"
* **Expected Result:** Interview scheduled

**Verification Query:**

```sql theme={null}
SELECT id, interview_type, scheduled_at, interviewer_id 
FROM hr_interviews 
WHERE application_id = [application_id];
```

#### Step 11: Complete Interview (as Hiring Manager)

* **Actor:** Hiring Manager
* **Action:**
  * Open application
  * Navigate to scheduled interview
  * Click "Complete Interview"
* **Form Data:**
  * **Interview Result:** Passed
  * **Rating:** 4/5
  * **Feedback:** "Excellent communication skills, demonstrates strong knowledge of evidence-based practices"
  * **Next Step:** Proceed to offer
* **Expected Result:** Interview marked complete, application moves to "interviewed" stage

#### Step 12: Move to Offer (Alternative: Skip to Offer)

* **Actor:** Hiring Manager
* **Action:**
  * In application detail, click "Create Offer" button
  * OR go to Offers list and create new offer
* **Expected Result:** Offer creation form displays

#### Step 13: Create Job Offer

* **Actor:** Hiring Manager
* **Action:** Create offer with form data
* **Form Data:**
  * **Position:** Clinical Therapist - Test
  * **Applicant:** John Applicant
  * **Start Date:** \[Today + 30 days]
  * **Salary:** 65000
  * **Employment Type:** Full-Time
  * **Status:** Draft
  * **Notes:** "Welcome to the team!"
* **Expected Result:** Offer created in "draft" status

**Verification Query:**

```sql theme={null}
SELECT id, application_id, offer_status, start_date, salary 
FROM hr_offers 
WHERE application_id = [application_id];
```

#### Step 14: Send Offer

* **Actor:** Hiring Manager
* **Action:**
  * Open offer detail
  * Click "Send Offer to Candidate"
  * Confirm sending
* **Expected Result:** Offer status changes to "pending", candidate receives notification

**Expected Behavior:** Email or notification sent to candidate with offer details

#### Step 15: Candidate Reviews Offer (Manual or Automated)

* **Actor:** Candidate OR Hiring Manager on behalf of candidate
* **Action (if manual via candidate portal):**
  * Candidate receives email link or logs into candidate portal
  * Views offer details
  * Accepts or declines offer
* **Action (if testing via backend directly):**
  * Skip to Step 16 - simulate acceptance
* **Expected Result:** Offer status updates based on candidate action

#### Step 16: Accept Offer (Trigger Hiring)

* **Actor:** Hiring Manager (acting as administrator) OR Candidate (in portal)
* **Action:**
  * Open offer detail
  * Click "Accept Offer" button
  * Add optional acceptance notes
  * Confirm acceptance
* **Expected Result:**
  * Offer status changes to "accepted"
  * `accepted_at` timestamp recorded
  * Employee record created automatically (via database trigger)
  * `hr_employee_hired` event published
  * Onboarding instance created (if auto\_create\_onboarding enabled)

**Verification Query:**

```sql theme={null}
SELECT id, offer_status, accepted_at FROM hr_offers 
WHERE id = [offer_id];

-- Verify employee was created
SELECT id, first_name, last_name, email, hire_date 
FROM hr_employees 
WHERE candidate_id = [candidate_id]
AND organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';

-- Verify onboarding instance was created
SELECT id, employee_id, status, start_date 
FROM hr_onboarding_instances 
WHERE employee_id = [new_employee_id];
```

***

### Phase 3: Employee Record Verification (Steps 17-20)

#### Step 17: Verify Employee Created

* **Actor:** HR Admin
* **Path:** HR → Employee Directory → All Employees
* **Expected Result:** New employee appears in list with:
  * Name: John Applicant
  * Hire Date: \[Start date from offer]
  * Department: Clinical
  * Status: Active (or New)

#### Step 18: View Employee Detail

* **Actor:** HR Admin
* **Action:** Click on new employee
* **Expected Result:** Employee profile displays with:
  * Full contact information
  * Hire date
  * Department and manager
  * Employment status
  * Link to onboarding

#### Step 19: Verify Hire Transitions Recorded

* **Actor:** HR Admin (optional deep dive)
* **Query:** Database verification only

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, from_status, to_status, transition_date, reason 
FROM hr_hire_transitions 
WHERE employee_id = [new_employee_id];
```

#### Step 20: Verify Event Published (optional)

* **Actor:** System/Audit (verification only)
* **Query:** Check event logs (if available in your infrastructure)

**Verification Query:**

```sql theme={null}
SELECT id, organization_id, event_name, payload, created_at 
FROM pf_events 
WHERE event_name = 'hr_employee_hired'
AND payload->>'employee_id' = '[new_employee_id]'
ORDER BY created_at DESC 
LIMIT 1;
```

***

### Phase 4: Onboarding Instance Creation & Configuration (Steps 21-28)

#### Step 21: Verify Onboarding Instance Created

* **Actor:** Employee OR HR Admin
* **Expected Result:** Onboarding instance exists with correct configuration

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, status, start_date, created_by 
FROM hr_onboarding_instances 
WHERE employee_id = [new_employee_id]
ORDER BY created_at DESC 
LIMIT 1;
```

#### Step 22: Navigate to Employee Onboarding Hub

* **Actor:** New Employee (simulated)
* **Path:** HR → My Onboarding (or as new employee)
* **Expected Result:** Onboarding hub loads with:
  * Overall progress (should be 0% or minimal)
  * 6 section cards: Tasks, Credentials, Benefits, Tax Forms, Skills, Job Description
  * Timeline view showing Day 1 to Day 90
  * Milestone indicators

#### Step 23: Verify Onboarding Task Instances Created

* **Actor:** System verification
* **Expected Result:** Tasks created from template

**Verification Query:**

```sql theme={null}
SELECT id, onboarding_instance_id, task_template_id, status, due_date 
FROM hr_onboarding_task_instances 
WHERE onboarding_instance_id = [onboarding_instance_id]
ORDER BY due_date ASC;

-- Count tasks by status
SELECT status, COUNT(*) as count 
FROM hr_onboarding_task_instances 
WHERE onboarding_instance_id = [onboarding_instance_id]
GROUP BY status;
```

#### Step 24: Verify Task Count and Types

* **Expected Result:** Standard Onboarding template creates \~15-20 tasks including:
  * IT setup tasks
  * Compliance tasks
  * Department-specific tasks

#### Step 25: Access Tasks Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Your Tasks
* **Expected Result:** Task list displays with:
  * Task names and descriptions
  * Due dates
  * Status indicators
  * Ability to mark complete

#### Step 26: Complete First Task

* **Actor:** New Employee
* **Action:**
  * Click first task (usually IT-related)
  * Read instructions
  * Click "Mark Complete"
* **Expected Result:** Task status changes to "completed", overall progress updates

**Verification Query:**

```sql theme={null}
SELECT status, COUNT(*) FROM hr_onboarding_task_instances 
WHERE onboarding_instance_id = [onboarding_instance_id]
GROUP BY status;
```

#### Step 27: Verify Progress Updated

* **Actor:** New Employee
* **Expected Result:**
  * Task shows as completed
  * Overall progress percentage increased
  * Dashboard updates to show new progress

#### Step 28: Check Benefits Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Benefits Enrollment
* **Expected Result:** Benefits section displays:
  * Available plans
  * Enrollment deadline
  * "Not Started" status until employee enrolls

***

### Phase 5: Manager Monitoring (Steps 29-36)

#### Step 29: Navigate to Onboarding Command Center

* **Actor:** Manager (`hiring-manager@northsightrecovery.com`)
* **Path:** HR → Admin → Onboarding Command Center
* **Expected Result:** Dashboard displays with:
  * Summary cards (active onboardings, at-risk count)
  * Status grid showing all team member onboardings

#### Step 30: Find New Employee in Status Grid

* **Actor:** Manager
* **Expected Result:** New employee (John Applicant) appears in grid showing:
  * Name
  * Progress percentage (currently low, \~5%)
  * Status in each section (Checklist, Credentials, Benefits, Tax, Skills, Job Description)

#### Step 31: View Employee Detail from Command Center

* **Actor:** Manager
* **Action:** Click on new employee row
* **Expected Result:** Detailed onboarding view displays showing:
  * Current milestone (Day 1)
  * Section progress breakdown
  * At-risk indicators (if applicable)
  * Quick actions menu

#### Step 32: Schedule 30-Day Check-in

* **Actor:** Manager
* **Action:**
  * In employee onboarding detail
  * Find "Milestones" section
  * Click "Schedule 30-Day Check-in"
* **Form Data:**
  * **Date:** \[Today + 30 days]
  * **Time:** 2:00 PM
  * **Location:** Zoom (or in-person)
  * **Notes:** "Review first month progress"
* **Expected Result:** Check-in scheduled

**Verification Query:**

```sql theme={null}
SELECT id, onboarding_instance_id, milestone_type, scheduled_at, status 
FROM hr_milestone_check_ins 
WHERE onboarding_instance_id = [onboarding_instance_id]
AND milestone_type = '30_day';
```

#### Step 33: Send Reminder to Employee

* **Actor:** Manager
* **Action:**
  * In employee onboarding detail
  * Click "Send Reminder"
  * Select sections to remind about
  * Confirm
* **Expected Result:**
  * Notification created for employee
  * HR system records reminder sent
  * Employee receives notification/email

**Verification Query:**

```sql theme={null}
SELECT id, recipient_id, notification_type, subject, created_at 
FROM pf_notifications 
WHERE recipient_id = [new_employee_id]
AND notification_type LIKE '%onboarding%'
ORDER BY created_at DESC 
LIMIT 5;
```

#### Step 34: View HR Settings (Optional)

* **Actor:** HR Admin
* **Path:** HR → Settings → Onboarding Configuration
* **Expected Result:** Settings page shows:
  * `auto_create_onboarding` toggle (should be ON)
  * `default_onboarding_template_id` (should be set)
  * Milestone date configuration
  * Task deadline defaults

#### Step 35: Verify Auto-Onboarding Setting

* **Query:** Confirm auto-create is enabled

**Verification Query:**

```sql theme={null}
SELECT auto_create_onboarding, default_onboarding_template_id 
FROM hr_module_settings 
WHERE organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';
-- Expected: auto_create_onboarding = true
```

#### Step 36: Monitor Overall Progress

* **Actor:** Manager
* **Action:** Periodically refresh Command Center to see progress updates
* **Expected Result:** Progress percentage increases as employee completes sections

***

### Phase 6: Credentials & Compliance (Steps 37-44)

#### Step 37: Navigate to Credentials Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Professional Credentials
* **Expected Result:** Credentials section displays:
  * Required credentials list
  * "Not Started" status
  * "Upload Credential" button

#### Step 38: Upload License/Certification

* **Actor:** New Employee
* **Action:**
  * Click "Upload Credential"
  * Select credential type (e.g., "LCSW License")
  * Upload document (PDF or image)
  * Enter expiration date \[Today + 3 years]
  * Submit
* **Expected Result:** Credential uploaded and shown as "Pending Verification"

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, credential_type, file_path, expiration_date, verification_status 
FROM hr_employee_credentials 
WHERE employee_id = [new_employee_id];
```

#### Step 39: HR Verifies Credential

* **Actor:** HR Admin
* **Path:** HR → Compliance → Credentials or Onboarding Command Center
* **Action:**
  * Find employee's credential
  * Review uploaded document
  * Click "Verify" or "Approve"
  * Add notes if needed
* **Expected Result:** Credential status changes to "Verified"

#### Step 40: Verify Credential Progress Updated

* **Actor:** New Employee
* **Expected Result:** Credentials section now shows:
  * 1 of 1 verified
  * Status changed to "In Progress" or "Completed"
  * Overall progress percentage increased

#### Step 41: Test Expiring Soon Alert

* **Actor:** System (optional - requires advanced date manipulation)
* **Query:** Test credential approaching expiration

#### Step 42: Repeat for Additional Credentials

* **Actor:** New Employee
* **Action:** If multiple credentials required, repeat Steps 38-40
* **Expected Result:** All required credentials uploaded and verified

#### Step 43: Verify Credentials Completion

* **Query:** Confirm all required credentials verified

**Verification Query:**

```sql theme={null}
SELECT COUNT(*) as total, 
       SUM(CASE WHEN verification_status = 'verified' THEN 1 ELSE 0 END) as verified 
FROM hr_employee_credentials 
WHERE employee_id = [new_employee_id]
AND is_required = true;
-- Expected: total = verified (all required credentials verified)
```

#### Step 44: Check Credentials Section Status

* **Actor:** New Employee
* **Expected Result:** Credentials section shows green checkmark, 100% completion

***

### Phase 7: Tax & Payroll Setup (Steps 45-52)

#### Step 45: Navigate to Tax & Payroll Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Tax & Payroll
* **Expected Result:** Tax & Payroll section displays:
  * W-4 form status ("Not Started")
  * Direct deposit status ("Not Started")
  * Progress indicator

#### Step 46: Start W-4 Form

* **Actor:** New Employee
* **Action:**
  * Click "Complete W-4 Form"
  * Follow wizard steps
* **Form Data (Step 1):**
  * **First Name:** John
  * **Last Name:** Applicant
  * **SSN:** 123-45-6789 (test SSN)
  * **Address:** 1234 Test St, Phoenix, AZ 85001
* **Form Data (Step 2):**
  * **Filing Status:** Single
  * **Claim Dependents:** 0
  * **Other Income:** None
  * **Deductions:** Standard
* **Expected Result:** W-4 submitted and marked as pending

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, form_type, filing_status, claim_dependents, submission_status 
FROM hr_employee_tax_info 
WHERE employee_id = [new_employee_id];
```

#### Step 47: Set Up Direct Deposit

* **Actor:** New Employee
* **Action:**
  * In Tax & Payroll section, click "Set Up Direct Deposit"
  * Enter banking information
* **Form Data:**
  * **Bank Name:** Chase Bank
  * **Routing Number:** 021000021 (test routing)
  * **Account Number:** 123456789
  * **Account Type:** Checking
* **Expected Result:** Direct deposit configured

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, bank_name, account_type, is_active 
FROM hr_employee_bank_accounts 
WHERE employee_id = [new_employee_id];
```

#### Step 48: HR Verifies Tax Setup

* **Actor:** HR Admin or Payroll Staff
* **Action:**
  * Review W-4 form
  * Verify direct deposit information
  * Mark as processed
* **Expected Result:** Tax setup marked complete

#### Step 49: Verify Tax Section Status

* **Actor:** New Employee
* **Expected Result:** Tax & Payroll section shows:
  * W-4: ✅ Complete
  * Direct Deposit: ✅ Complete
  * Progress: 100%

#### Step 50: Test W-4 Update (Optional)

* **Actor:** New Employee
* **Action:**
  * If W-4 form updateable, modify claiming information
  * Resubmit
* **Expected Result:** New W-4 version created, previous archived

#### Step 51: Verify Payroll Integration

* **Query:** Confirm tax data linked to employee payroll record

**Verification Query:**

```sql theme={null}
SELECT e.id, e.first_name, t.filing_status, ba.account_type 
FROM hr_employees e
LEFT JOIN hr_employee_tax_info t ON e.id = t.employee_id
LEFT JOIN hr_employee_bank_accounts ba ON e.id = ba.employee_id
WHERE e.id = [new_employee_id];
```

#### Step 52: Check Tax Section Status

* **Actor:** New Employee
* **Expected Result:** Tax & Payroll section shows green checkmark, 100% completion

***

### Phase 8: Skills Assessment (Steps 53-60)

#### Step 53: Navigate to Skills Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Skills Assessment
* **Expected Result:** Skills section displays:
  * List of required job skills
  * Self-assessment rating scale
  * "Not Started" status

#### Step 54: Complete Skills Self-Assessment

* **Actor:** New Employee
* **Action:**
  * For each skill, select rating:
    * Novice / Intermediate / Advanced / Expert
  * Add comments for key skills
  * Submit
* **Form Data Examples:**
  * Evidence-Based Therapy: Intermediate
  * Assessment & Evaluation: Advanced
  * Documentation: Intermediate
  * Crisis Intervention: Novice
  * Clinical Supervision: Advanced
* **Expected Result:** Self-assessment submitted

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, skill_name, self_assessment_level, created_at 
FROM hr_employee_skills 
WHERE employee_id = [new_employee_id]
ORDER BY skill_name;
```

#### Step 55: Manager Verifies Skills

* **Actor:** Manager
* **Path:** Onboarding Command Center → Employee Detail → Skills Section
* **Action:**
  * Review employee's self-assessment
  * For each skill, confirm or adjust rating
  * Add manager feedback/coaching notes
  * Submit
* **Expected Result:** Manager verification recorded

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, skill_name, verified_level, manager_feedback, verified_at 
FROM hr_employee_skills 
WHERE employee_id = [new_employee_id]
AND verified_at IS NOT NULL;
```

#### Step 56: Identify Development Needs

* **Actor:** Manager (Optional - system analysis)
* **Expected Result:** Skills where self-assessment > manager verification identified as development areas

#### Step 57: Repeat Skills Verification

* **Actor:** Manager
* **Action:** Complete all required skills verification
* **Expected Result:** All skills have manager verification

#### Step 58: View Skills Verification Summary

* **Actor:** New Employee
* **Expected Result:** Skills section shows:
  * All skills listed with verified ratings
  * Manager feedback visible
  * Status: ✅ Complete

#### Step 59: Verify Skills Section Status

* **Query:** Confirm all required skills verified

**Verification Query:**

```sql theme={null}
SELECT COUNT(*) as total, 
       SUM(CASE WHEN verified_at IS NOT NULL THEN 1 ELSE 0 END) as verified 
FROM hr_employee_skills 
WHERE employee_id = [new_employee_id]
AND is_required = true;
-- Expected: total = verified
```

#### Step 60: Check Overall Progress Update

* **Actor:** New Employee
* **Expected Result:** Overall onboarding progress now \~70% (tasks, credentials, tax, skills mostly done)

***

### Phase 9: Benefits Enrollment & Job Description (Steps 61-68)

#### Step 61: Navigate to Benefits Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Benefits Enrollment
* **Expected Result:** Benefits section displays available plans with details

#### Step 62: Review Benefit Plans

* **Actor:** New Employee
* **Action:**
  * Click each plan category to view details:
    * Medical plans
    * Dental plans
    * Vision plans
    * 401(k) plan
  * Review coverage, costs, deductibles
* **Expected Result:** Plan information displays clearly

#### Step 63: Enroll in Benefits

* **Actor:** New Employee
* **Action:**
  * For each plan type, select to Enroll or Decline
  * If enrolling, select coverage level:
    * Medical: Employee + Spouse
    * Dental: Employee Only
    * Vision: Employee Only
    * 401(k): \$300/pay period
  * Review selections
  * Confirm enrollment
* **Expected Result:** Elections submitted

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, benefit_plan_id, enrollment_status, coverage_level, enrolled_at 
FROM hr_benefits_enrollments 
WHERE employee_id = [new_employee_id];
```

#### Step 64: Verify Benefits Enrollment

* **Actor:** HR Admin
* **Action:** Review employee's benefits elections
* **Expected Result:** All elections recorded correctly

#### Step 65: Navigate to Job Description Section

* **Actor:** New Employee
* **Path:** Onboarding Hub → Job Description
* **Expected Result:** Job description displays:
  * Position title
  * Key responsibilities
  * Reporting structure
  * "Acknowledge" button

#### Step 66: Review and Acknowledge Job Description

* **Actor:** New Employee
* **Action:**
  * Read job description
  * Click "I Acknowledge"
  * Confirm understanding
* **Expected Result:** Acknowledgment recorded with timestamp

**Verification Query:**

```sql theme={null}
SELECT id, employee_id, acknowledged_at, acknowledgment_version 
FROM hr_job_description_acknowledgments 
WHERE employee_id = [new_employee_id];
```

#### Step 67: Verify All Sections Complete

* **Actor:** New Employee
* **Expected Result:** Dashboard shows:
  * ✅ Your Tasks: \~90% (most complete)
  * ✅ Credentials: 100% (all verified)
  * ✅ Benefits: 100% (all enrolled)
  * ✅ Tax Forms: 100% (W-4 + Direct Deposit)
  * ✅ Skills: 100% (all verified)
  * ✅ Job Description: 100% (acknowledged)
  * **Overall Progress: \~95-100%**

**Final Progress Verification Query:**

```sql theme={null}
SELECT 
  oi.id as onboarding_instance_id,
  oi.employee_id,
  oi.status,
  oi.overall_progress_percent,
  (SELECT COUNT(*) FROM hr_onboarding_task_instances WHERE onboarding_instance_id = oi.id AND status = 'completed') as tasks_completed,
  (SELECT COUNT(*) FROM hr_employee_credentials WHERE employee_id = oi.employee_id AND verification_status = 'verified') as credentials_verified,
  (SELECT COUNT(*) FROM hr_benefits_enrollments WHERE employee_id = oi.employee_id AND enrollment_status = 'enrolled') as benefits_enrolled,
  (SELECT COUNT(*) FROM hr_employee_tax_info WHERE employee_id = oi.employee_id AND submission_status = 'processed') as tax_forms_complete,
  (SELECT COUNT(*) FROM hr_employee_skills WHERE employee_id = oi.employee_id AND verified_at IS NOT NULL) as skills_verified
FROM hr_onboarding_instances oi
WHERE oi.employee_id = [new_employee_id];
```

#### Step 68: Complete Onboarding (Optional - Requires Day 90 Check-in)

* **Actor:** Manager or HR Admin
* **Action:**
  * After Day 90 milestone check-in completed
  * Click "Complete Onboarding"
  * Mark as successful transition to standard employee status
* **Expected Result:**
  * Onboarding status changes to "completed"
  * Employee moved to full active status (if applicable)
  * Onboarding instance archived/closed

**Final Status Verification Query:**

```sql theme={null}
SELECT id, employee_id, status, completed_at, completion_notes 
FROM hr_onboarding_instances 
WHERE employee_id = [new_employee_id];
-- Expected: status = 'completed', completed_at populated
```

***

## Success Criteria

### Phase 1: Job Posting ✅

* [ ] Job posting created and published
* [ ] Application created from candidate
* [ ] Status workflow functioning (applied → screened → interviewed)

### Phase 2: Hiring Process ✅

* [ ] Interviews can be scheduled and completed
* [ ] Offer created and sent to candidate
* [ ] Offer acceptance triggers employee creation

### Phase 3: Employee Record ✅

* [ ] Employee record created on offer acceptance
* [ ] Hire date correctly set from offer start date
* [ ] Employee visible in directory within 5 seconds
* [ ] Hire transitions recorded in audit table

### Phase 4: Auto-Onboarding ✅

* [ ] Onboarding instance created automatically on offer acceptance
* [ ] Onboarding instance uses configured default template
* [ ] Onboarding tasks created from template (15-20 tasks)
* [ ] Employee can access onboarding hub immediately

### Phase 5: Manager Monitoring ✅

* [ ] Manager can view employee in Command Center
* [ ] Manager can see real-time progress updates
* [ ] Manager can schedule check-ins
* [ ] Manager can send reminders to employee

### Phase 6: Credentials ✅

* [ ] Credentials section displays required credentials
* [ ] Employee can upload documents
* [ ] HR can verify credentials
* [ ] Progress updates when credentials verified

### Phase 7: Tax & Payroll ✅

* [ ] W-4 form completable and submittable
* [ ] Direct deposit setup completable
* [ ] Tax data linked to employee record
* [ ] Tax section shows completion status

### Phase 8: Skills ✅

* [ ] Skills assessment available for employee
* [ ] Manager can verify skills with feedback
* [ ] All required skills can be verified
* [ ] Skills section reflects completion

### Phase 9: Benefits & Job Description ✅

* [ ] Benefits enrollment available with plan details
* [ ] Employee can enroll in multiple plans
* [ ] Job description acknowledgment recordable
* [ ] Overall progress reaches 95-100% on completion

### Integration Points ✅

* [ ] Event published on offer acceptance
* [ ] Onboarding created within 2-5 seconds of offer acceptance
* [ ] No gaps in data flow from hiring to onboarding
* [ ] Multi-tenant security enforced throughout (only see own data)
* [ ] All timestamps accurate and consistent

***

## Troubleshooting & Edge Cases

### Issue: Onboarding Not Created

**Symptoms:** Employee hired but no onboarding instance visible

**Checks:**

1. Verify `auto_create_onboarding = true` in hr\_module\_settings
2. Verify `default_onboarding_template_id` is set to valid template
3. Check for errors in browser console during offer acceptance
4. Check database logs for RPC call errors

**Resolution:**

```sql theme={null}
-- Verify setting
SELECT auto_create_onboarding, default_onboarding_template_id 
FROM hr_module_settings 
WHERE organization_id = '75fc234d-79e9-461f-8cab-1cbe0384b1d2';

-- Verify template exists
SELECT id, name FROM hr_onboarding_templates 
WHERE id = [template_id];

-- Manually trigger if needed (advanced)
SELECT create_onboarding_from_template(
  _employee_id := [employee_id],
  _template_id := [template_id],
  _start_date := CURRENT_DATE,
  _created_by := [user_id]
);
```

### Issue: Progress Not Updating

**Symptoms:** Task completed but progress percentage stays same

**Checks:**

1. Refresh page to see updated progress
2. Verify task is actually marked complete in database
3. Check if progress calculation is accurate

**Resolution:**

```sql theme={null}
-- Verify task completion
SELECT status, COUNT(*) 
FROM hr_onboarding_task_instances 
WHERE onboarding_instance_id = [onboarding_instance_id]
GROUP BY status;

-- Manually recalculate progress (if available)
SELECT recalculate_onboarding_progress([onboarding_instance_id]);
```

### Issue: Employee Can See Others' Onboarding

**Symptoms:** RLS policy not enforcing multi-tenant security

**Checks:**

1. Verify RLS policies enabled on all hr tables
2. Verify current\_user\_id() function available
3. Check policy conditions reference auth.uid()

**Resolution:**

```sql theme={null}
-- Check RLS policies
SELECT * FROM pg_policies 
WHERE schemaname = 'public' 
AND tablename LIKE 'hr_%';

-- Verify policies have correct conditions
SELECT tablename, policyname, qual 
FROM pg_policies 
WHERE schemaname = 'public'
AND tablename = 'hr_onboarding_instances';
```

***

## Regression Tests (Quick Verification)

For quick smoke testing of the hiring-to-onboarding flow, run these steps:

1. Create job posting
2. Add candidate
3. Create application
4. Accept offer
5. Verify employee created
6. Verify onboarding instance created
7. Verify tasks exist
8. Verify manager can see employee in Command Center

**Expected Duration:** 5-10 minutes

***

## Appendix: Test Data Cleanup

After E2E testing, clean up test data in reverse dependency order:

```sql theme={null}
-- WARNING: Use only in test environment
BEGIN TRANSACTION;

-- Delete onboarding data
DELETE FROM hr_onboarding_task_instances 
WHERE onboarding_instance_id IN (
  SELECT id FROM hr_onboarding_instances 
  WHERE employee_id = [test_employee_id]
);

DELETE FROM hr_onboarding_instances 
WHERE employee_id = [test_employee_id];

-- Delete employee data
DELETE FROM hr_employee_skills 
WHERE employee_id = [test_employee_id];

DELETE FROM hr_employee_credentials 
WHERE employee_id = [test_employee_id];

DELETE FROM hr_employee_bank_accounts 
WHERE employee_id = [test_employee_id];

DELETE FROM hr_employee_tax_info 
WHERE employee_id = [test_employee_id];

DELETE FROM hr_hire_transitions 
WHERE employee_id = [test_employee_id];

DELETE FROM hr_employees 
WHERE id = [test_employee_id];

-- Delete application/offer data
DELETE FROM hr_interviews 
WHERE application_id = [test_application_id];

DELETE FROM hr_offers 
WHERE application_id = [test_application_id];

DELETE FROM hr_applications 
WHERE id = [test_application_id];

DELETE FROM hr_candidates 
WHERE id = [test_candidate_id] 
AND (email LIKE '%test%' OR email LIKE '%e2e%');

COMMIT;
```

***

**Document Status:** Complete and tested\
**Last Updated:** 2026-02-09\
**Next Review:** 2026-05-09 or after major ATS/Onboarding changes
