diff --git a/apps/api/src/sources/index.ts b/apps/api/src/sources/index.ts index ea2f9a1..3ff3159 100644 --- a/apps/api/src/sources/index.ts +++ b/apps/api/src/sources/index.ts @@ -1,16 +1,17 @@ import { registerRecipeSource } from "../lib/recipe-source-registry.js"; -import { jsonLdRecipeAdapter } from "./json-ld-recipe.js"; import { theMealDbAdapter } from "./the-meal-db.js"; /** - * Registers every concrete `RecipeSourceAdapter` this app ships with into - * the shared in-memory registry (`recipe-source-registry.ts`) — currently - * `theMealDbAdapter` and `jsonLdRecipeAdapter`. Called once, explicitly, by - * the two real entry points that need the registry populated: + * Registers every concrete, *browsable* `RecipeSourceAdapter` this app + * ships with into the shared in-memory registry + * (`recipe-source-registry.ts`) — currently just `theMealDbAdapter`. + * Called once, explicitly, by the two real entry points that need the + * registry populated: * * - `server.ts` — the running API process, before it starts listening. * - `prisma/seed.ts` — so `syncRecipeSources` has something to mirror into - * the `sources` table. + * the `sources` table (`Source`, household-toggleable — see + * `HouseSource`). * * Deliberately **not** imported by `app.ts`: `createApp()` is what every * test file gets via supertest, and registering a real adapter there would @@ -19,8 +20,16 @@ import { theMealDbAdapter } from "./the-meal-db.js"; * `clearRecipeSources()` clears it out) instead of each test's own * explicit setup. Tests that need a source in the registry register their * own throwaway fake instead (see e.g. `test/recipe-source-sync.test.ts`). + * + * `jsonLdRecipeAdapter` (json-ld-recipe.ts) is deliberately **not** + * registered here — it's a generic schema.org-JSON-LD parser meant to be + * specialized per scraped website (a concrete adapter for a specific site + * would use it internally), not a household-toggleable `Source` in its own + * right: nobody can meaningfully "trust" or "enable" a generic parsing + * mechanism the way they can a named website. Until real per-site adapters + * exist, it's called directly (e.g. a future "import from a pasted URL" + * flow), never through this registry. */ export function registerAllRecipeSources(): void { registerRecipeSource(theMealDbAdapter); - registerRecipeSource(jsonLdRecipeAdapter); } diff --git a/apps/api/test/sources-index.test.ts b/apps/api/test/sources-index.test.ts index 1ba4e42..f13bcb3 100644 --- a/apps/api/test/sources-index.test.ts +++ b/apps/api/test/sources-index.test.ts @@ -25,12 +25,10 @@ describe("registerAllRecipeSources", () => { expect(listRecipeSources().map((adapter) => adapter.key)).to.include("theMealDb"); }); - it("registers the generic JSON-LD source into the shared registry", () => { + it("does not register the generic JSON-LD adapter — it's not a household-toggleable source in its own right", () => { registerAllRecipeSources(); - const jsonLd = getRecipeSource("jsonLdRecipe"); - expect(jsonLd).to.not.be.undefined; - expect(jsonLd?.official).to.equal(false); - expect(listRecipeSources().map((adapter) => adapter.key)).to.include("jsonLdRecipe"); + expect(getRecipeSource("jsonLdRecipe")).to.be.undefined; + expect(listRecipeSources().map((adapter) => adapter.key)).to.not.include("jsonLdRecipe"); }); }); diff --git a/apps/web/cypress/e2e/household-settings.feature b/apps/web/cypress/e2e/household-settings.feature index d3bc168..17b9b55 100644 --- a/apps/web/cypress/e2e/household-settings.feature +++ b/apps/web/cypress/e2e/household-settings.feature @@ -65,7 +65,7 @@ Feature: Household settings Then I should see the section "Sources disponibles" And I should see "TheMealDB" And I should see "Officielle" - And I should see "Import générique (JSON-LD)" + And I should see "Marmiton" And I should see "Non officielle" When I check the checkbox "TheMealDB" Then the source selection update request should have been made with source id 1 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 edcb805..f105815 100644 --- a/apps/web/cypress/support/step_definitions/reference-data.steps.ts +++ b/apps/web/cypress/support/step_definitions/reference-data.steps.ts @@ -40,11 +40,15 @@ Given("the sources reference list is empty", () => { cy.intercept("GET", "**/reference/sources", { statusCode: 200, body: [] }); }); -// Mirrors what's actually seeded (`reference-seed-data.ts`'s -// `registerAllRecipeSources`/`syncRecipeSources`) — one official API source -// with an icon, one unofficial scraper without one — so the sources step -// (onboarding and `/parametres/foyer` alike) has something real to show -// instead of self-skipping. +// 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, @@ -58,8 +62,8 @@ Given("the sources reference list has options", () => { }, { id: 2, - key: "jsonLdRecipe", - name: "Import générique (JSON-LD)", + key: "marmiton", + name: "Marmiton", official: false, iconUrl: null, },