test(admin): fixe l'intercept monitoring (route page == chemin API)
Some checks failed
CI / build (push) Successful in 2m48s
CI / lint (push) Successful in 3m0s
CI / e2e (push) Successful in 12m51s
CI / intent-service-test (push) Successful in 16m53s
CI / test (push) Failing after 17m9s

La route page `/admin/monitoring` et le chemin API `GET /admin/monitoring`
sont identiques : un glob `**/admin/monitoring` capturait aussi la requete
document du `cy.visit()`. Le hardcode `http://localhost:3000/...` marchait
en local (VITE_API_URL dans apps/web/.env) mais pas en CI (pas de .env ->
API en meme origine sur :5173, donc collision totale) : `cy.wait
(@getMonitoring)` timeout.

`resourceType: "fetch"` epingle l'intercept sur le seul XHR d'AdminApiClient.
Verifie en simulant la CI (sans apps/web/.env) : 16/16 specs admin verts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Nicolas 2026-08-29 19:28:53 +02:00
parent bbd9afe8aa
commit 1a28d67218

View file

@ -52,8 +52,19 @@ describe("Admin monitoring", () => {
cy.intercept("GET", "**/admin/auth/me", { statusCode: 200, body: adminBody }); cy.intercept("GET", "**/admin/auth/me", { statusCode: 200, body: adminBody });
}); });
// The page route `/admin/monitoring` and the API path `GET /admin/monitoring`
// are identical — a plain `**/admin/monitoring` glob would also match the
// `cy.visit()` document request (and whether that's same-origin or not
// depends on `VITE_API_URL`, which isn't set in CI). `resourceType: "fetch"`
// pins the intercept to the `AdminApiClient` XHR only.
const monitoringApi = {
method: "GET",
url: "**/admin/monitoring",
resourceType: "fetch",
} as const;
it("renders one card per service with its status and details", () => { it("renders one card per service with its status and details", () => {
cy.intercept("GET", "http://localhost:3000/admin/monitoring", { cy.intercept(monitoringApi, {
statusCode: 200, statusCode: 200,
body: monitoringFixture(), body: monitoringFixture(),
}).as("getMonitoring"); }).as("getMonitoring");
@ -74,7 +85,7 @@ describe("Admin monitoring", () => {
}); });
it("shows an error state when the request fails", () => { it("shows an error state when the request fails", () => {
cy.intercept("GET", "http://localhost:3000/admin/monitoring", { cy.intercept(monitoringApi, {
statusCode: 500, statusCode: 500,
body: { code: 5000, message: "x" }, body: { code: 5000, message: "x" },
}); });