Repository navigation
chore: tests unitarios, CI con GitHub Actions y diagrama de arquitectura - #2
Merged
Merged
Conversation
- Unit tests with @nestjs/testing for auth, ticket, assignment, notification, gateway and the common lib (71 tests, no real Postgres/Kafka/Redis needed). - Fix lint/typecheck: per-project .eslintrc.json, allow intra-app path aliases, remove unused imports, nullable TicketResponseDto fields. - Align Nx packages to 18.3.5 and SWC tooling so `build` succeeds; add `typecheck` targets (tsc --noEmit) since SWC builds skip type-check; exclude specs from SWC output. - Track package-lock.json and pin Node 22 in .nvmrc for reproducible CI. - GitHub Actions CI (lint, typecheck, test, build) with README badge and Mermaid architecture + sequence diagrams. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
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.
Problema
El repo (proyecto fijado #1 del perfil) no tenía tests, CI ni un diagrama de arquitectura. Además,
lintybuildno pasaban:lint: el.eslintrc.jsonraíz ignora**/*y ningún proyecto tenía su propio config → "All files are ignored".build: versiones de Nx mezcladas (nx 18.0.4+@nx/eslint-plugin ^22) y@swc/cli 0.7(la salida cambió y el executor@nx/js:swcde Nx 18 marcaba el build como fallido aunque compilaba); además el type-check del executor SWC falla conTS6059 rootDiral importar las libs no-buildables (@app/common,@app/contracts).package-lock.jsonestaba en.gitignore), así que no se podía hacernpm ci.Qué cambia
Tests (71, todos unitarios con
@nestjs/testing, sin Postgres/Kafka/Redis reales):user.registereden outbox), login con JWT real firmado/verificado, hash bcrypt del password y del refresh token, credenciales inválidas, usuario inactivo, refresh token falsificado/no coincidente, logoutfindOne/update/deleteconNotFoundException, transiciones de estado (ticket.status.changedsólo si cambia), filtros y paginación, comentarios,@Roles(ADMIN, PROJECT_MANAGER)en deleteoutbox_events→KafkaService.emit('assignment.events', ticket.assigned)usando elOutboxServicereal sobre un repositorio en memoria@EventPattern), cobertura de todos losKAFKA_TOPICS, manejo de eventosuserIddel JWT propagado al proxy, rutas@Public(); proxy de tickets propagando status code de errores downstreamOutboxService(PENDING → SENT, reintentos, FAILED tras 5),JwtAuthGuardyRolesGuardConfiguración (cambios mínimos para que lint/typecheck/build pasen):
.eslintrc.jsonpor proyecto (convención Nx) yallowen@nx/enforce-module-boundariespara los alias internos de cada app (@auth/*,@gateway/*, …), que son una convención documentada del repo.18.3.5;@swc/cli ~0.3.12,@swc/core ~1.5.7,@swc-node/register ~1.9.1;@nestjs/testingcomo devDependency.skipTypeCheck: true(como ya teníaauth-service) y nuevo targettypecheck(tsc --noEmit) por app, para no perder la verificación de tipos..swcrcexcluye specs yjest.configdel output.typecheck: imports sin uso yTicketResponseDtoconestimatedHours/sprintId/parentTicketIdnullable (coinciden con la entidad).package-lock.jsonversionado y.nvmrccon Node 22.CI:
.github/workflows/ci.yml(CI) en push amastery en PRs:npm ci+npx nx run-many -t lint typecheck test build. UsaNX_NO_CLOUD=true, no necesita secretos.README: badge de CI y sección
## Arquitectura (diagrama)con un flowchart Mermaid (cliente → gateway JWT → servicios → su Postgres → outbox → tópicos Kafka reales → notification-service, Redis) y un diagrama de secuencia "asignar ticket → evento → notificación".Cómo se usa
Casos borde / hallazgos (no corregidos en este PR)
OutboxService.processPendingEvents()existe pero nada lo invoca (@Cron/@Interval), así que hoy los eventos quedanPENDINGenoutbox_eventsy no llegan a Kafka. Quedó documentado en el README.@app/common,@auth/...) ni incluye las libs endist, así quenode dist/.../main.js/nx servefallarían en runtime. Arreglarlo implica cambiar la estrategia de build (p. ej.@nx/webpacko libs buildables) y queda para otro PR.CommentsService.deleteno verifica que quien borra sea el autor (el parámetrouserIdno se usa).nx.jsoncontienenxCloudAccessToken(read-write) versionado en un repo público; conviene rotarlo/moverlo a variable de entorno. El CI lo ignora conNX_NO_CLOUD=true.npm cimuestra un warning de peer (@swc-node/corepide@swc/core >= 1.13.3); no afecta lint/test/build.Validación
Local (Windows 11, Node 22.16.0,
npm cidesde cero,CI=true NX_NO_CLOUD=true):Tests por proyecto: auth-service 14, ticket-service 18, assignment-service 7, notification-service 9, gateway 11, common 12, contracts 0 (sin lógica) → 71 en verde.
🤖 Generated with Claude Code