fix(web-tests): simplifie le scénario planning, retire une vérif redondante/instable

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 <noreply@anthropic.com>
This commit is contained in:
Nicolas 2026-08-20 17:51:44 +02:00
parent 991f91bc0e
commit 81848179bf
2 changed files with 32 additions and 48 deletions

View file

@ -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

View file

@ -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,13 +28,8 @@ 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({
cy.intercept("GET", "**/sources/theMealDb/browse*", {
statusCode: 200,
body: {
items: [
@ -52,15 +46,14 @@ Given("browsing TheMealDB returns some items", () => {
title: "Fish Pie",
picture: null,
url: "https://www.themealdb.com/meal/9999",
alreadyImported: fishPieImported,
recipeId: fishPieImported ? 99 : null,
alreadyImported: false,
recipeId: null,
},
],
nextCursor: null,
},
});
});
});
Given("previewing TheMealDB item {string} is available", (externalId: string) => {
cy.intercept("GET", `**/sources/theMealDb/preview/${externalId}`, {
@ -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) => {