From 189621c306d11fd3f36b0e609b4b280601b9e5b8 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 17 Aug 2026 07:48:33 +0200 Subject: [PATCH] =?UTF-8?q?Test:=20fix=20auth.cy.ts=20signup=20test=20?= =?UTF-8?q?=E2=80=94=20stale=20post-onboarding-wizard=20assertions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retour de CI (job e2e, PR #10) : "creates a profile and lands on the home page" échouait avec une exception non gérée ("Failed to fetch") depuis OnboardingHouseholdPage's GET /house/current — jamais mocké dans ce test. Cause : ce test n'avait jamais été mis à jour quand le signup a commencé à rediriger vers /onboarding/foyer au lieu de "/" directement (fait dans le commit du wizard d'inscription, plus tôt sur cette PR) — seul le texte "Bonjour Alice Martin" -> "Bonjour Alice" avait été corrigé à l'époque, pas la destination réelle de la redirection. Invisible localement : je n'ai pas pu faire tourner Cypress dans ce sandbox (crash GPU headless, confirmé pré-existant), donc ce test n'avait jamais réellement été exécuté après ce changement — seulement typechecké. Fix : le test vérifie maintenant qu'il atterrit sur /onboarding/foyer (pas la home) avec le nom du foyer préaffiché, et mocke GET /house/current comme le fait déjà onboarding.cy.ts pour ce même écran. Vérifié via tsc --noEmit (Cypress toujours injouable localement ici) — CI à re-checker après push. --- apps/web/cypress/e2e/auth.cy.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/web/cypress/e2e/auth.cy.ts b/apps/web/cypress/e2e/auth.cy.ts index 0f5db35..40250ac 100644 --- a/apps/web/cypress/e2e/auth.cy.ts +++ b/apps/web/cypress/e2e/auth.cy.ts @@ -6,9 +6,14 @@ import { ErrorCode } from "@batch-cooking/shared"; // suites against a real database. describe("Signup", () => { - it("creates a profile and lands on the home page", () => { + it("creates a profile and starts the onboarding wizard (household/regime/allergens)", () => { cy.intercept("GET", "**/auth/me", { statusCode: 401 }); - cy.intercept("GET", "**/planning/current", { statusCode: 200, body: null }); + // The onboarding wizard's first step (see onboarding.cy.ts for the full + // walkthrough) reads the household right away to prefill its name field. + cy.intercept("GET", "**/house/current", { + statusCode: 200, + body: { id: 1, name: "Foyer de Alice" }, + }); cy.intercept("POST", "**/auth/signup", { statusCode: 201, body: { @@ -30,8 +35,11 @@ describe("Signup", () => { cy.contains("button", "Créer mon profil").click(); cy.wait("@signup"); - cy.url().should("not.include", "/signup"); - cy.contains("Bonjour Alice").should("be.visible"); + // Not the home page directly — signup hands off to the onboarding + // wizard first (RedirectIfAuthenticated no longer applies here, it's a + // RequireAuth-gated route of its own, see App.tsx). + cy.url().should("include", "/onboarding/foyer"); + cy.get("#houseName").should("have.value", "Foyer de Alice"); }); it("shows a client-side validation error without calling the API", () => {