Backend : - `createRecipe` refactorisé en fine enveloppe autour d'un nouvel helper interne `createRecipeInternal`, paramétré par une source d'import optionnelle ; nouvelle fonction exportée `createImportedRecipe` qui réutilise toute la validation ingrédients/unités/diets et le matching des tech steps, sans dupliquer cette logique. - La locale de l'adaptateur source est propagée jusqu'au chargement des `TechStepMapping`, pour que le texte anglais (TheMealDB, etc.) soit matché contre le bon jeu de règles au lieu du défaut français. - Nouvel endpoint `POST /sources/:sourceKey/import/:externalId` — valide le payload via `createRecipeSchema` (même schéma qu'une création manuelle) et persiste une vraie `Recipe` liée à la source (`sourceId`/`externalId`). - Nouveau code d'erreur `RECIPE_ALREADY_IMPORTED` (4022) quand l'item a déjà été importé pour ce foyer. Frontend : - `ImportRecipePage` (nouvelle page, `/recettes/importer/:sourceKey/:externalId`) — pré-remplit le formulaire depuis `previewSourceItem`, en miroir de `RecipeFormPage` (mêmes sous-composants : `IngredientRow`, `IngredientPicker`, `StepListEditor`, `DietTagSelect`). Ajoute une section dédiée aux lignes d'ingrédients non résolues automatiquement : l'utilisateur choisit un ingrédient réel via l'`IngredientPicker` existant ou retire la ligne — aucune recette invalide n'est jamais soumise, le bouton d'import reste désactivé tant qu'il en reste. - `SourceItemPreviewPanel` gagne un lien « Importer cette recette » vers cet écran. Tests : - Mocha (`apps/api/test/sources.test.ts`) : 6 nouveaux tests sur `POST /sources/:sourceKey/import/:externalId` (payload valide, ingrédient/unité inconnus, déjà importé, deux foyers distincts, locale de la source respectée pour les tech steps). 282 tests passent au total, aucune régression. - Cypress : nouveau scénario Gherkin bout-en-bout dans `recipe-sources.feature` (parcourir → prévisualiser → importer → résoudre un ingrédient non reconnu → confirmer → atterrir sur la recette sauvegardée). Steps d'édition d'ingrédients/étapes génériques déplacés de `recipe-form.ts` vers `cypress/support/step_definitions/common.steps.ts`, réutilisables par ce nouveau scénario. Suite : étape 4 (ajouter au planning déclenche l'import si nécessaire). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
73 lines
3.3 KiB
Gherkin
73 lines
3.3 KiB
Gherkin
Feature: Browsing external recipe sources
|
|
As a signed-in user
|
|
I want to browse the recipes available from my household's enabled sources
|
|
So that I can find new recipes to import, or jump straight to ones I already have
|
|
|
|
Background:
|
|
Given I am signed in as "Alice" "Martin"
|
|
And my household id is 1
|
|
And the disliked ingredients list is empty
|
|
And the planning request returns nothing
|
|
|
|
Scenario: Prompts to enable a source when the household hasn't enabled any
|
|
Given the recipe catalog contains nothing
|
|
And the sources reference list has options
|
|
And the household's enabled sources are empty
|
|
When I visit "/recettes"
|
|
And I click the button "Sources"
|
|
Then I should see "Aucune source n'est activée"
|
|
|
|
Scenario: Browses an enabled source, distinguishing already-imported items from new ones
|
|
Given the recipe catalog contains nothing
|
|
And the sources reference list has options
|
|
And the household has enabled TheMealDB
|
|
And browsing TheMealDB returns some items
|
|
And recipe 2's detail is available
|
|
When I visit "/recettes"
|
|
And I click the button "Sources"
|
|
Then I should see the source item "Chicken Handi"
|
|
And I should see the source item "Fish Pie"
|
|
And the source item "Chicken Handi" should be marked as already imported
|
|
|
|
When I click the source item "Chicken Handi"
|
|
Then the URL should include "/recettes/2"
|
|
And the recipe detail panel heading should be "Omelette"
|
|
|
|
Scenario: Previews a not-yet-imported item, highlighting its detected techniques
|
|
Given the recipe catalog contains nothing
|
|
And the sources reference list has options
|
|
And the household has enabled TheMealDB
|
|
And browsing TheMealDB returns some items
|
|
And previewing TheMealDB item "9999" is available
|
|
When I visit "/recettes"
|
|
And I click the button "Sources"
|
|
And I click the source item "Fish Pie"
|
|
Then the recipe detail panel heading should be "Fish Pie"
|
|
And I should see the highlighted technique "Cuire"
|
|
|
|
Scenario: Reviews an import, resolving an unrecognized ingredient before confirming
|
|
Given the recipe catalog contains nothing
|
|
And the sources reference list has options
|
|
And the household has enabled TheMealDB
|
|
And browsing TheMealDB returns some items
|
|
And previewing TheMealDB item "9999" is available
|
|
And the ingredient and diet catalog is available for import
|
|
And importing the previewed item will succeed and return id 99
|
|
When I visit "/recettes"
|
|
And I click the button "Sources"
|
|
And I click the source item "Fish Pie"
|
|
And I click the button "Importer cette recette"
|
|
Then the "recipe-name" field should have the value "Fish Pie"
|
|
And the recipe should include the ingredient "Oignon"
|
|
|
|
When I choose an ingredient for the unresolved line "some mystery paste"
|
|
And I select the ingredient "Sel" from the picker
|
|
Then the unresolved ingredients section should no longer be shown
|
|
And there should be 2 ingredient rows
|
|
|
|
When I select unit "unité" for the first ingredient
|
|
And I fill in the last ingredient's quantity with "1" and unit "unité"
|
|
Then the "Importer" button should not be disabled
|
|
When I click the button "Importer"
|
|
Then the import request should have included ingredient 2 with quantity 1 and unitId 1
|
|
And the URL should include "/recettes/99"
|