Skip to content

test: add unit coverage for ticket/department services and validators - #5

Open
itheCreator1 wants to merge 1 commit into
mainfrom
test/salvage-phase-1-5-coverage
Open

test: add unit coverage for ticket/department services and validators#5
itheCreator1 wants to merge 1 commit into
mainfrom
test/salvage-phase-1-5-coverage

Conversation

@itheCreator1

Copy link
Copy Markdown
Owner

Summary

  • Adds unit test coverage for services and validators that currently have zero test coverage in main: adminTicketService, clientTicketService, departmentService, errorReportingService, and their validators (adminTicketValidators, clientValidators, departmentValidators)
  • Source: salvaged from the long-stale test/phase-1-5-comprehensive-testing branch (diverged since Jan 2026), ported as standalone files rather than merged — a straight merge hits 19 conflicts including package.json, models/User.js, config/session.js, jest.config.js, and the shared test helpers, because that branch's own test infrastructure (CSRF handling, session storage) has since been rewritten
  • Adapted the ported tests to signature drift since they were originally written:
    • clientTicketService.getDepartmentTickets moved from (userId, filters) to (userId, department, filters) (v2.2.0 department-based access change)
    • Mutation service methods gained a trailing auditContext = {} parameter (recent audit-context threading work)
    • departmentService.createDepartment / validateDepartmentCreate now require a floor field (migration 020+)
    • clientTicketService.createTicket now also passes reporter_name (auto-populated) to Ticket.create
  • Left out of this pass (would need a rewrite, not a port): the branch's 3 route-level integration tests (departments, errorReporting, language), which were written against a CSRF-disabled/MemoryStore test setup that no longer exists — main now uses a real CSRF double-submit cookie flow even in tests (tests/helpers/csrf.js)
  • Did not touch tests/unit/models/Department.test.jsmain's current version (1150 lines) supersedes the branch's (678 lines)

Test plan

  • docker-compose exec web npm test — 1193/1193 passing (was 1004; +189 from this PR)
  • docker-compose exec web npm run lint — clean on all touched files
  • docker-compose exec web npx prettier --check — clean on all touched files
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_011tWtJbqWmefyKJUjXcEmfo

…r-reporting services

Salvages test files from the long-stale test/phase-1-5-comprehensive-testing
branch (diverged since Jan 2026) for modules that exist in main today with
zero test coverage: adminTicketService, clientTicketService,
departmentService, errorReportingService, and their validators
(adminTicketValidators, clientValidators, departmentValidators).

Ported as standalone files rather than merging the branch (which conflicts
on 19 files including package.json and core test infra). Adapted to
signature drift since these were written: clientTicketService.getDepartmentTickets
moved from (userId, filters) to (userId, department, filters) in v2.2.0,
mutation methods gained an auditContext param, and departments now require
a floor field.

+189 tests, 1004 -> 1193 passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011tWtJbqWmefyKJUjXcEmfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant