@@ -9,7 +9,7 @@ KNII Ticketing System - A professional support ticket management application wit
99** No ORM** : Raw SQL with pg driver
1010** Code Quality** : 98% compliance with professional Node.js development standards
1111** Security** : Zero SQL injection vulnerabilities, multi-layer defense with department-based access control, search input sanitization, admin mutation rate limiting
12- ** Testing** : 945 test cases passing (100%) - 38 test suites with comprehensive unit, integration, and E2E coverage
12+ ** Testing** : 1004 test cases passing (100%) - 39 test suites with comprehensive unit, integration, and E2E coverage
1313** CI/CD** : Docker-based testing + ESLint + Prettier + security audit via GitHub Actions
1414** Version** : 2.4.0 (Professional CI/CD + Docker-Based Testing + Full Lint Compliance)
1515
@@ -31,10 +31,10 @@ This file provides a quick reference for AI assistants. For comprehensive docume
3131 - Security debugging, performance optimization, common issues
3232 - Command reference for Docker, PostgreSQL, PM2
3333- ** [ Testing Guidelines] ( docs/testing_rules.md ) ** - Testing patterns and practices (850+ lines)
34- - Test statistics: 945/945 passing (100% pass rate)
34+ - Test statistics: 1004/1004 passing (100% pass rate)
3535 - Test infrastructure documentation (floor seeding, cleanup order)
3636 - Transaction-based isolation, FK-aware cleanup
37- - Migration testing (all 25 migrations validated)
37+ - Migration testing (all 28 migrations validated)
3838- ** [ CI/CD Guide] ( docs/ci-cd.md ) ** - GitHub Actions workflows and automation - UPDATED v2.4.0
3939 - Docker-based test execution (matches local dev workflow)
4040 - Lint workflow (ESLint + Prettier, zero conflicts)
@@ -46,7 +46,7 @@ This file provides a quick reference for AI assistants. For comprehensive docume
4646
4747## Testing Infrastructure
4848
49- ** 945/945 tests passing (100%)** - 38 test suites (Unit: 23, Integration: 12, E2E: 3 ). Coverage threshold: 60%. Details in [ docs/testing_rules.md] ( docs/testing_rules.md ) .
49+ ** 1004/1004 tests passing (100%)** - 39 test suites (Unit: 23, Integration: 12, E2E: 4 ). Coverage threshold: 60%. Details in [ docs/testing_rules.md] ( docs/testing_rules.md ) .
5050
5151** IMPORTANT** : All tests MUST run inside Docker. Tests require ` --runInBand ` (sequential) to prevent cross-suite contamination.
5252
@@ -60,8 +60,10 @@ docker-compose exec web npx jest tests/unit/models/User.test.js --no-coverage #
6060```
6161
6262** Key infrastructure notes** :
63- - CSRF protection disabled in test environment (` NODE_ENV=test ` )
63+ - CSRF is ** enabled globally** (real csrf-csrf double-submit cookie in all envs, including test)
64+ - CSRF test helpers: ` tests/helpers/csrf.js ` — ` fetchCsrfToken() ` , ` authenticateUser() ` , ` extractCsrfToken() ` , ` mergeCookies() `
6465- FK-aware cleanup order: comments -> tickets -> audit_logs -> session -> users -> departments -> floors
66+ - ** audit_logs cleanup** : Use ` TRUNCATE audit_logs CASCADE ` (not DELETE) — immutability trigger blocks DELETE/UPDATE
6567- Floor seeding runs before departments to satisfy FK constraints
6668- Unit tests use transaction isolation with dedicated client (not ` pool.query() ` )
6769- Benchmarks: ` npm run bench ` (auth, tickets, comments). Details in ` docs/performance-baseline.md `
@@ -511,14 +513,17 @@ models/* → config/database.js (pool)
5115133 . Update relevant model to use new column
5125144 . Never modify existing migration files
513515
514- ** Current migration number** : 025 (last: add_composite_indexes )
516+ ** Current migration number** : 028 (last: audit_logs_indexes )
515517
516518** Migration 020** : add_department_floor - Added floor column to departments table with CHECK constraint
517519** Migration 021** : fix_audit_log_fk_constraint - Fixed audit_logs FK to use ON DELETE SET NULL for audit trail preservation
518520** Migration 022** : create_floors_table - Created floors table for database-driven floor management (replaces hardcoded constants)
519521** Migration 023** : convert_floor_to_fk - Converted departments.floor from CHECK constraint to foreign key for dynamic floor management
520522** Migration 024** : remove_hardcoded_system_floors - Removed seeded system floors to make floors fully dynamic and customizable
521523** Migration 025** : add_composite_indexes - Added composite indexes for 50-80% performance improvement in dashboard queries
524+ ** Migration 026** : audit_logs_extended_columns - Added 7 columns to audit_logs (actorUsername, actorRole, sessionHash, targetLabel, action_category, severity, search_text)
525+ ** Migration 027** : audit_logs_backfill - Batched backfill of new audit_log columns
526+ ** Migration 028** : audit_logs_indexes - CONCURRENTLY indexes + pg_trgm GIN index on search_text
522527
523528### Add a new model method
524529``` javascript
@@ -608,7 +613,7 @@ Scripts are for **development/testing only**. Never run in production.
608613GitHub Actions runs two workflows on push/PR to ` main ` /` develop ` . See [ docs/ci-cd.md] ( docs/ci-cd.md ) for details.
609614
610615** CI Workflow** (` .github/workflows/ci.yml ` ):
611- - ** Tests (Docker)** : ` docker compose -f docker-compose.ci.yml up --build --exit-code-from web ` — runs all 945 tests inside Docker with coverage, uploads report as artifact
616+ - ** Tests (Docker)** : ` docker compose -f docker-compose.ci.yml up --build --exit-code-from web ` — runs all 1004 tests inside Docker with coverage, uploads report as artifact
612617- ** Security Audit** : ` npm audit --omit=dev --audit-level=high ` — production deps must be clean
613618
614619** Lint Workflow** (` .github/workflows/lint.yml ` ):
@@ -656,6 +661,7 @@ npm run format:check # Check formatting without changes
6566618 . ** Use synchronous bcrypt methods** - Use async versions
6576629 . ** Forget to handle errors in async routes** - Wrap in try/catch
65866310 . ** Return password_hash from User model public methods** - Security risk
664+ 11 . ** Use DELETE to clean audit_logs in tests** - Immutability trigger blocks DELETE/UPDATE; use ` TRUNCATE audit_logs CASCADE ` instead
659665
660666---
661667
0 commit comments