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;