Skip to content

test(api): fail loudly when the SPA bundle is missing - #100

Merged
rodrigoc89 merged 1 commit into
developfrom
test/spa-bundle-fails-loud
Nov 1, 2026
Merged

rodrigoc89 merged 1 commit into
developfrom
test/spa-bundle-fails-loud

Conversation

@rodrigoc89

Copy link
Copy Markdown
Collaborator

Issue relacionada

Sin issue vinculada, a propósito. Es el follow-up directo de un hallazgo medido durante el PR #98: el conteo de tests de este repo dependía del entorno de una forma invisible. No hay issue abierta que describa el problema, y no referencio una ajena para no cerrarla de rebote.

El problema, con números: sin el bundle del frontend, SpaRoutingHttpTests se salteaba entera y el reporte decía 4 skipped, mientras en realidad se perdían 21 ejecuciones (1 @Test + 20 casos de tres @ParameterizedTest). JUnit cuenta un contenedor deshabilitado como un placeholder por método, así que el agujero de cobertura se veía cuatro veces más chico de lo que era — y la suite quedaba verde igual.

Tipo de PR

  • Mantenimiento/tooling (type:chore) — sólo un test y un documento. Sin cambios de producción.

Resumen

  • @EnabledIf("spaEntryPresent") sale de SpaRoutingHttpTests; entra un @BeforeAll que falla explícito si falta static/admin/admin.html, con un mensaje que dice exactamente qué correr para construir el bundle.
  • Un worktree sin bundle ya no puede reportar verde cubriendo menos de lo que declara.
  • El costo es deliberado y está documentado: mvn verify local sin -Pfrontend ahora falla en vez de pasar con skips. El CI no se ve afectado porque siempre construye el bundle.

Cambios

Archivo Cambio
api/src/test/java/com/carrito/saas/SpaRoutingHttpTests.java Fuera @EnabledIf; entra requireSpaBundle() (@BeforeAll) con IllegalStateException y mensaje accionable. Javadoc actualizado: explicaba el skip, ahora explica por qué no
odd/tasks/cross-tenant-followups.md L7 con la evidencia de los dos lados, el costo declarado y el estado de develop; sección de entrega actualizada con el merge de #98 (6fedb18)

Plan de pruebas

Los dos lados, con el mismo comando (-Dtest=SpaRoutingHttpTests):

Escenario Antes Ahora
Con bundle Tests run: 21, BUILD SUCCESS Tests run: 21, Failures: 0, Errors: 0, Skipped: 0, BUILD SUCCESS
Sin bundle Tests run: 4, Skipped: 4, BUILD SUCCESS (exit 0) Tests run: 1, Errors: 1, BUILD FAILURE (exit 1)

Lado que falla, literal:

java.lang.IllegalStateException: SpaRoutingHttpTests needs the served SPA bundle
(static/admin/admin.html), which is not committed. Build it first:
`npm run build:spring` inside frontend/, or run `mvn -Pfrontend verify`, which is
what CI does. Without it this class would silently lose 21 executions (1 @Test +
20 @ParameterizedTest cases) and report 4 skips instead of them.
  at SpaRoutingHttpTests.requireSpaBundle(SpaRoutingHttpTests.java:70)

El escenario "sin bundle" se corrió en una copia throwaway en /tmp con el admin.html borrado; el árbol real nunca se tocó. El escenario "con bundle" es el árbol real con el bundle construido por -Pfrontend.

  • CI: mvn -B --no-transfer-progress -Pfrontend verify (el comando de ci.yml), que construye el bundle y por eso pasa.
  • Frontend / migraciones: N/A, no se tocan.

Checklist

  • Issue relacionada aprobada — no hay issue para este trabajo (ver arriba); ci.yml no tiene gate de issue
  • Exactamente un label type:* (type:chore)
  • Commits en formato conventional y sin trailers Co-Authored-By
  • Docs actualizadas: odd/tasks/cross-tenant-followups.md L7

SpaRoutingHttpTests was @EnabledIf("spaEntryPresent") over
static/admin/admin.html, a bundle that is not committed and that only the
frontend profile generates. A worktree without it skipped the whole class and
the suite stayed green while covering less than it claimed: JUnit counts a
disabled container as one placeholder per method, so the report said "4
skipped" while the 20 @ParameterizedTest cases were never expanded and 21
executions were silently lost.

A @BeforeAll now fails with the reason and the two commands that build the
bundle, instead of skipping. Verified both ways with the same command: with the
bundle, 21 run and the build succeeds; in a copy with the bundle removed, the
class fails with IllegalStateException at requireSpaBundle and the build fails.

The cost is deliberate and documented: a local mvn verify without -Pfrontend
now fails. CI always builds the bundle, so it is unaffected.
@rodrigoc89 rodrigoc89 added the type:chore Mantenimiento/tooling label Nov 1, 2026
@rodrigoc89
rodrigoc89 merged commit 7a17517 into develop Nov 1, 2026
1 check passed
@rodrigoc89
rodrigoc89 deleted the test/spa-bundle-fails-loud branch November 1, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Mantenimiento/tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant