> ## 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.

# CL Testing Gaps

> Last Updated: 2026-02-24 Purpose: Track missing RLS, unit, integration, and E2E tests for the Clinical (CL) core. Use to prioritize Phase B–D work and manual r…

**Last Updated:** 2026-02-24\
**Purpose:** Track missing RLS, unit, integration, and E2E tests for the Clinical (CL) core. Use to prioritize Phase B–D work and manual review (Phase E).

**See also:** [SPEC\_TEST\_COVERAGE.md](SPEC_TEST_COVERAGE.md) (spec–test matrix), [TESTING\_SETUP\_AND\_RUN.md](TESTING_SETUP_AND_RUN.md), .cursor/rules/testing-completion.mdc.

***

## Summary

| Category        | Status  | Notes                                                                                                                    |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| **RLS**         | Partial | 6 CL tables missing RLS tests (see below). Run `npm run check-rls-coverage -- --missing-only` to refresh.                |
| **Unit**        | Partial | Several CL specs have unit tests; not all hooks/utils covered.                                                           |
| **Integration** | Partial | CL-01, CL-02, CL-03, CL-17, CL-21 have workflow tests; others may need coverage.                                         |
| **E2E**         | Gap     | No dedicated `tests/e2e/cl/` Playwright suite; critical flows (consent, progress notes, risk screening) should be added. |

## Quick Reference

| I need to…     | Pattern                                        | Location                  |
| -------------- | ---------------------------------------------- | ------------------------- |
| Run RLS check  | `npm run check-rls-coverage -- --missing-only` | RLS: Tables Missing Tests |
| Run unit audit | `npm run test:audit:completeness`              | Refreshing This Document  |
| Add E2E specs  | Create `tests/e2e/cl/*.spec.ts`                | E2E: Gaps                 |

***

## RLS: Tables Missing Tests

As of the last `check-rls-coverage --missing-only` run (with `cl_` in CORE\_PREFIXES):

| Table                 | Spec(s)                   | Action                                                                                          |
| --------------------- | ------------------------- | ----------------------------------------------------------------------------------------------- |
| `cl_group_attendance` | CL-14 (Group Therapy)     | Add `tests/rls/cl/cl-14-group-attendance.rls.test.ts` (or cover in existing group-session test) |
| `cl_group_sessions`   | CL-14                     | Add or extend RLS test for group sessions                                                       |
| `cl_outcome_measures` | CL-10 (Outcomes Tracking) | Add RLS test when implementing                                                                  |
| `cl_pharmacies`       | CL-06 (E-Prescribing)     | Add RLS test                                                                                    |
| `cl_prescriptions`    | CL-06                     | Add RLS test                                                                                    |
| `cl_program_outcomes` | CL-10                     | Add RLS test when implementing                                                                  |

**CL tables that already have RLS test coverage** (via existing `tests/rls/cl/*.rls.test.ts` or `.from()` usage):\
cl\_patient\_charts (cl-01), cl\_assessments / sections / instruments (cl-02), cl\_treatment\_plans / goals / interventions / signatures (cl-03), cl\_risk\_screenings, cl\_safety\_plans (cl-07), cl\_cds\_rules / cl\_cds\_alerts (cl-08), cl\_care\_teams / cl\_transitions (cl-12), `cl_pdmp_*` (cl-17), `cl_moud_*` (cl-21), and others covered by the same test files.

***

## Unit: Gaps

* **Covered:** CL-01–CL-03 (chart, assessment, treatment plan utils), CL-07 (risk screening), CL-08 (CDS evaluate), CL-09 (lab orders, result parsing, CDS lab monitoring), CL-11 (consent), CL-12 (care coordination), CL-17/CL-21 (via integration), vitals trend, progress note content, export audit, break-glass authorization.
* **Gaps:** Other CL specs’ hooks and services (e.g. CL-04 progress notes, CL-05/06 meds/e-prescribing, CL-10 outcomes, CL-11 disclosure log, CL-13 crisis, CL-15 reporting, CL-16 FHIR, CL-18/19 SDOH/peer, CL-20 export, CL-22 vitals) — add unit tests as those areas are implemented or touched.

***

## Integration: Gaps

* **Covered:** CL-01 (chart workflow), CL-02 (assessment workflow), CL-03 (treatment plan workflow), CL-17 (PDMP workflow), CL-21 (MOUD workflow).
* **Gaps:** CL-04 (progress notes), CL-05/06 (medication/e-prescribing), CL-10–11 (outcomes, consent flows), CL-14 (group therapy), CL-18/19 (SDOH, peer), CL-20 (export), etc. Add integration tests for workflows that cross modules or use Supabase.

***

## E2E: Gaps

* **Current:** No `tests/e2e/cl/` directory; no Playwright specs tagged for CL-only runs.
* **Recommended:** Add E2E for critical CL flows per plan Phase D: consent capture (CL-11), progress note creation (CL-04), risk screening (CL-07), and key dashboards/reporting (CL-15). Create `tests/e2e/cl/` and add specs (e.g. `consent-capture.spec.ts`, `progress-note-flow.spec.ts`, `risk-screening.spec.ts`).

***

## Manual Review (Phase E)

After automated tests are in place, a human should:

1. Confirm test assertions match spec acceptance criteria (no tautological or placeholder assertions).
2. Spot-check 2–3 CL specs (e.g. CL-11, CL-15, CL-22) against implemented code and tests.
3. Verify [REGULATORY\_COMPLIANCE\_TRACKER.md](../compliance/REGULATORY_COMPLIANCE_TRACKER.md) (or CL-specific compliance notes) for tests that assert compliance-related behavior (e.g. Part 2, PDMP, incident deadlines).

***

## Refreshing This Document

1. Run `npm run test:audit:completeness` and inspect reports for CL.
2. Run `npx tsx scripts/check-rls-coverage.ts --missing-only` and update the “RLS: Tables Missing Tests” table.
3. Update [SPEC\_TEST\_COVERAGE.md](SPEC_TEST_COVERAGE.md) CL Core section when adding or changing tests.
