Layer Test Reports Specification
Comprehensive test strategy for each architectural layer. Each layer defines the exact tests required, the test report format, and completeness metrics to verify validity.
Test Requirement Legend
π΄
Required β Must add/update tests for every feature
π‘
Optional β Only when feature specifically modifies this area
β«
Disabled β Not currently supported
Architecture Flow
β
β
β
β
β
β
β
1. Database Layer
lib/db/schema.ts, lib/db/migrations/
What This Layer Does
The foundation of data persistence using Drizzle ORM with Neon Postgres. Tables are defined with TypeScript, and Row Level Security (RLS) policies are specified inline using pgPolicy() to enforce multi-tenancy at the database level.
Why Test This Layer
Testing at this layer ensures your data model is correct before any application code runs. RLS policies act as a security backstopβeven if application code has bugs, the database itself prevents unauthorized data access across organizations.
Related Skills
Required Tests
π΄
Schema Validation Tests
Verify Drizzle schema definitions match database state
Test Types
β’
Table existence verification
β’
Column type validation
β’
Constraint verification (NOT NULL, UNIQUE, FK)
β’
Index existence checks
β’
Default value verification
Vitest
neon-testing
Drizzle Kit
$ pnpm vitest run --project integration tests/integration/schema/
π΄
Migration Tests
Ensure migrations apply cleanly and are reversible
Test Types
β’
Forward migration success
β’
Migration idempotency (re-run safety)
β’
Data preservation during migration
β’
Schema state after migration matches expected
Drizzle Kit
neon-testing
$ pnpm db:migrate && pnpm db:check
π΄
RLS Policy Tests
Verify Row Level Security policies enforce access control
Test Types
β’
Organization isolation (user A cannot see user B's data)
β’
Authenticated vs anonymous access
β’
CRUD operation permissions per role
β’
Cross-organization data leakage prevention
Vitest
neon-testing
Real database branches
$ pnpm vitest run --project integration tests/integration/rls/
Test Report Output
JSON report with table verification counts, migration status, RLS policy test results per table, constraint coverage percentage, and index verification status. HTML report provides visual diff of expected vs actual schema state.
Test Report: 1. Database Layer
| Metric | Description | Value |
|---|---|---|
| tables_verified | Number of tables with passing schema tests | 8/8 tables |
| migrations_status | All migrations applied successfully | β 42 migrations |
| rls_policies_tested | RLS policies verified per table | 32/32 policies |
| constraint_coverage | FK, UNIQUE, NOT NULL constraints verified | 100% |
| index_verification | All indexes exist and are used | 8/8 indexes |
Completeness Checklist
Every table in schema.ts has corresponding test file
All RLS policies (SELECT, INSERT, UPDATE, DELETE) tested for each table
All foreign key relationships verified with referential integrity tests
Default values tested for all columns with defaults
Test Coverage Summary
| Layer | Test Categories | Primary Tool | Report Type |
|---|---|---|---|
| 1. Database Layer | 3 | Vitest | JSON + HTML |
| 2. Data Access / Schema Layer | 3 | Vitest | JSON + HTML |
| 3. Service / Business Logic Layer | 3 | Vitest | JSON + HTML |
| 4. API Layer | 3 | Vitest | JSON + HTML |
| 5. State Management Layer | 3 | Vitest | JSON + HTML |
| 6. UI Component Layer | 4 | Storybook | JSON + HTML |
| 7. Pages / Views Layer | 4 | Playwright | JSON + HTML |
| 8. Observability Layer (Cross-cutting) | 3 | Vitest | JSON + HTML |
Quick Reference: Test Commands
# Run all tests
pnpm check
# Run by project
pnpm vitest run --project unit
pnpm vitest run --project integration
pnpm vitest run --project storybook
# Run E2E tests
pnpm playwright test
# Generate reports
pnpm vitest run --reporter=json --outputFile=test-results.json
pnpm playwright test --reporter=html