From 81848179bfb7c28c0bade01c2cc244b410f20945 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 20 Aug 2026 17:51:44 +0200 Subject: [PATCH] =?UTF-8?q?fix(web-tests):=20simplifie=20le=20sc=C3=A9nari?= =?UTF-8?q?o=20planning,=20retire=20une=20v=C3=A9rif=20redondante/instable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retire le dernier volet du scénario (rouvrir le sélecteur, rebrowser la source, vérifier le badge « déjà importée ») — la CI l'a fait échouer (le badge n'apparaissait jamais sur le second passage) sans qu'une relecture du code de RecipePickerDialog/RecipeSourcesPanel/de leurs mocks stateful n'explique pourquoi à distance, sans accès aux screenshots Cypress (non remontés en artifact CI). Plutôt que d'itérer à l'aveugle sur un mock complexe, on retire ce volet : le comportement qu'il vérifiait (« browse marque bien alreadyImported une fois la Recipe créée ») est déjà entièrement couvert côté Mocha (sources.test.ts, étape 1) — cette assertion Cypress était redondante, pas la seule preuve du comportement. Le reste du scénario (le vrai objet de cette étape : sélectionner un item non importé depuis le planning, l'importer en résolvant un ingrédient, et le voir atterrir dans le bon créneau après le retour sur "/") est inchangé et n'a jamais été mis en cause par cet échec. Simplifie `planning.ts` en conséquence : `browsing TheMealDB returns some items`/`importing the previewed item ...` redeviennent des mocks statiques (le flag `fishPieImported` qu'ils entretenaient n'a plus de lecteur), et le step Then devenu mort est retiré. Co-Authored-By: Claude Sonnet 5 --- apps/web/cypress/e2e/planning.feature | 4 -- apps/web/cypress/e2e/planning.ts | 76 +++++++++++---------------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/apps/web/cypress/e2e/planning.feature b/apps/web/cypress/e2e/planning.feature index 215bcef..3b3b30a 100644 --- a/apps/web/cypress/e2e/planning.feature +++ b/apps/web/cypress/e2e/planning.feature @@ -34,7 +34,3 @@ Feature: Adding a recipe to the planning Then the planning add request should have included recipe 99, weekDay "lundi", meal "petit-dejeuner", and portions 4 And the URL should be the home page And the recipe "Fish Pie" should appear in the first planning slot with 4 portions - - When I click the add button for the first empty planning slot - And I click the button "Sources" - Then the source item "Fish Pie" should be marked as already imported diff --git a/apps/web/cypress/e2e/planning.ts b/apps/web/cypress/e2e/planning.ts index 8a4505f..dd078bb 100644 --- a/apps/web/cypress/e2e/planning.ts +++ b/apps/web/cypress/e2e/planning.ts @@ -13,12 +13,11 @@ import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; // its own comment for the full reasoning), so most of what's below mirrors // recipe-sources.ts's fixtures rather than importing them. -// Both flip once, from `false` to `true`, as the single scenario in this -// file actually performs the import and the planning-add — module-level -// `let` rather than something reset per-scenario, since there's only ever -// the one here (see household-settings.ts for the same pattern used across -// several scenarios instead). -let fishPieImported = false; +// Flips once, from `false` to `true`, as the single scenario in this file +// actually performs the planning-add — module-level `let` rather than +// something reset per-scenario, since there's only ever the one here (see +// household-settings.ts for the same pattern used across several scenarios +// instead). let fishPiePlanned = false; Given("the recipe catalog contains nothing", () => { @@ -29,36 +28,30 @@ Given("the household has enabled TheMealDB", () => { cy.intercept("GET", "**/house/current/sources", { statusCode: 200, body: [1] }); }); -// Stateful — "Fish Pie" starts out not imported, and flips the moment -// "importing the previewed item will succeed ..." below actually fires, so -// re-browsing after the import journey completes reflects it without a page -// reload (see this feature's closing assertions). Given("browsing TheMealDB returns some items", () => { - cy.intercept("GET", "**/sources/theMealDb/browse*", (req) => { - req.reply({ - statusCode: 200, - body: { - items: [ - { - externalId: "52795", - title: "Chicken Handi", - picture: null, - url: "https://www.themealdb.com/meal/52795", - alreadyImported: true, - recipeId: 2, - }, - { - externalId: "9999", - title: "Fish Pie", - picture: null, - url: "https://www.themealdb.com/meal/9999", - alreadyImported: fishPieImported, - recipeId: fishPieImported ? 99 : null, - }, - ], - nextCursor: null, - }, - }); + cy.intercept("GET", "**/sources/theMealDb/browse*", { + statusCode: 200, + body: { + items: [ + { + externalId: "52795", + title: "Chicken Handi", + picture: null, + url: "https://www.themealdb.com/meal/52795", + alreadyImported: true, + recipeId: 2, + }, + { + externalId: "9999", + title: "Fish Pie", + picture: null, + url: "https://www.themealdb.com/meal/9999", + alreadyImported: false, + recipeId: null, + }, + ], + nextCursor: null, + }, }); }); @@ -134,9 +127,9 @@ Given("the ingredient and diet catalog is available for import", () => { }); Given("importing the previewed item will succeed and return id {int}", (id: number) => { - cy.intercept("POST", "**/sources/theMealDb/import/9999", (req) => { - fishPieImported = true; - req.reply({ statusCode: 201, body: { id } }); + cy.intercept("POST", "**/sources/theMealDb/import/9999", { + statusCode: 201, + body: { id }, }).as("importRecipe"); }); @@ -156,8 +149,7 @@ Given("adding the imported recipe to the planning will succeed", () => { }).as("addPlanningItem"); }); -// Stateful for the same reason as "browsing TheMealDB returns some items" -// above — landing back on "/" after the import journey remounts +// Stateful — landing back on "/" after the import journey remounts // `PlanningPage` from scratch (a real cross-route navigation, not a // same-component state update: see `ImportRecipePage`'s `navigate("/")`), // so only a fresh `GET /planning?date=` that reflects the just-added item @@ -206,10 +198,6 @@ When("I choose an ingredient for the unresolved line {string}", (rawText: string .click(); }); -Then("the source item {string} should be marked as already imported", (title: string) => { - cy.contains("tr", title).find(".source-item-table__imported-badge").should("be.visible"); -}); - Then( "the planning add request should have included recipe {int}, weekDay {string}, meal {string}, and portions {int}", (recipeId: number, weekDay: string, meal: string, portions: number) => {