Repository navigation
feat(tests): implemented comprehensive production-grade automated test suite - #26
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This Pull Request implements FR-1: Automated Test Suite & Quality Gates (Task 2.22 in
docs/audit/2026-07-20/task.md). It establishes a production-grade, zero-dependency, three-layer automated testing architecture using Vitest and Supertest, running 100% in-memory out-of-the-box. It includes decoupled mock data layers, continuous integration (CI) quality gates, path alias standardization, and full documentation consolidation.Key Changes by Functional Area
1. Zero-Infrastructure In-Memory Execution & Decoupled Mocks
src/core/database/prisma.ts&src/core/database/redis.ts) into modular files insidetests/mocks/.Mapbacking store for Prisma (tests/mocks/prisma.ts) supportinguser,session,account, andoidcClientmodels, relation loading (user.accounts,session.user), in-place record mutations,$transactionhandling, and auto-resettingprismaMockspies.ioredis-mock(tests/mocks/redis.ts) to handle custom Redis Lua commands (SCRIPT LOAD,EVALSHA,EVAL) required byrate-limit-redis.@tests/*,@core/*, and@api/*path aliases acrosstsconfig.jsonandvitest.config.ts, replacing relative import paths (../../../).2. Three-Layer Automated Test Suite (61 / 61 Tests Passing)
tests/unit/*.service.test.ts): Covered business logic across all 8 service classes (AuthService,UserService,MfaService,OidcService,OAuthService,SessionService,MagicLinkService,HealthService,AdminService).tests/integration/*.test.ts): Verified Express middlewares (CORS, CSRF double-submit tokens, role authorization, rate-limiters, error sanitizers) and router schema validations.tests/e2e/*.test.ts): Covered multi-step customer flows including Credentials signup/login/rotation/lockout, Magic Link verification, TOTP MFA lifecycle and backup codes, OIDC PKCE authorization and UserInfo, and Admin user/session management.3. Continuous Integration & Artifact Relocation
.github/workflows/ci.ymlto execute Node 20, frozen lockfile caching (pnpm install --frozen-lockfile), linter (pnpm lint), type-check (pnpm type-check), and in-memory test suite (pnpm test).logs/emails/.Documentation Synchronization
docs/testing_architecture.md: Consolidateddocs/testing_architecture.mdanddocs/testing-workflows.mdinto a single authoritative guide detailing test architecture, directory layout, CLI commands, pre-commit hooks, CI gates, and deployment workflows (Local Dev, Docker Dev with Redis Insight, and Docker Prod behind Nginx). Deleted duplicatedocs/testing-workflows.md.docs/api-specs/AuthKit.postman_collection.json: Restructured to cover all 46 API endpoints organized into 10 structured workflow folders.docs/api-specs/openapi.json& Swagger UI: Regenerated and synchronized all 46 endpoints viapnpm build:swagger.README.md: Updated documentation links to point todocs/testing_architecture.mdand detailed the 10 Postman collection workflow folders.docs/audit/2026-07-20/task.md: Marked Phase 2 tasks 2.21, 2.21a, 2.21b, and 2.22 (FR-1) as Done.Verification Summary
pnpm type-check) with zero errors.pnpm lint) and formatting (pnpm format) successfully with zero issues.