From 30fffd59adfe4f9f8777386b81553725d392f12b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 20 Aug 2026 09:47:17 +0200 Subject: [PATCH] =?UTF-8?q?fix(web):=20corrige=20l'e2e=20onboarding=20cass?= =?UTF-8?q?=C3=A9=20par=20l'=C3=A9tape=20sources?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GET /reference/sources n'était intercepté par aucun scénario Cypress menant à la création/jonction d'un foyer — la requête réelle restait en attente indéfiniment, laissant OnboardingSourcesPage bloqué sur /onboarding/sources au lieu de s'auto-sauter vers /onboarding/allergenes. - Ajout du Given "the sources reference list is empty" (même pattern que les intercepts diets/allergies existants), câblé dans les deux scénarios qui créent/rejoignent un foyer. - Mise à jour de l'assertion "Étape 3 sur 3" → "Étape 4 sur 4" : un foyer étant créé dans ce scénario, l'étape allergènes affiche désormais le total dynamique (4 étapes) comme prévu. - OnboardingSourcesPage.tsx : redirige aussi vers /onboarding/allergenes en cas d'échec réseau sur getSources(), pas seulement quand la liste est vide — le wizard ne doit pas bloquer l'utilisateur sur une étape optionnelle à cause d'un problème transitoire. Co-Authored-By: Claude Sonnet 5 --- apps/web/cypress/e2e/onboarding.feature | 6 ++++-- .../support/step_definitions/reference-data.steps.ts | 10 ++++++++++ .../web/src/pages/onboarding/OnboardingSourcesPage.tsx | 8 ++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/web/cypress/e2e/onboarding.feature b/apps/web/cypress/e2e/onboarding.feature index c429a82..2997214 100644 --- a/apps/web/cypress/e2e/onboarding.feature +++ b/apps/web/cypress/e2e/onboarding.feature @@ -6,11 +6,12 @@ Feature: Onboarding wizard Background: Given the planning request returns nothing - Scenario: Walks through all three steps, creating a household on the way, and lands on the home page + Scenario: Walks through the wizard, creating a household on the way (which surfaces the sources step), and lands on the home page Given the diets reference list has options And selecting the diet will succeed And the household request returns no household And creating a household will succeed + And the sources reference list is empty And the allergies reference list has options And updating allergies will succeed And I have signed up @@ -25,7 +26,7 @@ Feature: Onboarding wizard And I click the button "Créer" Then the household creation request should have been made with name "Chez Alice" And the URL should include "/onboarding/allergenes" - And I should see "Étape 3 sur 3" + And I should see "Étape 4 sur 4" And I should see the section "Allergies" And I should see the section "Intolérances" When I check the checkbox "Arachides" @@ -56,6 +57,7 @@ Feature: Onboarding wizard And selecting the diet will succeed And the household request returns no household And joining a household will succeed + And the sources reference list is empty And the allergies reference list is empty And updating allergies will succeed And I have signed up diff --git a/apps/web/cypress/support/step_definitions/reference-data.steps.ts b/apps/web/cypress/support/step_definitions/reference-data.steps.ts index 732da0e..263bf19 100644 --- a/apps/web/cypress/support/step_definitions/reference-data.steps.ts +++ b/apps/web/cypress/support/step_definitions/reference-data.steps.ts @@ -31,3 +31,13 @@ Given("the allergies reference list has options", () => { Given("the allergies reference list is empty", () => { cy.intercept("GET", "**/reference/allergies", { statusCode: 200, body: [] }); }); + +// Every onboarding scenario that reaches the household step also reaches +// `/onboarding/sources` right after (when a household got created/joined — +// see `OnboardingHouseholdPage`'s `goToNextStep`), which reads this before +// self-skipping to `/onboarding/allergenes`. No "has options" counterpart +// yet — no source is implemented in the app itself, so there's nothing +// real to mock a populated catalog with. +Given("the sources reference list is empty", () => { + cy.intercept("GET", "**/reference/sources", { statusCode: 200, body: [] }); +}); diff --git a/apps/web/src/pages/onboarding/OnboardingSourcesPage.tsx b/apps/web/src/pages/onboarding/OnboardingSourcesPage.tsx index 331f73e..68f7cd3 100644 --- a/apps/web/src/pages/onboarding/OnboardingSourcesPage.tsx +++ b/apps/web/src/pages/onboarding/OnboardingSourcesPage.tsx @@ -44,9 +44,13 @@ export function OnboardingSourcesPage() { return; } setSources(result); + setIsLoading(false); }) - .finally(() => { - if (!cancelled) setIsLoading(false); + .catch(() => { + // Nothing to configure sources for if we can't even list them — the + // wizard shouldn't strand the visitor here over a transient failure + // fetching an optional step's own data. + if (!cancelled) navigate("/onboarding/allergenes", { replace: true }); }); return () => { cancelled = true;