jsonLdRecipeAdapter était enregistré (et donc synchronisé comme Source sélectionnable par un foyer) au même titre que theMealDbAdapter — mais c'est une structure générique de parsing schema.org destinée à être déclinée par site web scrappé, pas une source qu'on peut raisonnablement « activer » ou « faire confiance » en tant que telle (aucun catalogue à parcourir : list() renvoie toujours vide). registerAllRecipeSources() ne l'enregistre donc plus — elle reste utilisable directement (un futur adapter par site l'utiliserait en interne, ou un futur flux « importer depuis une URL » l'appellerait directement), simplement plus comme Source autonome du registre. Corrige aussi le mock Cypress qui prétendait « mirrorer ce qui est vraiment seedé » avec cette même source — remplacé par un second exemple clairement illustratif (Marmiton), qui ne correspond à aucun adapter réel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
72 lines
2.5 KiB
TypeScript
72 lines
2.5 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: [] });
|
|
});
|
|
|
|
// 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` if it comes back empty.
|
|
Given("the sources reference list is empty", () => {
|
|
cy.intercept("GET", "**/reference/sources", { statusCode: 200, body: [] });
|
|
});
|
|
|
|
// 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,
|
|
},
|
|
],
|
|
});
|
|
});
|