batchCooking/apps/web/cypress/support/step_definitions/reference-data.steps.ts
Nicolas 53d415fddb feat(tech-steps): fiabilise la detection des tech steps (corpus + LLM + corrections utilisateur)
Une seule feature livree en une seule PR, en 5 phases :

- Phase 1 : enrichit le corpus NLP (tech-step-training-data.ts) et ajoute
  un harness d'evaluation (precision/rappel/F1) avec un jeu de test etiquete
  - la premiere metrique objective de qualite pour ce classifieur.
- Phase 2 : schema Prisma (StepTechStepCorrection, TechStepTrainingSuggestion)
  + endpoints utilisateur (POST/GET corrections, ouverts a tout viewer, pas
  seulement l'auteur) + endpoints internes /internal/tech-steps/* proteges
  par secret partage (requireInternalWorker).
- Phase 3 : UI de highlight/correction cote web (selection de texte ->
  association a une technique, ou clic sur un highlight existant pour le
  corriger/supprimer) - verifiee via Cypress (component + e2e, en Chrome
  reel).
- Phase 4 : worker LLM autonome (services/tech-step-llm-worker, hors du
  monorepo pnpm comme experiments/llm-tech-step-poc) qui audite les clauses
  a faible confiance et transforme les corrections utilisateur en
  suggestions d'entrainement, sans jamais toucher le chemin interactif.
- Phase 5 : script retrain-tech-steps.ts (gate de regression F1 + backfill)
  et list-pending-training-suggestions.ts pour la revue humaine avant
  application au corpus.

Verification effectuee cette session : tsc/biome sur l'ensemble du repo,
build complet (pnpm build), suite Cypress complete (component 39/39, e2e
75/76 - le seul echec est preexistant et sans rapport, cote
recipe-form.feature/ingredient-picker), tests unitaires du worker (6/6) et
son install/typecheck reels contre node-llama-cpp. Les tests Mocha
d'apps/api (Phases 1 et 2) n'ont pas pu etre executes dans cette session
(pas de Postgres local disponible) - a lancer avant merge.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 09:48:02 +02:00

87 lines
3.1 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: [] });
});
// `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,
},
],
});
});