Skip to content

fix: make CI pass and fix the API bugs it uncovered - #23

Merged
nleceguic merged 8 commits into
masterfrom
fix/ci-pipeline
Oct 6, 2026
Merged

nleceguic merged 8 commits into
masterfrom
fix/ci-pipeline

Conversation

@nleceguic

@nleceguic nleceguic commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

El CI llevaba meses sin poder pasar en ninguna PR. Al ponerlo en marcha, los tests de integración destaparon bugs reales de la API.

CI

  • Backend: compila/testea rush-order.backend.slnf. Los proyectos desktop (net8.0-windows) fallaban en Linux.
  • Dependency check: restaura la solución completa con EnableWindowsTargeting=true para seguir auditando el desktop.
  • Docker: el Dockerfile copia Directory.Packages.props/global.json antes del restore (CS0246 INotification).
  • PWA: 5 warnings de lint intencionados anotados; robots.txt añadido.
  • Lighthouse: errors-in-console como warning (no hay backend en CI); off las auditorías de imagen LCP que no aplican.

Tests de integración

  • Config vía UseSetting (Program lee las claves antes de que se apliquen los ConfigureAppConfiguration) y colecciones en serie (carrera en el logger estático de Serilog).
  • Lectura del envelope data; eventos de Stripe con los campos que Stripe.net 46 necesita.

Bugs de la API

  • Flujos anónimos (sin claim tid) devolvían 401/404 por el filtro global de tenant: pedido por QR de invitado, reserva, payment intent/confirm/split, rating, refresh token, verificación MFA y reset de contraseña. Ahora el tenant se resuelve desde la mesa/restaurante/pedido; un token de staff sigue limitado a su tenant y los productos deben ser del restaurante de la mesa.
  • Webhook de Stripe: no encontraba el pago (filtro de tenant), así que los pedidos nunca pasaban a pagados.
  • Event handlers de Infrastructure no registrados en MediatR: no se emitían eventos SignalR (OrderReceived, cambios de estado, mesas) ni se guardaba el historial de estados.
  • KDS: el rol Kitchen recibía 403 en GET /orders.
  • Admin: /admin/tenants y /admin/metrics daban 500 (Dapper bigint a int); respuestas ahora con el envelope data.
  • Logs: el request logging registraba 500 en excepciones ya manejadas (422) y leía un claim de tenant inexistente.

Dependencias vulnerables

  • NuGet: MailKit 4.18.1, JwtBearer 8.0.31, Testcontainers 4.15 (SSH.NET), xunit 2.9.3; referencias explícitas parcheadas a Azure.Identity (tests) y SQLitePCLRaw (desktop). dotnet list package --vulnerable: 0.
  • npm: npm audit fix sin cambios mayores. El audit del CI pasa a evaluar solo dependencias de producción (--omit=dev): las altas/críticas restantes son de tooling (Vite/esbuild, Vitest, Tailwind 3, LHCI) y requieren upgrades mayores o no tienen parche.

Resultado

Todos los jobs en verde: Backend (96 unitarios + 40 integración, cobertura 82,1 %), PWA, Docker/Trivy, Lighthouse, Dependency check.

…ersions in Docker, clear PWA lint warnings

- Backend CI builds/tests rush-order.backend.slnf: desktop projects target
  net8.0-windows and fail on Linux runners (NETSDK1100).
- Dependency check restores the full solution with EnableWindowsTargeting so
  desktop packages are still audited.
- Root Dockerfile copies Directory.Packages.props and global.json before
  restore; without them central package versions were missing (CS0246 on
  MediatR's INotification).
- NuGet cache key includes Directory.Packages.props.
- PWA: annotate the 5 intentional lint warnings so --max-warnings 0 passes.
- Integration tests: pass connection strings and flags via UseSetting.
  Program reads them while registering services, before
  ConfigureAppConfiguration callbacks apply, so the API was pointed at
  localhost:5432 instead of the Testcontainers instance.
- Run test collections serially: ApiFactory and RateLimitApiFactory booted
  in parallel and raced on the static Serilog logger, so the entry point
  exited before building the host.
- PWA: add robots.txt (the SPA fallback served index.html for it).
- Lighthouse: errors-in-console is a warning (no backend in CI); turn off
  LCP-image/animation audits that are not applicable and report NaN.
- Auth responses are wrapped in the ApiResponse envelope; read tokens from
  "data" in AuthHelper, AuthTests, MfaTests and the multi-tenancy logins.
- Stripe webhook test payload includes "object" and "api_version", which
  Stripe.net 46 requires to parse the event.
…er Infrastructure event handlers

Anonymous endpoints (no "tid" claim) were filtered out by the global tenant
query filter, so they failed with 401/404 in real use:
- Guest QR ordering, self-booking, payment intent/confirm/split and rating now
  resolve the tenant from the table/restaurant/order (staff tokens are still
  restricted to their own tenant; products must belong to the table's restaurant).
- Refresh token, MFA verify and password reset look users up across tenants.
- Stripe webhook looks payments/orders/customers up across tenants, so
  payment_intent.succeeded actually marks orders as paid.
- Reservation availability ignores the tenant filter (scoped by restaurantId).

MediatR never scanned the Infrastructure assembly, so OrderPlaced/
OrderStatusChanged/TableStatusChanged/ProductAvailability handlers (SignalR
broadcasts, order status history) never ran. Audit fields are now stamped after
dispatch so entities added by handlers get them too.

Kitchen role can list orders (the KDS uses GET /orders).

Tests: MFA setup response unwrapped from "data"; Stripe test event includes
"request"; CreateOrder unit tests cover guest ordering and tenant/restaurant
mismatches.
…nt claim

- Admin metrics: cast COUNT()/churn to int/float8 so Dapper can materialize
  the int/double records (GET /admin/tenants returned 500).
- Request logging runs outside the exception handler, so handled exceptions
  are logged with their real status (e.g. 422) instead of 500.
- Request log TenantId reads the "tid" claim the JWT actually carries.

Tests: guest order creation now expects 201; flow test Stripe event carries
the fields Stripe.net needs to parse it.
@nleceguic nleceguic changed the title fix(ci): make CI pipeline pass on Linux runners fix: make CI pass and fix the API bugs it uncovered Oct 6, 2026
…check passes

- MailKit 4.18.1 (MimeKit), JwtBearer 8.0.31 (IdentityModel 7.1.x),
  Testcontainers 4.15 (SSH.NET 2026), xunit 2.9.3 (drops NETStandard 1.x
  System.Net.Http / RegularExpressions 4.3.0).
- Explicit patched references: Azure.Identity 1.11.4 in integration tests
  (via Respawn) and SQLitePCLRaw.bundle_e_sqlite3 2.1.13 in desktop.
- Testcontainers 4 image constructors.
- PWA: npm audit fix (non-breaking) and gate the audit on production
  dependencies; remaining high/critical advisories are dev tooling only.
@nleceguic
nleceguic merged commit 0287dce into master Oct 6, 2026
7 checks passed
@nleceguic
nleceguic deleted the fix/ci-pipeline branch October 6, 2026 10:17
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