This document defines the standards for organizing and naming tests in the Encore Health OS codebase. Spec traceability: For which tests cover which specs, see SPEC_TEST_COVERAGE.md. Any test that implements scenarios from a feature spec MUST include anDocumentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
@spec CORE-## tag in the file header (e.g. @spec FA-20).
Directory Structure
All tests are organized in thetests/ directory by test type:
Naming Conventions
RLS Tests
Pattern:{core}-{table}.rls.test.ts
Examples:
pf-organizations.rls.test.tshr-employees.rls.test.tsfa-journal-entries.rls.test.tsfw-forms.rls.test.ts
- Always use
.rls.test.tssuffix - Include core prefix (pf, hr, fa, fw, etc.)
- Use table name (singular or plural as in database)
- Flat structure (no subdirectories)
Unit Tests
Pattern:{core}/{feature}.test.ts or {core}/{feature}.test.tsx
Examples:
pf/formatting-utilities.test.tshr/useEmployees.test.tshr/onboarding-wizard-steps.test.tsxfa/journal-entries.test.ts
- Use
.test.tsor.test.tsxsuffix - Organize by module in subdirectories
- Use descriptive feature/hook/utility name
- Use
.tsxfor component tests
Integration Tests
Pattern:{core}/{workflow}-workflow.test.ts or {core}/{feature}-integration.test.ts
Examples:
hr/onboarding-workflow.test.tsfa/budget-template-workflow.test.tsfw/form-submission-workflow.test.tspf/permissions-system.test.tsx
- Use
-workflow.test.tssuffix for workflow tests - Use
-integration.test.tssuffix for feature integration tests - Organize by module in subdirectories
- Describe the complete workflow being tested
E2E Tests
Pattern:{core}/{feature}.spec.ts
Authentication: Specs that hit authenticated routes must use the shared auth fixture or the chromium-authenticated project. See TESTING_SETUP_AND_RUN.md.
Examples:
auth/authentication-flow.test.tshr/employee-management.spec.tsfa/financial-transactions.spec.tsplatform/search-filter-sort.spec.ts
- Use
.spec.tssuffix (Playwright convention) - Organize by module in subdirectories
- Use descriptive feature name
- Focus on critical user journeys
Test File Organization Rules
When to Use Each Test Type
| Test Type | When to Use | Example |
|---|---|---|
| RLS | Testing row-level security policies | hr-employees.rls.test.ts |
| Unit | Testing isolated functions, hooks, utilities | hr/useEmployees.test.ts |
| Integration | Testing cross-component workflows | hr/onboarding-workflow.test.ts |
| E2E | Testing complete user journeys | hr/employee-management.spec.ts |
Co-location vs Centralization
Current Standard: Centralized- All tests go in
tests/directory - Tests are organized by type (rls, unit, integration, e2e)
- Module organization within each type
src/__tests__/:
src/platform/wizards/utils/__tests__/src/platform/navigation/__tests__/
tests/ directory unless there’s a specific reason for co-location.
Module Organization
Core Modules
Tests are organized by core module:pf/- Platform Foundationhr/- Human Resourcesfa/- Finance & Accountingfw/- Forms & Workflowrh/- Recovery Housingfm/- Facilities Managementit/- IT Asset Managementce/- Community Engagementlo/- Leadership Operating Systemgr/- Governance & Compliance
Special Categories
Some test types have special categories:e2e/auth/- Authentication flowse2e/security/- Security testse2e/performance/- Performance testse2e/visual/- Visual regression tests
Test Structure Standards
RLS Test Structure
Unit Test Structure
Integration Test Structure
Migration Checklist
When reorganizing existing tests:- Move RLS tests to flat
tests/rls/structure - Ensure all RLS tests use
{core}-{table}.rls.test.tsnaming - Organize unit tests by module in
tests/unit/{core}/ - Organize integration tests by module in
tests/integration/{core}/ - Organize E2E tests by module in
tests/e2e/{core}/ - Update imports to use new locations
- Update test scripts if needed
- Verify all tests still run