batchCooking/apps/web/cypress/support/step_definitions/reference-data.steps.ts
Nicolas 2a3fb0434a
All checks were successful
CI / lint (push) Successful in 3m54s
CI / build (push) Successful in 4m10s
CI / intent-service-test (push) Successful in 5m15s
CI / e2e (push) Successful in 8m32s
CI / test (push) Successful in 23m8s
CI / build-android (push) Has been skipped
feat(onboarding): réordonne le wizard en compte → préférences → foyer → sources (#129)
Nouvel ordre : régime → allergènes (les deux « préférences ») → foyer →
sources. L'étape sources devient la dernière et n'est atteinte que si
l'étape foyer vient de **créer** un foyer — rejoindre ou passer termine le
wizard vers `/` (un foyer rejoint a déjà ses sources ; un foyer passé n'a
rien à quoi les rattacher).

- `onboarding-steps.ts` (nouveau) : séquence des étapes + `onboardingStepIndicator()`
  en un seul endroit. Les compteurs « Étape N sur M » étaient codés en dur
  page par page, ce qu'un réordonnancement cassait. régime/allergènes/foyer
  sont en amont du choix « créer vs rejoindre/passer » donc affichent « sur 3 » ;
  seule l'étape sources, jamais atteinte hors du chemin à 4 étapes, affiche « 4 sur 4 ».
- `OnboardingDietPage` → enchaîne sur `/onboarding/allergenes`.
- `OnboardingAllergensPage` → enchaîne sur `/onboarding/foyer` ; bouton « Continuer »
  (plus « Terminer ») ; suppression du `getCurrentHouse()` + `totalSteps` dynamique,
  devenus inutiles maintenant que cette étape précède le foyer.
- `OnboardingHouseholdPage` → `goToNextStep(createdHousehold)` : `/onboarding/sources`
  seulement si créé, sinon `/`. `JoinHouseholdForm`/`SkipButton`/branche défensive
  « déjà un foyer » terminent vers `/`.
- `OnboardingSourcesPage` → dernière étape : submit, court-circuit « aucune source »
  et catch vont tous vers `/` ; bouton « Terminer ».
- `App.tsx` : blocs `<Route>` réordonnés + commentaire de doc du groupe.
- `specs/frontend-architecture.md` : ordre, diagramme mermaid, condition sources.

Tests : `onboarding.feature` réécrit — 4 parcours (walk-through complet avec
foyer créé + sources ; préférences + foyer passés ; foyer créé sans source
implémentée → étape sources auto-sautée ; foyer rejoint → pas de sources),
compteurs vérifiés sur chaque chemin. `pnpm lint` / `pnpm build` verts ;
Cypress local : onboarding 4/4, régression auth/preferences/household-settings 16/16.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 16:34:49 +02:00

87 lines
3 KiB
TypeScript

import { Given } from "@badeball/cypress-cucumber-preprocessor";
// Shared across auth.feature (signup) and onboarding.feature (wizard) — both
// need the diets/allergies reference lists mocked before reaching a step
// that reads them, in either their "has options" or "is empty" shape.
Given("the diets reference list has options", () => {
cy.intercept("GET", "**/reference/diets", {
statusCode: 200,
body: [
{ id: 1, key: "omnivore" },
{ id: 2, key: "vegetarian" },
],
});
});
Given("the diets reference list is empty", () => {
cy.intercept("GET", "**/reference/diets", { statusCode: 200, body: [] });
});
Given("the allergies reference list has options", () => {
cy.intercept("GET", "**/reference/allergies", {
statusCode: 200,
body: [
{ id: 1, key: "peanuts", kind: "ALLERGY" },
{ id: 2, key: "gluten", kind: "INTOLERANCE" },
],
});
});
Given("the allergies reference list is empty", () => {
cy.intercept("GET", "**/reference/allergies", { statusCode: 200, body: [] });
});
// An onboarding scenario whose household step *creates* a household then
// reaches `/onboarding/sources` (see `OnboardingHouseholdPage`'s
// `goToNextStep`), which reads this before self-skipping straight to the
// home page if it comes back empty.
Given("the sources reference list is empty", () => {
cy.intercept("GET", "**/reference/sources", { statusCode: 200, body: [] });
});
// `id`/`key` pairs mirror `recipes.ts`'s `omeletteDetail` fixture (`cook`,
// id 1, is the step's existing match) plus a second option
// (`simmer`/"Mijoter") for `recipes.feature`'s correction scenario to
// re-assign to — TechStepCorrectionPopover's own picker needs at least two
// choices for that scenario to be a meaningful correction, not a no-op.
Given("the tech steps reference list has options", () => {
cy.intercept("GET", "**/reference/tech-steps", {
statusCode: 200,
body: [
{ id: 1, key: "cook" },
{ id: 3, key: "simmer" },
],
});
});
// The real first entry (`theMealDb`) mirrors what's actually seeded
// (`reference-seed-data.ts`'s `registerAllRecipeSources`/
// `syncRecipeSources`); the second is illustrative only — a future
// per-site scraper adapter, not tied to any real one that exists yet (the
// generic `jsonLdRecipeAdapter` is deliberately never registered as a
// household-toggleable source in its own right — see `sources/index.ts`).
// Two entries so the sources step (onboarding and `/parametres/foyer`
// alike) has more than one thing to show/select, instead of self-skipping
// or exercising only a single-item list.
Given("the sources reference list has options", () => {
cy.intercept("GET", "**/reference/sources", {
statusCode: 200,
body: [
{
id: 1,
key: "theMealDb",
name: "TheMealDB",
official: true,
iconUrl: "https://www.themealdb.com/images/logo.svg",
},
{
id: 2,
key: "marmiton",
name: "Marmiton",
official: false,
iconUrl: null,
},
],
});
});